Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions brat/Brat/Checker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Data.List.NonEmpty (NonEmpty(..))
import qualified Data.List.NonEmpty as NE
import qualified Data.Map as M
import Data.Maybe (fromJust)
import qualified Data.Set as S
import Data.Traversable (for)
import Data.Type.Equality ((:~:)(..), testEquality)
import Prelude hiding (filter)
Expand Down Expand Up @@ -387,16 +388,19 @@ check' (Var x) ((), ()) = (, ((), ())) . ((),) <$> case ?my of
Kerny -> req (KLup x) >>= \case
Just (p, ty) -> pure [(p, ty)]
Nothing -> err $ KVarNotFound (show x)
check' (Arith op l r) ((), u@(hungry, ty):unders) = case (?my, ty) of
(Braty, ty) -> do
ty <- evalBinder Braty ty
case ty of
Right TNat -> check_arith TNat
Right TInt -> check_arith TInt
Right TFloat -> check_arith TFloat
_ -> err . ArithNotExpected $ show u
check' (Arith op l r) ((), (hungry, ty):unders) = case (?my, ty) of
(Braty, ty) -> checkNumTy ty
(Kerny, _) -> err ArithInKernel
where
checkNumTy :: BinderType Brat -> Checking (SynConnectors m d k, ChkConnectors m d k)
checkNumTy (Right ty) | ty `elem` [TNat, TInt, TFloat] = check_arith ty
-- TODO: Allow Arith expressions typed against Left Nat
checkNumTy (Right ty@(VApp (VPar e) B0)) = do
mkYield ("WaitingForHope(" ++ show e ++ ")") (S.singleton e)
ty <- eval S0 ty
checkNumTy (Right ty)
checkNumTy _ = err $ ArithNotExpected (show ty)

check_arith ty = let ?my = Braty in do
let inRo = RPr ("left", ty) $ RPr ("right", ty) R0
let outRo = RPr ("out", ty) R0
Expand Down
Loading