[Haskell-cafe] Adding Ord constraint to instance Monad Set?

MR K P SCHUPKE k.schupke at imperial.ac.uk
Wed Mar 31 15:43:48 EST 2004


>My intention was that the context before a data constructor shall mean that
>the variable (a) shall be constrained only in the type of the constructor
>function, not in the type definition.

Okay, functional laguages have the notion that binding a variable is true
for all time (like in mathematics)... Therefore if "a" is "1" then it has
type Integer - forever. In this case the type of a in the first definition
is "forall a . Num a". This is true for all references to a where we mean the 
same a. Because a is on the left-hand-side of the equals we assume all a's on
the right are the same (it is the only rational choise) and hence we
end up with two different types for a single variable. you could say something
like (this doesn't work by the way)

	data Either a =
		(forall a . Num a => Left a)
		(forall a . Ord a => Right a) 

But here the a in each set of brackets has nothing to do with the a on the 
left hand side. This is different from:

	(data Either a = Num a => Left a | Ord a => Right a) 

where it is clear a == a but Ord a /= Num a

Doing anything different would break the scoping rules for variables, and
it is much more important IMHO to keep these consistant. Good languages
are: Consistant, Symmetric, and Complete.

	Regards,
	Keean.


More information about the Haskell-Cafe mailing list