On 30/01/2011 19:43, Henning Thielemann wrote:
> 
> I do not see a constant 1 that is equated with a type.
> 
This is due to my misunderstanding of Haskell.
After your comments my understanding of the  unit function is as follows:

1) In the instance below the argument for unit must have type
LengthInMetres

>> instance MetricDescription LengthInMetres Metre where
>>>  valueInUnit (LengthInMetres d) = d
>>>  unit l = Metre


2) The constant 1 on the LHS can be replaced _ because it is the fact
that unit is defined in this instance the determines the return value.

3) The RHS is not a type but a constructor.

4) The compiler ensures the correct unit function is called for either
MetricDescription instances.


Thanks for your help,
Pat

This message has been scanned for content and viruses by the DIT Information 
Services E-Mail Scanning Service, and is believed to be clean. http://www.dit.ie

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to