runGetSimple: simply return the result value
commit4f98e98ea063368fd9d1c0e3aeecf1c4c589d045
authorLennart Kolmodin <kolmodin@gentoo.org>
dateThu 26 Aug 2010, 16:08 (16 years ago)
parent1467419
BitsGet.hs+8
@@ -9,6 +9,7 @@ module BitsGet
99 , readWord8
1010 , readWord16be
1111 , runBitGet
12+ , runBitGetSimple
1213 , BitGet
1314 , getBool
1415 , getWord8
@@ -219,6 +220,13 @@ instance Applicative BitGet where
219220 pure x = return x
220221 fm <*> m = fm >>= \f -> m >>= \v -> return (f v)
221222
223+runBitGetSimple :: BitGet a -> Get a
224+runBitGetSimple bg = do
225+ v <- runBitGet bg
226+ case v of
227+ Left err -> fail err
228+ Right v -> return v
229+
222230runBitGet :: BitGet a -> Get (Either String a)
223231runBitGet bg = do
224232 bs <- getS -- get the current chunk