[Haskell] Re: Mixing monadic and non-monadic functions

Aaron Denney wnoise at ofb.net
Fri Sep 9 14:17:48 EDT 2005


On 2005-09-09, Keean Schupke <k.schupke at imperial.ac.uk> wrote:
> 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.

I thought the easy answer would be to inject non-monadic values into the
monad (assuming one already rejiggered things to do automatic lifting).

-- 
Aaron Denney
-><-



More information about the Haskell mailing list