[Haskell] Mixing monadic and non-monadic functions

Keean Schupke k.schupke at imperial.ac.uk
Fri Sep 9 07:54:58 EDT 2005

Keean Schupke wrote:

>>>> 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.
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.

Effectivly we need to redefine list as a class, then (Num a) can be made 
an instance of the class... See my implementation of Joy in the HList 
library. (this lifts numbers into an AST rather than a list) - this 
however uses type level programming and has problems with non static 
types (IE you need to use existentials for lists who's values is not 
known at compile time)...

The easy answer is to define a type that contains both singletons and 
lists... although the type constructors may not look as neat.


More information about the Haskell mailing list