summaryrefslogtreecommitdiff
path: root/KikiD/Message.hs
diff options
context:
space:
mode:
Diffstat (limited to 'KikiD/Message.hs')
-rw-r--r--KikiD/Message.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/KikiD/Message.hs b/KikiD/Message.hs
index cd3ee71..efefdc6 100644
--- a/KikiD/Message.hs
+++ b/KikiD/Message.hs
@@ -12,6 +12,7 @@ import Data.Bytes.Put as Put
12import Data.Bytes.Get as Get 12import Data.Bytes.Get as Get
13import Codec.LineReady 13import Codec.LineReady
14import Control.Monad.Loops 14import Control.Monad.Loops
15import Data.Word
15 16
16data KikiDMessage = TODO deriving (Show,Read) 17data KikiDMessage = TODO deriving (Show,Read)
17 18
@@ -31,7 +32,11 @@ instance Serialize KikiDMessage where
31instance Serial KikiDMessage where 32instance Serial KikiDMessage where
32 serialize m = Put.putByteString . toLineReady . Cereal.encode $ m 33 serialize m = Put.putByteString . toLineReady . Cereal.encode $ m
33 deserialize = do 34 deserialize = do
34 xs <- unfoldWhileM (/= '\n') (fmap (chr . fromIntegral) Get.getWord8) 35 xs <- unfoldM $ do
36 flag <- Get.isEmpty
37 if flag then return Nothing else do
38 c <- fmap (chr . fromIntegral) Get.getWord8
39 if (c == '\n') then return Nothing else return (Just c)
35 case (Cereal.decode . fromLineReady $ B.pack xs) of 40 case (Cereal.decode . fromLineReady $ B.pack xs) of
36 Left str -> fail str 41 Left str -> fail str
37 Right x -> return x 42 Right x -> return x