[Haskell-cafe] Re: Why is $ right associative instead ofleftassociative?

Jan-Willem Maessen jmaessen at alum.mit.edu
Wed Feb 8 08:15:19 EST 2006


On Feb 8, 2006, at 1:34 AM, Stefan Monnier wrote:

>> The trouble with monad comprehensions was that it became far too  
>> easy to
>> write ambiguous programs, even when you thought you were just  
>> working with
>> lists.
>
> One solution was already suggested: to make the comprehension  
> syntax be pure
> syntactic sugar whose semantics depends on the semantics of the  
> identifiers
> the syntactic sugar expands into.

OK.  Which identifiers?  I happen to want a version which always uses  
"concatMap" (or, equivalently, monadic bind), and never, ever the  
direct "efficient" translation.  To get the efficient translation for  
lists a la Wadler, though, this requires either a wrapper, so that  
the comprehension runs at the type ([a] -> [a]) and gets applied to  
[] at the very end, or it requires heavy lifting from the compiler  
(foldr/build and its kin as seen in GHC, phc, etc.).

When it was all tied to lists, it was easy to gloss over the details  
of the machinery.

-Jan-Willem Maessen

> So you could keep the current list-only comprehension as default,  
> and allow
> monad comprehension by providing a library (which the users need to  
> import
> so as to hide the Prelude's definition).
>
>
>         Stefan
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list