[Haskell] Mixing monadic and non-monadic functions

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Fri Sep 9 06:37:44 EDT 2005


Wolfgang Jeltsch <wolfgang at jeltsch.net> 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]

Where the functions in question are not infix, you don't even need to
define a new name, just use (liftM fn) directly inline!

Regards,
  Malcolm


More information about the Haskell mailing list