Permalink
Browse files

Add instances: Functor, Applicative, MonadIO.

  • Loading branch information...
1 parent d9bbb1b commit 48dfd8bf9e458b193ef90fa6c188efcec56b7e7e @pcapriotti committed Apr 7, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 pipes-extra/Control/Pipe/PutbackPipe.hs
@@ -7,6 +7,7 @@ module Control.Pipe.PutbackPipe (
runPutback
) where
+import Control.Applicative
import Control.Monad
import Control.Monad.Trans
import qualified Control.Pipe as P
@@ -25,6 +26,16 @@ instance Monad m => Monad (PutbackPipe a b m) where
instance MonadTrans (PutbackPipe a b) where
lift = PutbackPipe . lift
+instance Monad m => Functor (PutbackPipe a b m) where
+ fmap f (PutbackPipe p) = PutbackPipe (liftM f p)
+
+instance Monad m => Applicative (PutbackPipe a b m) where
+ pure = return
+ (<*>) = ap
+
+instance MonadIO m => MonadIO (PutbackPipe a b m) where
+ liftIO a = PutbackPipe (liftIO a)
+
fromPipe :: Monad m => Pipe a b m r -> PutbackPipe a b m r
fromPipe p = PutbackPipe (joinP >+> p >+> P.pipe Left)

0 comments on commit 48dfd8b

Please sign in to comment.