[Haskell-cafe] Re: Generic types

Cale Gibbard cgibbard at gmail.com
Tue Jun 14 04:15:12 EDT 2005


For extra fun, notice that you can make declarations like:

data (Unit u) => Kilo u = Kilo u

instance (Unit u) => Unit (Kilo u) where
    shortName (Kilo u) = "k" ++ shortName u

which behaves in ghci like:
*Main> UnitValue (Kilo Meter) 30
30km

 - Cale


More information about the Haskell-Cafe mailing list