module Hans.Utils where
import Control.Monad (MonadPlus(mzero))
import Numeric (showHex)
import qualified Data.ByteString.Lazy as L
import qualified Data.ByteString as S
type DeviceName = String
type MkPseudoHeader = Int -> S.ByteString
type Endo a = a -> a
void :: Monad m => m a -> m ()
void m = m >> return ()
showPaddedHex :: (Integral a, Show a) => a -> ShowS
showPaddedHex x
| x < 0x10 = showChar '0' . base
| otherwise = base
where base = showHex x
just :: MonadPlus m => Maybe a -> m a
just = maybe mzero return
singleton :: a -> [a]
singleton x = [x]
chunk :: S.ByteString -> L.ByteString
chunk bs = L.fromChunks [bs]
strict :: L.ByteString -> S.ByteString
strict = S.concat . L.toChunks