[Haskell-cafe] Is it possible to represent such polymorphism?
Victor Gorokgov
me at rkit.pp.ru
Sun Oct 2 19:07:07 CEST 2011
02.10.2011 19:55, David Barbour пишет:
> Use TypeFamilies.
>
>
> {-# LANGUAGE TypeFamilies #}
> ...
> type family FType a :: *
> type instance FType Char = Float
> type instance FType Double = Int
>
> class ExampleClass a where
> f :: a -> FType a
>
Better to include type in class.
class ExampleClass a where
type FType a
f :: a -> FType a
instance ExampleClass Char where
type FType Char = Float
f char = ...
More information about the Haskell-Cafe
mailing list