[Haskell-cafe] monad subexpressions

Jules Bean jules at jellybean.co.uk
Fri Aug 3 04:06:41 EDT 2007


Neil Mitchell wrote:
> Hi Chris,
> 
>> I've heard Simon (Peyton-Jones) twice now mention the desire to be able
>> to embed a monadic subexpression into a monad.
> 
> I think this is a fantastic idea, please do so!
> 
>>     $( expr   )   -- conflicts with template haskell
>>     ( <- expr )   -- makes sense, and I think it's unambiguous
>>
>> Other ideas:
>>
>>     ``expr``      -- back-ticks make sense for UNIX shell scripters
>>     (| expr |)    -- I don't think anything uses this yet
> 
> This final (| one |) looks way too much like template haskell, it has
> the feel of template haskell, even if it isn't yet in the syntax. Your
> (<- proposal) feels a bit like an operator section - I'm not sure if
> that is a good thing or a bad thing, but for some reason feels
> slightly clunky and high-syntax overhead, perhaps because of the
> inevitable space between the <- and expr, and that ()<- are all fairly
> high semantic value currently in Haskell, while this extension should
> blend in, rather than stand out. 

I'm not sure I agree with Neil's misgivings. Certainly <- already has a 
high semantic value, but this is a very closely related notion, so I see 
that as consistent.

As for the (), well as far as I know they only have two meanings: 
grouping and tupling. This seems like a special case of grouping to me.

E.g.:

do
   a <- m
   b <- n
   l a x b y

becomes

l (<- m) x (<- n) y

...with, I suppose, left-to-right evaluation order. This looks 'almost 
like substitution' which is the goal.

Jules



More information about the Haskell-Cafe mailing list