[Haskell-beginners] How does the Deriving being implemented in Haskell?
Jonas Almström Duregård
jonas.duregard at chalmers.se
Wed Jun 15 09:00:30 CEST 2011
Not sure exactly what you want to know, but in the language report it
says "For an enumeration, the first and last constructors listed in
the data declaration are the bounds".
On 14 June 2011 14:07, Haisheng Wu <freizl at gmail.com> 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 |
> deriving (Bounded, Enum)
> Therefore, minBound :: Day will produce Monday.
> Just be curious how it is being implemented.
> Beginners mailing list
> Beginners at haskell.org
More information about the Beginners