@@ -5,22 +5,17 @@ import Control.Applicative ((<$>))
55
66import qualified Data.Map as Map
77
8−import qualified Type.Type as T
98import qualified Type.Constrain.Expression as TcExpr
109import qualified Type.Environment as Env
1110
1211import SourceSyntax.Declaration
13−import qualified SourceSyntax.Location as SL
14−import qualified SourceSyntax.Literal as SL
15−import qualified SourceSyntax.Pattern as SP
16−import qualified SourceSyntax.Expression as SE
17−import qualified SourceSyntax.Type as ST
12+import qualified SourceSyntax.Everything as Src
13+import qualified SourceSyntax.Type as Type
1814
19−
20−toExpr :: [Declaration t v] -> [SE.Def t v]
15+toExpr :: [Declaration t v] -> [Src.Def t v]
2116toExpr = concatMap toDefs
2217
23−toDefs :: Declaration t v -> [SE.Def t v]
18+toDefs :: Declaration t v -> [Src.Def t v]
2419toDefs decl =
2520 case decl of
2621 Definition def -> [def]
@@ -29,24 +24,24 @@ toDefs decl =
2924 where
3025 toDefs (ctor, tipes) =
3126 let vars = take (length tipes) $ map (\n -> "_" ++ show n) [0..]
32− loc = SL.none
33− body = loc . SE.Data name $ map (loc . SE.Var) vars
34− in [ SE.TypeAnnotation ctor $
35− foldr ST.Lambda (ST.Data name $ map ST.Var tvars) tipes
36− , SE.Def (SP.PVar ctor) $
37− foldr (\p e -> loc $ SE.Lambda p e) body (map SP.PVar vars)
27+ loc = Src.none
28+ body = loc . Src.Data name $ map (loc . Src.Var) vars
29+ in [ Src.TypeAnnotation ctor $
30+ foldr Type.Lambda (Type.Data name $ map Type.Var tvars) tipes
31+ , Src.Def (Src.PVar ctor) $
32+ foldr (\p e -> loc $ Src.Lambda p e) body (map Src.PVar vars)
3833 ]
3934
4035 -- Type aliases must be added to an extended equality dictionary,
4136 -- but they do not require any basic constraints.
4237 TypeAlias _ _ _ -> []
4338
44− ImportEvent _ expr@(SL.L a b _) name tipe ->
45− [ SE.TypeAnnotation name tipe
46− , SE.Def (SP.PVar name) (SL.L a b $ SE.App (SL.L a b $ SE.Var "constant") expr) ]
39+ ImportEvent _ expr@(Src.L a b _) name tipe ->
40+ [ Src.TypeAnnotation name tipe
41+ , Src.Def (Src.PVar name) (Src.L a b $ Src.App (Src.L a b $ Src.Var "constant") expr) ]
4742
4843 ExportEvent _ name tipe ->
49− [ SE.TypeAnnotation name tipe ]
44+ [ Src.TypeAnnotation name tipe ]
5045
5146 -- no constraints are needed for fixity declarations
5247 Fixity _ _ _ -> []