diff --git a/src/full/OwO/TypeChecking.hs b/src/full/OwO/TypeChecking.hs index b6b7e61..d299b3a 100644 --- a/src/full/OwO/TypeChecking.hs +++ b/src/full/OwO/TypeChecking.hs @@ -17,7 +17,13 @@ import OwO.TypeChecking.Reduce typeCheck :: TCEnv -> PsiTerm -> Either TCErr Term typeCheck env (PsiConstant _ info) = Right $ Constant info typeCheck env (PsiLambda binder term) = return __TODO__ -typeCheck env (PsiReference name) = return __TODO__ +typeCheck env (PsiReference name) = + case lookupCtxWithName + (envModuleName env) + (textOfName name) + (envDefinitions env) of + Nothing -> Left $ UnresolvedReferenceErr name + Just def -> Right $ Ref FunctionName name def typeCheck env term = return __TODO__ typeCheckFile :: TCState -> PsiFile -> TCM () diff --git a/src/full/OwO/TypeChecking/Core.hs b/src/full/OwO/TypeChecking/Core.hs index ea6e184..41f66ab 100644 --- a/src/full/OwO/TypeChecking/Core.hs +++ b/src/full/OwO/TypeChecking/Core.hs @@ -76,7 +76,7 @@ data Term' i -- ^ Application | Var !Int -- ^ A variable resolved with de bruijn index - | Param NameType i (Term' i) + | Ref NameType i Definition -- ^ Named reference, might be external definitions | Bind i !(BinderInfo (Term' i)) (Term' i) -- ^ Name binding diff --git a/src/full/OwO/TypeChecking/Monad.hs b/src/full/OwO/TypeChecking/Monad.hs index 8d05d98..b74a633 100644 --- a/src/full/OwO/TypeChecking/Monad.hs +++ b/src/full/OwO/TypeChecking/Monad.hs @@ -83,6 +83,8 @@ data TCEnv = TypeCheckingEnv -- ^ This is passed all around , envDefinitions :: TCCtx Definition -- ^ Local definitions + , envModuleName :: QModuleName + -- ^ Current module name } deriving (Generic, Show) data TCErr' t