[Haskell-cafe] Trouble with types

Kari Pahula kari at sammakko.yok.utu.fi
Fri Jul 23 12:18:28 EDT 2004

I'm new to Haskell, as you can probably tell...

I have the following data types:

data Real a => Energy a = Energy a deriving (Eq, Ord, Show)

data Real a => HeatC a = HeatC a deriving (Eq, Ord, Show)

data Object h c = Object {energy :: (Energy h), heatc :: (HeatC c)} deriving (Eq, Show)

data Real a => Temp a = Temp a deriving (Eq, Ord, Show)

I'd like to make a function to calculate the temperature of an object.
Physically this is the total heat times the heat capacity.

I tried this with the following:

temp :: (Real a) => Object (Energy a) (HeatC a) -> Temp a
temp Object (Energy e) (HeatC c) = Temp e*c

But this fails in hugs with:
ERROR "temp.hs":22 - Constructor "Object" must have exactly 2 arguments in pattern

What's the syntax to use here?  Should I do this in some other way?
Should I use newtype here instead of data?

More information about the Haskell-Cafe mailing list