{-# OPTIONS -fglasgow-exts #-} module Esotericbot.BSUtils where import Prelude as P import qualified System.IO as IO import Data.Char import Data.ByteString.Lazy.Char8 as BS import Data.ByteString.Unsafe import Data.Word import Data.Attoparsec import Data.List.Stream as L choices = L.foldl1 ( \ mkp p -> try p <|> mkp ) space = choices $ L.map word8 space_word8s space_word8s = [ 32 , 10 , 9 , 13 ] ls2bs s bs = do unsafePackAddressLen s bs >>= return . fromChunks . flip (:) [ ] s2bs = BS.pack bs2s = BS.unpack digit = choices $ L.map word8 [ 48 .. 57 ] spaces = many space