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

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to