Make it possible to evaluate monadic actions when assigning record fields

apfelmus apfelmus at quantentunnel.de
Wed Jul 11 06:13:28 EDT 2007


Wouter Swierstra wrote:
> 
> On 11 Jul 2007, at 08:38, Simon Peyton-Jones wrote:
> 
>> Another alternative (which I got from Greg Morrisett) that I'm toying
>> with is this.  It's tiresome to write
>>
>>         do { x <- <stuff1>
>>            ; y <- <sutff2>
>>            ; f x y }
>>
>> In ML I'd write simply
>>
>>         f <stuff1> <stuff2>
> 
> Using Control.Applicative you could already write:
> 
> f <$> x <*> y

No, since f is not a pure function, it's f :: x -> y -> m c. The correct
form would be

  join $ f <$> x <*> y

(Why doesn't haddock document infix precedences?) But maybe some
type-class hackery can be used to eliminate the join.

In any case, I'm *strongly against* further syntactic sugar for monads,
including #1518. The more tiresome monads are, the more incentive you
have to avoid them.

Regards,
apfelmus



More information about the Haskell-prime mailing list