bytable 0.0.0.1 → 0.0.0.2
raw patch · 2 files changed
+18/−3 lines, 2 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Codec.Bytable: instance Bytable ByteString
+ Codec.Bytable: list :: Int -> BytableM b -> BytableM [b]
Files
- bytable.cabal +2/−2
- src/Codec/Bytable.hs +16/−1
bytable.cabal view
@@ -2,7 +2,7 @@ build-type: Simple name: bytable-version: 0.0.0.1+version: 0.0.0.2 stability: Experimental author: Yoshikuni Jujo <PAF01143@nifty.ne.jp> maintainer: Yoshikuni Jujo <PAF01143@nifty.ne.jp>@@ -28,7 +28,7 @@ source-repository this type: git location: git://github.com/YoshikuniJujo/forest- tag: bytable-0.0.0.1+ tag: bytable-0.0.0.2 library hs-source-dirs: src
src/Codec/Bytable.hs view
@@ -3,7 +3,7 @@ module Codec.Bytable ( Bytable(..), BytableM(..), evalBytableM, execBytableM,- head, take, null+ head, take, null, list, ) where import Prelude hiding (take, head, null)@@ -39,6 +39,10 @@ fromByteString :: BS.ByteString -> Either String b toByteString :: b -> BS.ByteString +instance Bytable BS.ByteString where+ fromByteString = Right+ toByteString = id+ head :: BytableM Word8 head = BytableM $ \bs -> case BS.uncons bs of Just (h, t) -> Right (h, t)@@ -53,3 +57,14 @@ null :: BytableM Bool null = BytableM $ \bs -> Right (BS.null bs, bs)++list :: Int -> BytableM b -> BytableM [b]+list n m = do+ bs <- take n+ case evalBytableM lst bs of+ Right xs -> return xs+ Left msg -> fail msg+ where+ lst = do+ e <- null+ if e then return [] else (:) <$> m <*> lst