[Haskell-cafe] Instantiation problem
patrick.browne at dit.ie
Sun Jan 30 23:22:16 CET 2011
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
>> 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
Thanks for your help,
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
More information about the Haskell-Cafe