[Haskell-cafe] ReRe: Basic question concerning data constructors

Jake McArthur jake.mcarthur at gmail.com
Sun Dec 30 17:21:45 EST 2007

On Dec 30, 2007, at 12:32 PM, Joost Behrends wrote:

> Thanks to both fast answers.
> there remain problems with Jakes mail for me. This:
>> When you define datatypes, you are essentially defining a type-level
>> constructors on the left hand side and (value-level) constructors on
>> the right hand side.
> is very useful for me. "data" defines TWO constructors, ok.

To be more accurate, it defines one type constructor and however many  
value constructors you want to define.

> Then i arrive at
>> . Now, let's say we had tried defining ClockTime with parameters as
>> you suggested.
>>      ClockTime' :: Integer -> Integer -> *
>> Do you see the problem? In order to use the ClockTime type
>> constructor, we would have to use Integer values.
> Cannot see any problem here - do we NOT want ClockTime to be  
> initialized by two
> Integers ? Or is this the main reason for introducing "TOD" - to be  
> able to
> change it without having to make any changes to code using ClockTime ?
> To repeat myself - am i right understanding, that this needs a  
> differently named
> data constuctor ?

No, we do not want the _type_ to be parameterized with our _values_.  
That is the difference between ClockTime and TOD; ClockTime is on the  
type level and TOD is on the value level. ClockTime is the type of the  
value returned by TOD after applying it to two Integer values.

- Jake

More information about the Haskell-Cafe mailing list