X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=sem.icl;h=fc8614b0c2a462501b364cc5cb52ad855d85a03b;hb=249bdba5121bca15012597a09e63a242781b001b;hp=a973a0223e787170fbd6e7013ad43476971c977d;hpb=c9a2ff29fb4482fc1f43cf0386198a7d0e4a5f9b;p=cc1516.git diff --git a/sem.icl b/sem.icl index a973a02..fc8614b 100644 --- a/sem.icl +++ b/sem.icl @@ -23,6 +23,10 @@ from parse import :: ParserOutput, :: Error :: Gamma :== 'Map'.Map String Type :: Env a :== StateT Gamma (Either SemError) a +//we need to redefine this even though it is in Control.Monad.State +instance MonadTrans (StateT Gamma) where + liftT m = StateT \s-> m >>= \a-> return (a, s) + get = gets id instance toString SemError where @@ -36,12 +40,9 @@ instance toString SemError where toString t1, ". Given: ", toString t2] putIdent :: String Type -> Env Void -putIdent i t = undef -/*putIdent i t = gets ('Map'.get i) >>= \mt -> case mt of - Nothing = pure <$> modify ('Map'.put i t) - Just t2 = unify t t2 >>= \r -> case r of - Left e = pure $ Left e - Right t3 = pure <$> modify ('Map'.put i t3)*/ +putIdent i t = gets ('Map'.get i) >>= \mt -> case mt of + Nothing = modify ('Map'.put i t) + Just t2 = unify t t2 >>= \t3-> modify ('Map'.put i t3) sem :: AST -> SemOutput sem (AST vd fd) = case evalStateT m 'Map'.newMap of