on master help sign in
Start adding constraint generation for declarations.
commit2ef18826dedf19a258895c30e9a2360bba389fb1 authorEvan Czaplicki <evan@Evans-MacBook-Air.local> dateMon 8 Jul 2013, 18:23 (13 years ago) parent5cc99f5
2 files changed+20−1
compiler/SourceSyntax/Module.hs−1 compiler/Type/Constrain/Declaration.hs+20
compiler/SourceSyntax/Module.hs−1
@@ -5,7 +5,6 @@ import Data.Data
55import Data.List (intercalate)
66import qualified SourceSyntax.Declaration as Decl
77import System.FilePath (joinPath)
8−import Types.Types
98
109data Module tipe var =
1110 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.