[cvs-nhc98] patch applied (hat): Remove another bug in type checker with respect to type synonyms.

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Tue Oct 10 07:24:34 EDT 2006


Tue Apr  1 05:54:36 PST 2003  olaf
  * Remove another bug in type checker with respect to type synonyms.
  
  The program below did not type check (occurrence check failure), because the type checker did not expand type synonyms before doing the occurrence check. Expansion of a type can lead to a type with less type variables, or in this case the type to be substituted is just a simple type variable.
  
  In turned out that for the latter handling of type class contexts it is important that a substitution never replaces a variable by a type that is not a type variable but becomes a type variable after type synonym expansion. So unification assures that the resulting substitution meets this constraint.
  
  There may still be further errors with respect to unexpanded type synonyms in nhc98. Simply exanding all first would avoid all the problems, but also lead to less readable type error messages.
  
  -- begin
  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

    M ./src/compiler98/NT.hs -1 +7
    M ./src/compiler98/TypeUnify.hs -26 +36


More information about the Cvs-nhc98 mailing list