Twan van Laarhoven <twanvl <at> gmail.com> writes: > The solution is to use a dummy parameter: > > class IntegerType a where > > value :: a -> Integer > And call it like: > > f = value (undefined :: Two) > > So for instance: > > instance IntegerType d => Show (QF d) where > > show (QF a b) = show a ++ " + " ++ show b ++ " sqrt " > > ++ show (value (undefined::d))
Thanks to all respondents for this suggestion. That works great. > > The problem is that this doesn't work, because d is not in scope, you > need the scoped type variables extension: > > > valueOfQF :: forall a. IntegerType a => QF a -> Integer > > valueOfQF qf = value (undefined :: a) Well actually, your first attempt *did* work for me (using GHC 6.6.1). Is this not behaviour that I can rely on? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe