
Feliks Kluzniak
When I tried to compile my large program (which goes through GHC without any warnings), I get a bunch of strange error messages. I have managed to extract a small example that demonstrates the problem (see below).
I think my function is OK, don't you? In any case the error message seems confusing, since the derived type and the given type are shown as identical.
Thanks for the report - this bug is new to us. You are right that nhc98 should accept this program, and that the error message is confusing. The cause appears to be that nhc98 does not expand the type synonym type GNode a = a correctly. Our resident type system hacker will have a look at it, I'm sure. Regards, Malcolm
------------------------------- The diagnostics: $ nhc98 -c SeeStrange.hs ====== Errors after type inference/checking: Derived type for Main.unknownNodesInEdges at 17:1 can not be unified with given type due to (type-variable occurrence check fails) Derived:((GEdges a) -> ((GNodes a) -> (GEdges a))) Given :((GEdges a) -> ((GNodes a) -> (GEdges a))) Type error (type-variable occurrence check fails) when trying to apply function at 18:42 to its 2nd argument at 18:65.
Type error (type-variable occurrence check fails) when trying to apply function at 18:10 to its 2nd argument at 18:33.
------------------------------ SeeStrange.hs: import List ( nub )
type GNode a = a
type GNodes a = [ GNode a ]
type GEdge a = ( GNode a , GNode a )
type GEdges a = [ GEdge a ]
-- Find edges that contain occurrences of nodes not given in arg2.
unknownNodesInEdges :: (Eq a) => GEdges a -> GNodes a -> GEdges a
unknownNodesInEdges edges nodes = nub (filter (notNode . fst) edges ++ filter (notNode . snd) edges) where notNode = \x -> notElem x nodes ----------------------------------------------------------------------------

type GNode a = a
Thanks for the report - this bug is new to us. You are right that nhc98 should accept this program, and that the error message is confusing.
This bug is now fixed in CVS. A patch for nch98-1.16 is available from the downloads webpage. http://haskell.org/nhc98/download.html ftp://ftp.cs.york.ac.uk/pub/haskell/nhc98/patch-1.16-typesyn Regards, Malcolm
participants (1)
-
Malcolm Wallace