implementation module sem
import qualified Data.Map as Map
+
from Data.Func import $
+from StdFunc import o
+
import Data.Either
-import Control.Monad.State
-import StdMisc
+
+import StdString
+import StdList
+import StdEnum
+import RWST
+import GenEq
+
+from Text import class Text(concat), instance Text String
import AST
-from parse import :: ParserOutput
-from yard import :: Error
:: Gamma :== 'Map'.Map String Type
-:: Env a :== State Gamma a
+:: Constraint :== String
+:: Infer a :== RWST [String] [Constraint] Gamma (Either SemError) a
+:: SemError
+ = ParseError Pos String
+ | UnifyError Pos Type Type
+ | FieldSelectorError Pos Type FieldSelector
+ | OperatorError Pos Op2 Type
+ | UndeclaredVariableError Pos String
+ | ArgumentMisMatchError Pos String
+ | Error String
-sem :: ParserOutput -> SemOutput
-sem (Left p) = Left p
-sem (Right (AST vd fd)) = Right $ AST vd fd
-// foldM semVarDecl vd
-// >>= \gamma ->foldM typecheck gamma fd
+variableStream :: [String]
+variableStream = map toString [1..]
-semVarDecl :: VarDecl -> Env VarDecl
-semVarDecl (Vardecl pos type ident expr) = undef
-
+sem :: AST -> SemOutput
+sem (AST vd fd) = Right $ (AST vd fd, 'Map'.newMap)
+instance toString Gamma where
+ toString mp = concat [concat [k, ": ", toString v, "\n"]\\(k, v)<-'Map'.toList mp]
-
+instance toString SemError where
+ toString se = "SemError: "