on master help sign in
Start adding constraint generation for declarations.
2ef1882Evan Czaplicki
compiler/SourceSyntax/Module.hs−1
@@ -5,7 +5,6 @@ import Data.Data
5import Data.List (intercalate)
5import Data.List (intercalate)
6import qualified SourceSyntax.Declaration as Decl
6import qualified SourceSyntax.Declaration as Decl
7import System.FilePath (joinPath)
7import System.FilePath (joinPath)
8−import Types.Types
9
8
10data Module tipe var =
9data Module tipe var =
11 Module [String] Exports Imports [Decl.Declaration tipe var]
10 Module [String] Exports Imports [Decl.Declaration tipe var]
compiler/Type/Constrain/Declaration.hsnew file+20
@@ -0,0 +1,20 @@
1+module Type.Constrain.Declaration where
2+
3+import Type.Type
4+import SourceSyntax.Declaration
5+import qualified Type.Constrain.Expression as Expr
6+import qualified Type.Environment as Env
7+
8+constrain :: Env.Environment -> Declaration t v -> Type -> IO TypeConstraint
9+constrain env decl tipe =
10+ case decl of
11+ ImportEvent _ expr var sourceType -> do
12+ etipe <- (Expr.instantiateType sourceType)
13+ constraint <- Expr.constrain env expr etipe
14+ return (tipe === etipe /\ constraint)
15+ -- also do something with var. Not sure what yet.
16+
17+ ExportEvent _ var sourceType -> do
18+ etipe <- (Expr.instantiateType sourceType)
19+ return (tipe === etipe)
20+ -- also do something with var. Not sure what yet.