
Kari, Others have not mentioned the change required in the type signature yet. < temp :: (Real a) => Object (Energy a) (HeatC a) -> Temp a < temp Object (Energy e) (HeatC c) = Temp e*c
temp :: forall a . (Real a) => Object a a -> Temp a temp (Object (Energy e) (HeatC c)) = Temp (e * c)
HTH, Stefan
data (Real a) => Energy a = Energy a deriving (Eq, Ord, Show) data (Real a) => HeatC a = HeatC a deriving (Eq, Ord, Show) data (Real a) => Temp a = Temp a deriving (Eq, Ord, Show)
data Object h c = Object { energy :: Energy h, heatc :: HeatC c } deriving (Eq, Show)
main = let obj = Object { energy = Energy 2.5 , heatc = HeatC 12.0 } in print (temp obj) -- prints "Temp 30.0"