Survival of generic-classes in ghc
Simon Peyton-Jones
simonpj@microsoft.com
Mon, 25 Feb 2002 00:27:08 -0800
| > Another possiblity would be to make the ConCls class look like this
| > class ConCls c where
| > name :: String
| > arity :: Int=20
| > ...etc...
| >=20
| > Now we'd have to give an explicit type argument at the call site:
| >=20
| > show {| Constr c t |} (Con x) =3D (name {| c |}) ++ show x
| >=20
| > I quite like the thought of being able to supply explicit type=20
| > arguments.... but I don't konw how to speak about the order of type=20
| > parameters. What order does map takes its two type parameters in?
|=20
| Sorry, this seems like a non-sequitur to me?
|=20
| 'map' has type '(a->b) -> [a] -> [b]'; supplying explicit=20
| type parameters would mean giving values to 'a' and 'b'. If=20
| I wanted to propose notation for this, I would suggest, e.g.,
| (map :: (String -> Int) -> [String] -> [Int]) length=20
| ["Hello", "World"]
|=20
| 'name' (above) has type 'String'; the '{| c |}' is not=20
| providing a type parameter in the same sense.
Yes it is. 'name' would have type
forall c. ConCls c =3D> String
It requires a type argument, just like map.
Simon