{-# LANGUAGE CPP #-}
#include "MachDeps.h"
module Data.ByteString.Utils.ByteOrder
( ByteOrder(..)
, hostByteOrder
, whenLittleEndian
, whenBigEndian
) where
import GHC.ByteOrder (ByteOrder(..))
hostByteOrder :: ByteOrder
hostByteOrder :: ByteOrder
hostByteOrder =
#ifdef WORDS_BIGENDIAN
BigEndian
#else
ByteOrder
LittleEndian
#endif
whenLittleEndian :: (a -> a) -> a -> a
whenLittleEndian :: forall a. (a -> a) -> a -> a
whenLittleEndian a -> a
fun a
val = case ByteOrder
hostByteOrder of
ByteOrder
LittleEndian -> a -> a
fun a
val
ByteOrder
BigEndian -> a
val
whenBigEndian :: (a -> a) -> a -> a
whenBigEndian :: forall a. (a -> a) -> a -> a
whenBigEndian a -> a
fun a
val = case ByteOrder
hostByteOrder of
ByteOrder
LittleEndian -> a
val
ByteOrder
BigEndian -> a -> a
fun a
val