@@ -2,15 +2,15 @@
2module Type.Constrain.Declaration where
2module Type.Constrain.Declaration where
4import SourceSyntax.Declaration
4import SourceSyntax.Declaration
5−import qualified SourceSyntax.Expression as Src
5+import qualified SourceSyntax.Expression as E
6import qualified SourceSyntax.Location as L
6import qualified SourceSyntax.Location as L
7import qualified SourceSyntax.Pattern as P
7import qualified SourceSyntax.Pattern as P
8import qualified SourceSyntax.Type as Type
8import qualified SourceSyntax.Type as Type
10−toExpr :: [Declaration] -> [Src.Def]
10+toExpr :: [Declaration] -> [E.Def]
11toExpr = concatMap toDefs
11toExpr = concatMap toDefs
13−toDefs :: Declaration -> [Src.Def]
13+toDefs :: Declaration -> [E.Def]
14toDefs decl =
14toDefs decl =
15 case decl of
15 case decl of
16 Definition def -> [def]
16 Definition def -> [def]
@@ -20,7 +20,7 @@ toDefs decl =
20 toDefs' (ctor, tipes) =
20 toDefs' (ctor, tipes) =
21 let vars = take (length tipes) arguments
21 let vars = take (length tipes) arguments
22 tbody = Type.Data name $ map Type.Var tvars
22 tbody = Type.Data name $ map Type.Var tvars
23− body = L.none . Src.Data ctor $ map (L.none . Src.Var) vars
23+ body = L.none . E.Data ctor $ map (L.none . E.Var) vars
24 in [ definition ctor (buildFunction body vars) (foldr Type.Lambda tbody tipes) ]
24 in [ definition ctor (buildFunction body vars) (foldr Type.Lambda tbody tipes) ]
26 TypeAlias name _ tipe@(Type.Record fields ext) _ ->
26 TypeAlias name _ tipe@(Type.Record fields ext) _ ->
@@ -30,13 +30,13 @@ toDefs decl =
30 Type.EmptyRecord -> map snd fields
30 Type.EmptyRecord -> map snd fields
31 _ -> map snd fields ++ [ext]
31 _ -> map snd fields ++ [ext]
33− var = L.none . Src.Var
33+ var = L.none . E.Var
34 vars = take (length args) arguments
34 vars = take (length args) arguments
36 efields = zip (map fst fields) (map var vars)
36 efields = zip (map fst fields) (map var vars)
37 record = case ext of
37 record = case ext of
38− Type.EmptyRecord -> L.none $ Src.Record efields
38+ Type.EmptyRecord -> L.none $ E.Record efields
39− _ -> foldl (\r (f,v) -> L.none $ Src.Insert r f v) (var $ last vars) efields
39+ _ -> foldl (\r (f,v) -> L.none $ E.Insert r f v) (var $ last vars) efields
41 -- Type aliases must be added to an extended equality dictionary,
41 -- Type aliases must be added to an extended equality dictionary,
42 -- but they do not require any basic constraints.
42 -- but they do not require any basic constraints.
@@ -56,9 +56,9 @@ toDefs decl =
56arguments :: [String]
56arguments :: [String]
57arguments = map (:[]) ['a'..'z'] ++ map (\n -> "_" ++ show (n :: Int)) [1..]
57arguments = map (:[]) ['a'..'z'] ++ map (\n -> "_" ++ show (n :: Int)) [1..]
59−buildFunction :: Src.LExpr -> [String] -> Src.LExpr
59+buildFunction :: E.LExpr -> [String] -> E.LExpr
60buildFunction body@(L.L s _) vars =
60buildFunction body@(L.L s _) vars =
61− foldr (\p e -> L.L s (Src.Lambda p e)) body (map P.PVar vars)
61+ foldr (\p e -> L.L s (E.Lambda p e)) body (map P.PVar vars)
63−definition :: String -> Src.LExpr -> Type.Type -> Src.Def
63+definition :: String -> E.LExpr -> Type.Type -> E.Def
64−definition name expr tipe = Src.Definition (P.PVar name) expr (Just tipe)
64+definition name expr tipe = E.Definition (P.PVar name) expr (Just tipe)