[Haskell-cafe] Monadic vs "pure" style
Jacques Carette
carette at mcmaster.ca
Thu Sep 1 10:55:43 EDT 2005
Bulat Ziganshin wrote:
>Language.Haskell.TH.Lib is full of definitions like this:
>
>infixP p1 n p2 = do p1' <- p1
> p2' <- p2
> return (InfixP p1' n p2')
>
>btw, such definitions can be simplified by using liftM/ap operations:
>
>instance (Monad m, MyNum v) => MyNum (m v) where
> (.+) = liftM2 (.+)
>
>
Such simplified forms then occur often enough that, in a scrapping
boilerplate kind of way, I would really like to be able to write
something like
instance (Monad m, MyNum v) => MyNum (m v) via lifting
or
lifted instance (Monad m, MyNum v) => MyNum (m v)
or
derived instance (Monad m, MyNum v) => MyNum (m v)
where all the operations from MyNum are obtained via applying the correct arity liftM function from the Monad class.
Jacques
More information about the Haskell-Cafe
mailing list