Re: [Haskell-cafe] Monad for Set?

2007-08-07 Thread Vitaliy Akimov
If you also read the rest of that thread, you'll see that with a recent GHC HEAD, you should be able to avoid the need for the Teq witness. http://www.cs.chalmers.se/~rjmh/Papers/restricted-datatypes.ps here is solution which doesn't require GADT and HEAD, but it does require changing of

[Haskell-cafe] Monad for Set?

2007-08-06 Thread Ronald Guida
Hi, I'm pondering, is it possible to define a Set monad analogous to the List monad? My thinking is as follows: * fmap f x would apply f to each element in a set x * return x would create a singleton set {x} * join x, where x is a set of sets: x = {x1, x2, ... xn}, would form

Re: [Haskell-cafe] Monad for Set?

2007-08-06 Thread Matthew Brecknell
Ronald Guida: I'm pondering, is it possible to define a Set monad analogous to the List monad? [snip] This leads me think of a different solution: What if I could define a Set monad that's smart enough to know, for any type a, whether or not (Eq a) holds, and degenerate to a blind list if