Add Applicative instances for instances of Monad
Ignore-this: a95ef4a320b4c1506f5352716a656385 darcs-hash:20150116211446-5ff09-fca82019a01b124f7c93efe6f25ff73d1abfa665
This commit is contained in:
parent
f679a9eb63
commit
e5e64a794f
@ -80,6 +80,13 @@ instance ByteSink PutM where
|
|||||||
|
|
||||||
newtype PutME a = PutME (Either EncodingException (PutM (),a))
|
newtype PutME a = PutME (Either EncodingException (PutM (),a))
|
||||||
|
|
||||||
|
instance Functor PutME where
|
||||||
|
fmap = liftM
|
||||||
|
|
||||||
|
instance Applicative PutME where
|
||||||
|
pure = return
|
||||||
|
(<*>) = ap
|
||||||
|
|
||||||
instance Monad PutME where
|
instance Monad PutME where
|
||||||
return x = PutME $ Right (return (),x)
|
return x = PutME $ Right (return (),x)
|
||||||
(PutME x) >>= g = PutME $ do
|
(PutME x) >>= g = PutME $ do
|
||||||
@ -114,6 +121,13 @@ instance (Monad m,Throws EncodingException m) => ByteSink (StateT (Seq Char) m)
|
|||||||
|
|
||||||
newtype StrictSink a = StrictS (Ptr Word8 -> Int -> Int -> IO (a,Ptr Word8,Int,Int))
|
newtype StrictSink a = StrictS (Ptr Word8 -> Int -> Int -> IO (a,Ptr Word8,Int,Int))
|
||||||
|
|
||||||
|
instance Functor StrictSink where
|
||||||
|
fmap = liftM
|
||||||
|
|
||||||
|
instance Applicative StrictSink where
|
||||||
|
pure = return
|
||||||
|
(<*>) = ap
|
||||||
|
|
||||||
instance Monad StrictSink where
|
instance Monad StrictSink where
|
||||||
return x = StrictS $ \cstr pos max -> return (x,cstr,pos,max)
|
return x = StrictS $ \cstr pos max -> return (x,cstr,pos,max)
|
||||||
(StrictS f) >>= g = StrictS (\cstr pos max -> do
|
(StrictS f) >>= g = StrictS (\cstr pos max -> do
|
||||||
@ -140,6 +154,13 @@ instance ByteSink StrictSink where
|
|||||||
|
|
||||||
newtype StrictSinkE a = StrictSinkE (StrictSink (Either EncodingException a))
|
newtype StrictSinkE a = StrictSinkE (StrictSink (Either EncodingException a))
|
||||||
|
|
||||||
|
instance Functor StrictSinkE where
|
||||||
|
fmap = liftM
|
||||||
|
|
||||||
|
instance Applicative StrictSinkE where
|
||||||
|
pure = return
|
||||||
|
(<*>) = ap
|
||||||
|
|
||||||
instance Monad StrictSinkE where
|
instance Monad StrictSinkE where
|
||||||
return = StrictSinkE . return . Right
|
return = StrictSinkE . return . Right
|
||||||
(StrictSinkE s) >>= g = StrictSinkE $ do
|
(StrictSinkE s) >>= g = StrictSinkE $ do
|
||||||
@ -167,6 +188,13 @@ createStrict sink = createStrictWithLen sink 32
|
|||||||
|
|
||||||
newtype StrictSinkExplicit a = StrictSinkExplicit (StrictSink (Either EncodingException a))
|
newtype StrictSinkExplicit a = StrictSinkExplicit (StrictSink (Either EncodingException a))
|
||||||
|
|
||||||
|
instance Functor StrictSinkExplicit where
|
||||||
|
fmap = liftM
|
||||||
|
|
||||||
|
instance Applicative StrictSinkExplicit where
|
||||||
|
pure = return
|
||||||
|
(<*>) = ap
|
||||||
|
|
||||||
instance Monad StrictSinkExplicit where
|
instance Monad StrictSinkExplicit where
|
||||||
return = (StrictSinkExplicit).return.Right
|
return = (StrictSinkExplicit).return.Right
|
||||||
(StrictSinkExplicit sink) >>= f
|
(StrictSinkExplicit sink) >>= f
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
Name: encoding
|
Name: encoding
|
||||||
Version: 0.7.0.2
|
Version: 0.7.0.3
|
||||||
Author: Henning Günther
|
Author: Henning Günther
|
||||||
Maintainer: daniel@wagner-home.com
|
Maintainer: daniel@wagner-home.com
|
||||||
License: BSD3
|
License: BSD3
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user