Colleagues! The essence of trouble may be given by code:
[haskell] module TypeTrouble where class FirstClass a where firstFunction :: (SecondClass b) => a -> b class SecondClass a where secondFunction :: a -> Double data FirstData = FirstData Double data SecondData = SecondData Double instance SecondClass SecondData where secondFunction (SecondData d) = d instance FirstClass FirstData where firstFunction (FirstData d) = SecondData d [/haskell] I need, the firstFunction of FirstClass types to return a value of a SecondClass type. For example SecondData for FirstData, but for some FirstClass ThirdData, some SecondClass FourthData, etc. GHC 6.8.1 produces an error: [quote] typetrouble.hs:17:31: Couldn't match expected type `b' against inferred type `SecondData' `b' is a rigid type variable bound by the type signature for `firstFunction' at typetrouble.hs:4:31 In the expression: SecondData d In the definition of `firstFunction': firstFunction (FirstData d) = SecondData d In the definition for method `firstFunction' [/quote] How can I make this idea work? -- With best regards, Konstantin _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe