@@ -9,7 +9,9 @@ import qualified Type.Constrain.Expression as TcExpr
9import qualified Type.Environment as Env
9import qualified Type.Environment as Env
11import SourceSyntax.Declaration
11import SourceSyntax.Declaration
12−import qualified SourceSyntax.Everything as Src
12+import qualified SourceSyntax.Expression as Src
13+import qualified SourceSyntax.Location as L
14+import qualified SourceSyntax.Pattern as P
13import qualified SourceSyntax.Type as Type
15import qualified SourceSyntax.Type as Type
15toExpr :: [Declaration t v] -> [Src.Def t v]
17toExpr :: [Declaration t v] -> [Src.Def t v]
@@ -25,34 +27,34 @@ toDefs decl =
25 toDefs (ctor, tipes) =
27 toDefs (ctor, tipes) =
26 let vars = take (length tipes) arguments
28 let vars = take (length tipes) arguments
27 tbody = Type.Data name $ map Type.Var tvars
29 tbody = Type.Data name $ map Type.Var tvars
28− body = Src.none . Src.Data ctor $ map (Src.none . Src.Var) vars
30+ body = L.none . Src.Data ctor $ map (L.none . Src.Var) vars
29 in [ Src.TypeAnnotation ctor $ foldr Type.Lambda tbody tipes
31 in [ Src.TypeAnnotation ctor $ foldr Type.Lambda tbody tipes
30− , Src.Def (Src.PVar ctor) $ buildFunction body vars
32+ , Src.Def (P.PVar ctor) $ buildFunction body vars
33 TypeAlias name tvars tipe@(Type.Record fields ext) ->
35 TypeAlias name tvars tipe@(Type.Record fields ext) ->
34 [ Src.TypeAnnotation name $ foldr Type.Lambda tipe args
36 [ Src.TypeAnnotation name $ foldr Type.Lambda tipe args
35− , Src.Def (Src.PVar name) $ buildFunction record vars ]
37+ , Src.Def (P.PVar name) $ buildFunction record vars ]
37 args = case ext of
39 args = case ext of
38 Type.EmptyRecord -> map snd fields
40 Type.EmptyRecord -> map snd fields
39 _ -> map snd fields ++ [ext]
41 _ -> map snd fields ++ [ext]
41− var = Src.none . Src.Var
43+ var = L.none . Src.Var
42 vars = take (length args) arguments
44 vars = take (length args) arguments
44 efields = zip (map fst fields) (map var vars)
46 efields = zip (map fst fields) (map var vars)
45 record = case ext of
47 record = case ext of
46− Type.EmptyRecord -> Src.none $ Src.Record efields
48+ Type.EmptyRecord -> L.none $ Src.Record efields
47− _ -> foldl (\r (f,v) -> Src.none $ Src.Insert r f v) (var $ last vars) efields
49+ _ -> foldl (\r (f,v) -> L.none $ Src.Insert r f v) (var $ last vars) efields
49 -- Type aliases must be added to an extended equality dictionary,
51 -- Type aliases must be added to an extended equality dictionary,
50 -- but they do not require any basic constraints.
52 -- but they do not require any basic constraints.
51 TypeAlias _ _ _ -> []
53 TypeAlias _ _ _ -> []
53− ImportEvent _ expr@(Src.L s _) name tipe ->
55+ ImportEvent _ expr@(L.L s _) name tipe ->
54 [ Src.TypeAnnotation name tipe
56 [ Src.TypeAnnotation name tipe
55− , Src.Def (Src.PVar name) (Src.L s $ Src.App (Src.L s $ Src.Var "constant") expr) ]
57+ , Src.Def (P.PVar name) (L.L s $ Src.App (L.L s $ Src.Var "constant") expr) ]
57 ExportEvent _ name tipe ->
59 ExportEvent _ name tipe ->
58 [ Src.TypeAnnotation name tipe ]
60 [ Src.TypeAnnotation name tipe ]
@@ -64,5 +66,5 @@ toDefs decl =
64arguments :: [String]
66arguments :: [String]
65arguments = map (:[]) ['a'..'z'] ++ map (\n -> "_" ++ show n) [1..]
67arguments = map (:[]) ['a'..'z'] ++ map (\n -> "_" ++ show n) [1..]
67−buildFunction body@(Src.L s _) vars =
69+buildFunction body@(L.L s _) vars =
68− foldr (\p e -> Src.L s (Src.Lambda p e)) body (map Src.PVar vars)
70+ foldr (\p e -> L.L s (Src.Lambda p e)) body (map P.PVar vars)