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! Thanks. On Sep 8, 2:36 pm, Kevin Jardine <kevinjard...@gmail.com> wrote:
Hi Tony and James,
I'm having trouble constructing the ToObj instance.
The obvious code:
toObj (w o) = o
fails with a syntax error.
How do I unwrap the value?
Kevin
On Sep 8, 2:30 pm, James Andrew Cook <mo...@deepbondi.net> wrote:
On Sep 8, 2010, at 8:19 AM, Kevin Jardine wrote:
Hi Tony,
I stared at that specific section for at least half an hour earlier today but could not figure out how it applied in my specific case. The only examples I have see are for deriving Num. Do you have any more detail on how I could use that extension?
Kevin
On Sep 8, 2:05 pm, Tony Morris <tonymor...@gmail.com> wrote:
I think you might want -XGeneralizedNewtypeDeriving
http://haskell.org/ghc/docs/6.12.2/html/users_guide/deriving.html#id6...
On 08/09/10 22:01, Kevin Jardine wrote:
I'm not sure if it's what he originally had in mind, but if your Obj class has a ToObj instance (which would be reasonable), then that extension allows your other classes to derive it:
newtype Foo = Foo Obj deriving ToObj
-- James_______________________________________________ Haskell-Cafe mailing list Haskell-C...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-C...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe