mirror of
https://github.com/github/semantic.git
synced 2025-01-01 19:55:34 +03:00
Derive the MonadAnalysis instance for TypeChecking.
This commit is contained in:
parent
2267f24ea8
commit
beb7261608
@ -11,36 +11,19 @@ import Prologue hiding (TypeError)
|
|||||||
newtype TypeChecking m (effects :: [* -> *]) a = TypeChecking { runTypeChecking :: m effects a }
|
newtype TypeChecking m (effects :: [* -> *]) a = TypeChecking { runTypeChecking :: m effects a }
|
||||||
deriving (Alternative, Applicative, Functor, Effectful, Monad)
|
deriving (Alternative, Applicative, Functor, Effectful, Monad)
|
||||||
|
|
||||||
deriving instance MonadEvaluator location term value effects m => MonadEvaluator location term value effects (TypeChecking m)
|
deriving instance MonadEvaluator location term Type effects m => MonadEvaluator location term Type effects (TypeChecking m)
|
||||||
|
deriving instance MonadAnalysis location term Type effects m => MonadAnalysis location term Type effects (TypeChecking m)
|
||||||
instance ( Effectful m
|
|
||||||
, Alternative (m effects)
|
|
||||||
, MonadAnalysis location term Type effects m
|
|
||||||
, Member (Resumable TypeError) effects
|
|
||||||
, Member NonDet effects
|
|
||||||
, MonadValue location Type effects (TypeChecking m)
|
|
||||||
)
|
|
||||||
=> MonadAnalysis location term Type effects (TypeChecking m) where
|
|
||||||
analyzeTerm eval term =
|
|
||||||
resume @TypeError (liftAnalyze analyzeTerm eval term) (
|
|
||||||
\yield err -> case err of
|
|
||||||
-- TODO: These should all yield both sides of the exception,
|
|
||||||
-- but something is mysteriously busted in the innards of typechecking,
|
|
||||||
-- so doing that just yields an empty list in the result type, which isn't
|
|
||||||
-- extraordinarily helpful. Better for now to just die with an error and
|
|
||||||
-- tackle this issue in a separate PR.
|
|
||||||
BitOpError{} -> throwResumable err
|
|
||||||
NumOpError{} -> throwResumable err
|
|
||||||
UnificationError{} -> throwResumable err
|
|
||||||
)
|
|
||||||
|
|
||||||
analyzeModule = liftAnalyze analyzeModule
|
|
||||||
|
|
||||||
instance ( Interpreter effects (Either (SomeExc TypeError) result) rest m
|
instance ( Interpreter effects (Either (SomeExc TypeError) result) rest m
|
||||||
, MonadEvaluator location term value effects m
|
, MonadEvaluator location term Type effects m
|
||||||
)
|
)
|
||||||
=> Interpreter (Resumable TypeError ': effects) result rest (TypeChecking m) where
|
=> Interpreter (Resumable TypeError ': effects) result rest (TypeChecking m) where
|
||||||
interpret
|
interpret
|
||||||
= interpret
|
= interpret
|
||||||
. runTypeChecking
|
. runTypeChecking
|
||||||
|
-- TODO: We should handle TypeError by yielding both sides of the exception,
|
||||||
|
-- but something is mysteriously busted in the innards of typechecking,
|
||||||
|
-- so doing that just yields an empty list in the result type, which isn't
|
||||||
|
-- extraordinarily helpful. Better for now to just die with an error and
|
||||||
|
-- tackle this issue in a separate PR.
|
||||||
. raiseHandler runError
|
. raiseHandler runError
|
||||||
|
Loading…
Reference in New Issue
Block a user