[Haskell-beginners] ODP: howto Pipe

Marcin Mrotek marcin.jan.mrotek at gmail.com
Thu Feb 18 17:12:07 UTC 2016


I mean literally use the function `lift`. Proxy (it's the underlying
type of all pipes, Pipe is a type synonym that expands to Proxy,
filling some type variables for you) implements the MonadTrans class
(from http://hackage.haskell.org/package/transformers-0.5.1.0/docs/Control-Monad-Trans-Class.html):

class MonadTrans t where
   lift :: Monad m => m a -> t m a

So, if `t` is `Pipe a b` and `m` is IO, then `lift` becomes:

lift :: IO r -> Pipe a b IO r

Thus, for example, `lift (c_hkl_engine_list_init engines geometry
detector sample)` will return `Pipe a b IO <something>` (for any `a`
and `b`, this is going to be a trivial pipe that doesn't yield or
await anything, and just executes the effect) rather than `IO
<something>`.

You don't need to import the Monad.Trans.Class module, Pipe reexports
it for you.

Best regards,
Marcin Mrotek


More information about the Beginners mailing list