Switch name of qualified import

This commit is contained in:
Evan Czaplicki 2014-01-04 09:45:20 +01:00
parent 9ff26223d8
commit 863d31b38f

View file

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