Malcolm Wallace wrote:

Wolfgang Jeltsch <[EMAIL PROTECTED]> writes:

I'm not sure exactly what you have in mind. Obviously I want something
that applies to all functions, with any number of arguments, and not
just (+). Furthermore, it should handle cases like 1+[2,3] where only
one value is monadic.
I doubt that it is a good thing to extend the language in a way that such
far  reaching declarations are automatically generated.

I agree.  The original request was for something like
   [1,2] + [3,4]
to be automatically lifted into a monad.  But surely it is not too
difficult to define the required behaviour precisely (and only)
where needed, e.g.

   (+.) = liftM2 (+)

   [1,2] +. [3,4]

Why not make the monad an instance of Num, then you do not proliferate meaningless similar symbols... besides which I am sure all the good ones are used in libraries already
(like +. <+> etc) ;)

instance (Monad m, Show a) => Show (m a)
  ...
instance (Monad m, Ord a) => Ord (m a)
  ...
instance (Monad m, Num a,Show (m a),Ord (m a)) -> Num (m a) where
   (+) = liftM2 (+)

The instances for Show and Ord can be empty if you don't need the functionality...

   Regards,
   Keean.
_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to