blob: 8af5dc6a3c8d648686f0c15abb8cbd7eba05f7a3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
module KikiD.GetLine where
import Control.Monad
import Data.Serialize
import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as L
import Data.Monoid
import Data.Binary.Builder
getLine :: Get BS.ByteString
getLine = getWords empty
where
getWords b = do
w <- getWord8
let x = singleton w
if (w == 10 || w == 0)
then return $ BS.concat . L.toChunks . toLazyByteString $ b <> x
else getWords (b <> x)
|