@@ -26,11 +26,11 @@ interface moduleName iface =
26 , iFixities = iFixities iface -- cannot have canonicalized operators while parsing
26 , iFixities = iFixities iface -- cannot have canonicalized operators while parsing
29− both f g (a,b,c) = (f a, b, g c)
29+ both f g (a,b,c,d) = (f a, b, g c, d)
30 prefix name = moduleName ++ "." ++ name
30 prefix name = moduleName ++ "." ++ name
32 pair name = (name, moduleName ++ "." ++ name)
32 pair name = (name, moduleName ++ "." ++ name)
33− canon (name,_,_) = pair name
33+ canon (name,_,_,_) = pair name
34 canons = Map.fromList $ concat
34 canons = Map.fromList $ concat
35 [ map canon (iAdts iface), map canon (iAliases iface) ]
35 [ map canon (iAdts iface), map canon (iAliases iface) ]
@@ -56,8 +56,8 @@ metadataModule ifaces modul =
56 [] -> Right ()
56 [] -> Right ()
57 missings -> Left [ P.text $ "The following imports were not found: " ++ List.intercalate ", " missings ]
57 missings -> Left [ P.text $ "The following imports were not found: " ++ List.intercalate ", " missings ]
58 program' <- rename initialEnv (program modul)
58 program' <- rename initialEnv (program modul)
59− aliases' <- mapM (third renameType') (aliases modul)
59+ aliases' <- mapM (threeOfFour renameType') (aliases modul)
60− datatypes' <- mapM (third (mapM (second (mapM renameType')))) (datatypes modul)
60+ datatypes' <- mapM (threeOfFour (mapM (second (mapM renameType')))) (datatypes modul)
61 exports' <- mapM (third renameType') (foreignExports modul)
61 exports' <- mapM (third renameType') (foreignExports modul)
62 imports' <- mapM (twoAndFour (rename initialEnv) renameType') (foreignImports modul)
62 imports' <- mapM (twoAndFour (rename initialEnv) renameType') (foreignImports modul)
63 return $ modul { program = program'
63 return $ modul { program = program'
@@ -68,19 +68,23 @@ metadataModule ifaces modul =
69 second f (a,b) = (,) a `fmap` f b
69 second f (a,b) = (,) a `fmap` f b
70 third f (a,b,c) = (,,) a b `fmap` f c
70 third f (a,b,c) = (,,) a b `fmap` f c
71+ threeOfFour f (a,b,c,d) =
71− twoAndFour f g (a,b,c,d) = do b' <- f b
74+ twoAndFour f g (a,b,c,d) =
72− d' <- g d
76+ d' <- g d
73− return (a,b',c,d')
77+ return (a,b',c,d')
74 renameType' =
78 renameType' =
75 Either.either (\err -> Left [P.text err]) return . renameType (replace "type" initialEnv)
79 Either.either (\err -> Left [P.text err]) return . renameType (replace "type" initialEnv)
77− get1 (a,_,_) = a
81+ get1 (a,_,_,_) = a
78 canon (name, importMethod) =
82 canon (name, importMethod) =
79 let pair pre var = (pre ++ drop (length name + 1) var, var)
83 let pair pre var = (pre ++ drop (length name + 1) var, var)
80 iface = ifaces Map.! name
84 iface = ifaces Map.! name
81 allNames = concat [ Map.keys (iTypes iface)
85 allNames = concat [ Map.keys (iTypes iface)
82 , map get1 (iAliases iface)
86 , map get1 (iAliases iface)
83− , concat [ n : map fst ctors | (n,_,ctors) <- iAdts iface ] ]
87+ , concat [ n : map fst ctors | (n,_,ctors,_) <- iAdts iface ] ]
84 in case importMethod of
88 in case importMethod of
85 As alias -> map (pair (alias ++ ".")) allNames
89 As alias -> map (pair (alias ++ ".")) allNames
86 Hiding vars -> map (pair "") $ filter (flip Set.notMember vs) allNames
90 Hiding vars -> map (pair "") $ filter (flip Set.notMember vs) allNames