[Haskell-beginners] accessor function scope
bieffe62 at gmail.com
Tue Apr 7 04:03:50 EDT 2009
2009/4/7 Michael Mossey <mpm at alumni.caltech.edu>
> I'm coming from the OO world and trying to adapt.
me too :-)
> For that matter, I don't know what the term is for a "StaffItem-type
> LayoutItem". The type is clearly LayoutItem. "StaffItem" is the constructor.
> How do you refer to the concept of a LayoutItem constructed via a StaffItem?
> Again, StaffItem and TextItem resemble derived classes in OO.
To me, they are more close to C union : a data type than can alternatively
have different structures,
In your example, LayoutItem is a type name, while StaffItem and TextItem are
constructor, that is functions.
Saying that a function specializes a type is a bit of a stretch, I think ...
Nevertheless, they can sometime be used to accomplish the same goal : where
in OO you define an abstact class and then
specialize with concrete classes to model a classification, in haskell you
can define a data type with alternate constructors.
I think that data types with alternate constructores are called algebraic
data types in haskellese, but I'm not sure of that ...
> Any clarification welcome.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners