summaryrefslogtreecommitdiff
path: root/KikiD/GetLine.hs
diff options
context:
space:
mode:
Diffstat (limited to 'KikiD/GetLine.hs')
-rw-r--r--KikiD/GetLine.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/KikiD/GetLine.hs b/KikiD/GetLine.hs
new file mode 100644
index 0000000..8af5dc6
--- /dev/null
+++ b/KikiD/GetLine.hs
@@ -0,0 +1,18 @@
1module KikiD.GetLine where
2
3import Control.Monad
4import Data.Serialize
5import qualified Data.ByteString as BS
6import qualified Data.ByteString.Lazy as L
7import Data.Monoid
8import Data.Binary.Builder
9
10getLine :: Get BS.ByteString
11getLine = getWords empty
12 where
13 getWords b = do
14 w <- getWord8
15 let x = singleton w
16 if (w == 10 || w == 0)
17 then return $ BS.concat . L.toChunks . toLazyByteString $ b <> x
18 else getWords (b <> x)