Skip to content

Commit

Permalink
[ #20 ] I don't know what to do
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed Dec 24, 2018
1 parent 7f21f28 commit 55a4468
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/full/OwO/TypeChecking.hs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE LambdaCase #-}

module OwO.TypeChecking where

import Control.Applicative (Alternative (..))
import Data.Functor ((<&>))
import Data.Maybe (catMaybes)
import Each

import OwO.Syntax.Abstract
import OwO.TypeChecking.Core
Expand All @@ -17,15 +15,21 @@ import OwO.TypeChecking.Reduce

#include <impossible.h>

typeCheck :: TCEnv -> PsiTerm -> Either TCErr Term
typeCheck env (PsiConstant _ info) = Right $ Constant info
constType :: ConstInfo -> Type
constType = __TODO__

typeCheck :: TCEnv -> PsiTerm -> Either TCErr (Type, Term)
typeCheck env (PsiConstant _ info) = Right (constType info, Constant info)
typeCheck env (PsiLambda binder term) = return __TODO__
typeCheck env (PsiApplication func term) = $(each [|
App (~! typeCheck env func) (~! typeCheck env term) |] )
typeCheck env (PsiApplication func term) = do
(f, ft) <- typeCheck env func
(x, xt) <- typeCheck env term
-- TODO: check the relationship
return (__TODO__, App f x)
typeCheck env (PsiReference name) =
case contextual <|> builtin of
Nothing -> Left $ UnresolvedReferenceErr name
Just def -> Right $ Ref FunctionName name def
Just def -> Right (definitionType def, Ref FunctionName name def)
where
txt = textOfName name
builtin = builtinDefinition txt
Expand Down
4 changes: 4 additions & 0 deletions src/full/OwO/TypeChecking/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module OwO.TypeChecking.Core

, builtinDefinition
, builtinDefinition'
, definitionType

, Definition(..)
) where
Expand Down Expand Up @@ -97,6 +98,9 @@ data Definition
-- ^ No type signature, just an expression with (optional) type specified
deriving (Eq, Generic, Ord, Show)

definitionType :: Definition -> Type
definitionType (SimpleDefinition t _) = t

-- | Built-in definition: Type0, Type1, etc
typeUniverseOfLevel :: Int -> Definition
typeUniverseOfLevel = uncurry SimpleDefinition . typeUniverseOfLevel'
Expand Down

0 comments on commit 55a4468

Please sign in to comment.