On Wed, 8 Sep 2010 05:51:22 -0700 (PDT), Kevin Jardine
<kevinjard...@gmail.com> wrote:
> Ah, I was missing an important piece of the puzzle.
> 
> If I write:
> 
> class ToObj a where
>     toObj :: a -> Obj
> 
> instance ToObj Obj where
>     toObj a = a
> 
> then
> 
> newtype Blog = Blog Obj deriving ToObj
> 
> works!

This post
<http://www.haskell.org/pipermail/libraries/2006-October/005950.html>
describes a general mini-library for this situation (having a
structure-indicating newtype of an underlying type). The 'Unpack' class
is a generalised version of your 'ToObj' class. Maybe it is useful to
compare (or even use), especially the smart ways in which you can use
this class to hide much of the wrapping/unwrapping.


Regards,

Arie

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to