[Haskell-cafe] Re: Unwrapping newtypes
kevinjardine at gmail.com
Wed Sep 8 08:36:58 EDT 2010
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?
On Sep 8, 2:30 pm, James Andrew Cook <mo... at 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... at gmail.com> wrote:
> >> I think you might want -XGeneralizedNewtypeDeriving
> >> 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... at haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe