diff options
Diffstat (limited to 'KikiD/GetLine.hs')
-rw-r--r-- | KikiD/GetLine.hs | 18 |
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 @@ | |||
1 | module KikiD.GetLine where | ||
2 | |||
3 | import Control.Monad | ||
4 | import Data.Serialize | ||
5 | import qualified Data.ByteString as BS | ||
6 | import qualified Data.ByteString.Lazy as L | ||
7 | import Data.Monoid | ||
8 | import Data.Binary.Builder | ||
9 | |||
10 | getLine :: Get BS.ByteString | ||
11 | getLine = 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) | ||