On Friday 22 October 2010 6:37:49 am Max Bolingbroke wrote:
> This is all well and good, but it means when working with data types
> defined in this manner you have to write Roll and unroll everywhere.
> This is tedious :-(

Your discovery is interesting (and I haven't seen it before).

Another solution, though, is SHE. With it, you can write:

  data ListF a r = NilF | ConsF a r
  newtype List a = Roll (ListF a (List a))

  pattern Nil       = Roll NilF
  pattern Cons x xs = Roll (ConsF x xs)

And not worry about Rolls anymore.

-- Dan

http://personal.cis.strath.ac.uk/~conor/pub/she/
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to