[Haskell] Type synonyms in the instance head
mads_lindstroem at yahoo.dk
Thu Feb 2 15:48:27 EST 2006
In this url
one can read about "Type synonyms in the instance head". A quote:
"You cannot, for example, write:
type P a = [[a]]
instance Monad P where ...
This design decision is independent of all the others, and easily
reversed, but it makes sense to me."
It does not make sense to me! Could anybody explain why this makes
Below, I will try to explain why it does not make sense to me.
If I have:
data LongAndUglyName a = ...
type ShortAndTellingName a = LongAndUglyName a
It seems to make sensible to:
instance Foo ShortAndTellingName
Also it is called a type _synonym_ and the type synonym and what it is
synonym for, should therefore be interchangeable.
This restriction do not only apply to instance heads, but also to
contexts, as in:
instance (Foo LongAndUgleName) => class something ...
Here again LongAndUglyName cannot be replaced by ShortAndTellingName.
This can be annoying if you have a lot of these instance declarations.
Also what the type synonym is synonym for, may not have any name and
thus properly not be telling at all, as in:
type TellingName a = \a -> String
More information about the Haskell