Re: Bringing back Monad Comprehensions (in style)

2010-10-07 Thread Max Bolingbroke
On 7 October 2010 12:04, Sebastiaan Visser hask...@fvisser.nl wrote:
 What exactly are the benefits of Monad comprehensions over, for example, the 
 do-notation or idioms?

List comprehensions are just a specialisation of the do-notation for lists.
Monad comprehensions are a generalisation for arbitrary monads of this
specialisation :-)

I don't think there are major benefits to this. The major change is
that they look like lists (which might be important if you are
writing a SQL library) and the final return is hoisted into the head
of the comprehension [HERE | with, the, usual, do, notation, sequence,
here].

 I'm not fully aware of what Monad comprehensions would offer in general, but 
 aren't most comprehensions directly translatable to applicative style?

Monadic style, not applicative style.

 For example:

  [(x, y) | x - xs | y - ys]  -- Comprehension.

This computes a zip of xs and ys.

  (,) $ xs * ys             -- Applicative style.

This actually computes a cartesian product instead.

You are right in spirit because:

  [e | qs] == do { qs; return e }

For example:

  [(x, y) | x - xs, y - ys] == do { x - xs; y - ys; return (x, y) }

Cheers,
Max
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Bringing back Monad Comprehensions (in style)

2010-10-07 Thread George Giorgidze
Hi Sebastian,

 For example:
 
  [(x, y) | x - xs | y - ys]  -- Comprehension.
 
versus
 
  (,) $ xs * ys -- Applicative style.
 
or
 
  (| (,) xs ys |)   -- Idiom brackets in She.
 
 Or am I missing some subtle points here?

Perhaps, you meant [(x, y) | x - xs , y - ys] which translates to the
following code in the do notation:

do x - xs
  y - ys
 return (x,y)

The comprehension notation also features filters.

[(x, y) | x - xs , y - ys, x == y] which for instances of MonadPlus (i.e.,
not for all monads) translates to:

do x - xs
  y - ys
 guard (x == y)
 return (x,y)

See Michael Adams' (link is in Max's reply) suggestion on how to translate
'order by' and 'group by' to monadic combinators. There, monadic code gets
really unwieldy.

The point of the comprehension notation is that (just like of any other
notation, including do) it makes certain kinds of programs easier to write and
read. As I have already mentioned, the comprehension notation is extremely
well suited for writing programs that process collections of values. Maybe
this is because the set comprehension notation was hardwired in our brains
during high school math.

Haskell is widely used for EDSL development. Some EDSLs are about processing
collections of values. Monad comprehensions would allow EDSLs to utilise the
expressive list comprehension notation that is currently only allowed for
lists.

Having said that, since the comprehension notation (to some extent) is used in
high school math curricula, even a bit mathematically inclined non-computer
scientist users of list-based EDSLs may feel at home when offered to program
using the comprehension notation.

To summarise, IMO programming list-processing applications is more natural in
the comprehension notation than in do notation and programming with 'group by'
and 'order by' is infeasible in monadic combinators.

Of course one could extend do notation further, but I think it is better for
the reasons outlined above to generalise the list comprehension notation
instead.

Of course, I still welcome alternative suggestions.

Cheers, George

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


GHC static binaries with glibc-2.12?

2010-10-07 Thread Alexander Dunlap
Hi all,

I recently upgraded my Arch Linux system to glibc 2.12 and static
binaries compiled with GHC 6.12.3 all fail with the message
mkTextEncoding: invalid argument (Invalid argument). This did not
happen with glibc 2.11. Has anyone else had this problem? Does anyone
have any advice for debugging it?

Thanks,
Alex
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users