monomorphism bug

Ross Paterson <[email protected]>
Newsgroups gmane.comp.lang.haskell.hugs.bugs
Message-ID <[email protected]>
I can't track this one down, so I'll post it:

	Prelude> :t let f = const 1 in let g = f in g
	let {...} in (let {...} in g) :: Num a => b -> c

The error here is that a and c should be identified.  In larger examples,
this can cause real trouble.

More detail: f is subject to the Monomorphism Restriction, so its
return type should be monomorphic.  Hugs gets this right, as seen in

	Prelude> :t let f = const 1 in (f,f)
	let {...} in (f,f) :: Num a => (b -> a,c -> a)

However it loses the constraint on the type of g, as seen in

	Prelude> :t let f = const 1 in let g :: a -> b; g = f in g
	let {...} in (let {...} in g) :: Num a => b -> c

(which it should reject).  It seems essential that the type of f contain
fully polymorphic variables as well as the constrained one.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.