[Haskell-beginners] How does the Deriving being implemented in Haskell?

David Place d at vidplace.com
Tue Jun 14 15:18:10 CEST 2011


Hi, Simon.

You should look at the Data.Derive module to see how to create your own instances.

> http://hackage.haskell.org/package/derive

Cheers,
David
____________________
David Place   
Owner, Panpipes Ho! LLC
http://panpipesho.com
d at vidplace.com



On Jun 14, 2011, at 8:07 AM, Haisheng Wu wrote:

> Hi guys,
>   What I understanding `deriving` is Haskell automatically make a type to be a instance of a particular typeclass.
>   If that's the case, the question is How does Haskell do that underline?
> 
>   Take code below as sample, the type Day is now an instance of Bounded.
> 
>  data Day = Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday
>             deriving (Bounded, Enum)
> 
>   Therefore, minBound :: Day will produce Monday.
> 
>  Just be curious how it is being implemented.
> 
> Thanks.
> Simon
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110614/365da237/attachment.htm>


More information about the Beginners mailing list