1 {-# LANGUAGE TypeFamilies, StandaloneDeriving, FlexibleInstances, FlexibleContexts, UndecidableInstances #-}
2 -- | This module declares some commonly used functions and instances.
12 import Data.Binary.Put
13 import qualified Data.ByteString.Lazy as B
14 import qualified Data.Map as M
19 instance Default B.ByteString where
22 instance Default Word16 where
25 toCharList :: B.ByteString -> [Int]
26 toCharList bstr = map fromIntegral $ B.unpack bstr
28 poolSize :: Pool stage -> Int
31 (!) :: (Ord k) => M.Map k a -> k -> a
34 showListIx :: (Show a) => [a] -> String
35 showListIx list = unlines $ zipWith s [1..] list
36 where s i x = show i ++ ":\t" ++ show x
38 byteString :: (Binary t) => t -> B.ByteString
39 byteString x = runPut (put x)