[Haskell] Mixing monadic and non-monadic functions

J. Garrett Morris trevion at gmail.com
Fri Sep 9 08:05:02 EDT 2005

On 9/9/05, Keean Schupke <k.schupke at imperial.ac.uk> wrote:
> Just noticed the 1+[1,2] case...  I am not certain whether this is
> possible - it is outside the
> scope of the formal definiton of Haskell and may rely on implementation
> details of the compiler/interpreter.

While this is outside the scope of the current Num class, if we adopt
the suggestion to redefine the standard classes using functional
dependencies (which is, I think, a useful addition to the standard
prelude anyway), we have, for example:

class Plus a b c | a b -> c
 where (+) :: a -> b -> c

instance (Plus a b c, Functor f) => a -> f b -> f c
 where a + fb = fmap (a +) fb

and so forth.  However, this doesn't generalize obviously (in any way
that I see) to generic two argument functions, which seemed to be what
Frederik wanted.


More information about the Haskell mailing list