mirror of
https://github.com/github/semantic.git
synced 2024-11-24 17:04:47 +03:00
Reflow
This commit is contained in:
parent
10c99d3549
commit
dc98e5ef9d
@ -111,7 +111,9 @@ runEnv initial = fmap (filterEnv . fmap (first Env.head)) . runState lowerBound
|
||||
| Exports.null ports = (binds, a)
|
||||
| otherwise = (Exports.toBindings ports <> Env.aliasBindings (Exports.aliases ports) binds, a)
|
||||
|
||||
handleEnv :: forall address value effects a . Effects effects => Env address (Eff (Env address ': effects)) a -> Evaluator address value (State (Environment address) ': State (Exports address) ': effects) a
|
||||
handleEnv :: forall address value effects a . Effects effects
|
||||
=> Env address (Eff (Env address ': effects)) a
|
||||
-> Evaluator address value (State (Environment address) ': State (Exports address) ': effects) a
|
||||
handleEnv = \case
|
||||
Lookup name -> Env.lookupEnv' name <$> get
|
||||
Bind name addr -> modify (Env.insertEnv name addr)
|
||||
@ -141,10 +143,15 @@ freeVariableError :: ( Member (Reader ModuleInfo) effects
|
||||
-> Evaluator address value effects address
|
||||
freeVariableError = throwEnvironmentError . FreeVariable
|
||||
|
||||
runEnvironmentError :: (Effectful (m address value), Effects effects) => m address value (Resumable (BaseError (EnvironmentError address)) ': effects) a -> m address value effects (Either (SomeExc (BaseError (EnvironmentError address))) a)
|
||||
runEnvironmentError :: (Effectful (m address value), Effects effects)
|
||||
=> m address value (Resumable (BaseError (EnvironmentError address)) ': effects) a
|
||||
-> m address value effects (Either (SomeExc (BaseError (EnvironmentError address))) a)
|
||||
runEnvironmentError = runResumable
|
||||
|
||||
runEnvironmentErrorWith :: (Effectful (m address value), Effects effects) => (forall resume . BaseError (EnvironmentError address) resume -> m address value effects resume) -> m address value (Resumable (BaseError (EnvironmentError address)) ': effects) a -> m address value effects a
|
||||
runEnvironmentErrorWith :: (Effectful (m address value), Effects effects)
|
||||
=> (forall resume . BaseError (EnvironmentError address) resume -> m address value effects resume)
|
||||
-> m address value (Resumable (BaseError (EnvironmentError address)) ': effects) a
|
||||
-> m address value effects a
|
||||
runEnvironmentErrorWith = runResumableWith
|
||||
|
||||
throwEnvironmentError :: ( Member (Resumable (BaseError (EnvironmentError address))) effects
|
||||
|
@ -109,10 +109,15 @@ instance Show1 (LoadError address) where
|
||||
instance Eq1 (LoadError address) where
|
||||
liftEq _ (ModuleNotFoundError a) (ModuleNotFoundError b) = a == b
|
||||
|
||||
runLoadError :: (Effectful (m address value), Effects effects) => m address value (Resumable (BaseError (LoadError address)) ': effects) a -> m address value effects (Either (SomeExc (BaseError (LoadError address))) a)
|
||||
runLoadError :: (Effectful (m address value), Effects effects)
|
||||
=> m address value (Resumable (BaseError (LoadError address)) ': effects) a
|
||||
-> m address value effects (Either (SomeExc (BaseError (LoadError address))) a)
|
||||
runLoadError = runResumable
|
||||
|
||||
runLoadErrorWith :: (Effectful (m address value), Effects effects) => (forall resume . (BaseError (LoadError address)) resume -> m address value effects resume) -> m address value (Resumable (BaseError (LoadError address)) ': effects) a -> m address value effects a
|
||||
runLoadErrorWith :: (Effectful (m address value), Effects effects)
|
||||
=> (forall resume . (BaseError (LoadError address)) resume -> m address value effects resume)
|
||||
-> m address value (Resumable (BaseError (LoadError address)) ': effects) a
|
||||
-> m address value effects a
|
||||
runLoadErrorWith = runResumableWith
|
||||
|
||||
throwLoadError :: Member (Resumable (BaseError (LoadError address))) effects
|
||||
@ -138,11 +143,23 @@ instance Eq1 ResolutionError where
|
||||
liftEq _ (GoImportError a) (GoImportError b) = a == b
|
||||
liftEq _ _ _ = False
|
||||
|
||||
runResolutionError :: (Effectful m, Effects effects) => m (Resumable (BaseError ResolutionError) ': effects) a -> m effects (Either (SomeExc (BaseError ResolutionError)) a)
|
||||
runResolutionError :: (Effectful m, Effects effects)
|
||||
=> m (Resumable (BaseError ResolutionError) ': effects) a
|
||||
-> m effects (Either (SomeExc (BaseError ResolutionError)) a)
|
||||
runResolutionError = runResumable
|
||||
|
||||
runResolutionErrorWith :: (Effectful m, Effects effects) => (forall resume . (BaseError ResolutionError) resume -> m effects resume) -> m (Resumable (BaseError ResolutionError) ': effects) a -> m effects a
|
||||
runResolutionErrorWith :: (Effectful m, Effects effects)
|
||||
=> (forall resume . (BaseError ResolutionError) resume -> m effects resume)
|
||||
-> m (Resumable (BaseError ResolutionError) ': effects) a
|
||||
-> m effects a
|
||||
runResolutionErrorWith = runResumableWith
|
||||
|
||||
throwResolutionError :: (Monad (m effects), Effectful m, Member (Reader ModuleInfo) effects, Member (Reader Span) effects, Member (Resumable (BaseError ResolutionError)) effects) => ResolutionError resume -> m effects resume
|
||||
throwResolutionError :: ( Monad (m effects)
|
||||
, Effectful m
|
||||
, Member (Reader ModuleInfo) effects
|
||||
, Member (Reader Span) effects
|
||||
, Member (Resumable (BaseError ResolutionError)) effects
|
||||
)
|
||||
=> ResolutionError resume
|
||||
-> m effects resume
|
||||
throwResolutionError err = currentErrorContext >>= \ errorContext -> throwResumable $ BaseError errorContext err
|
||||
|
@ -243,16 +243,36 @@ withTermSpans :: ( HasField fields Span
|
||||
-> SubtermAlgebra (TermF syntax (Record fields)) term (TermEvaluator term address value effects a)
|
||||
withTermSpans recur term = withCurrentSpan (getField (termFAnnotation term)) (recur term)
|
||||
|
||||
resumingResolutionError :: (Applicative (m effects), Effectful m, Member Trace effects, Effects effects) => m (Resumable (BaseError ResolutionError) ': effects) a -> m effects a
|
||||
resumingResolutionError :: ( Applicative (m effects)
|
||||
, Effectful m
|
||||
, Member Trace effects
|
||||
, Effects effects
|
||||
)
|
||||
=> m (Resumable (BaseError ResolutionError) ': effects) a
|
||||
-> m effects a
|
||||
resumingResolutionError = runResolutionErrorWith (\ (BaseError context err) -> traceError "ResolutionError" err context *> case err of
|
||||
NotFoundError nameToResolve _ _ -> pure nameToResolve
|
||||
GoImportError pathToResolve -> pure [pathToResolve])
|
||||
|
||||
resumingLoadError :: (Applicative (m address value effects), AbstractHole address, Effectful (m address value), Effects effects, Member Trace effects) => m address value (Resumable (BaseError (LoadError address)) ': effects) a -> m address value effects a
|
||||
resumingLoadError :: ( Applicative (m address value effects)
|
||||
, AbstractHole address
|
||||
, Effectful (m address value)
|
||||
, Effects effects
|
||||
, Member Trace effects
|
||||
)
|
||||
=> m address value (Resumable (BaseError (LoadError address)) ': effects) a
|
||||
-> m address value effects a
|
||||
resumingLoadError = runLoadErrorWith (\ (BaseError context err) -> traceError "LoadError" err context *> case err of
|
||||
ModuleNotFoundError _ -> pure (lowerBound, hole))
|
||||
|
||||
resumingEvalError :: (Applicative (m effects), Effectful m, Effects effects, Member Fresh effects, Member Trace effects) => m (Resumable (BaseError EvalError) ': effects) a -> m effects a
|
||||
resumingEvalError :: ( Applicative (m effects)
|
||||
, Effectful m
|
||||
, Effects effects
|
||||
, Member Fresh effects
|
||||
, Member Trace effects
|
||||
)
|
||||
=> m (Resumable (BaseError EvalError) ': effects) a
|
||||
-> m effects a
|
||||
resumingEvalError = runEvalErrorWith (\ (BaseError context err) -> traceError "EvalError" err context *> case err of
|
||||
DefaultExportError{} -> pure ()
|
||||
ExportError{} -> pure ()
|
||||
@ -261,7 +281,13 @@ resumingEvalError = runEvalErrorWith (\ (BaseError context err) -> traceError "E
|
||||
RationalFormatError{} -> pure 0
|
||||
NoNameError -> gensym)
|
||||
|
||||
resumingUnspecialized :: (Applicative (m value effects), AbstractHole value, Effectful (m value), Effects effects, Member Trace effects) => m value (Resumable (BaseError (UnspecializedError value)) ': effects) a -> m value effects a
|
||||
resumingUnspecialized :: ( Applicative (m value effects)
|
||||
, AbstractHole value
|
||||
, Effectful (m value)
|
||||
, Effects effects
|
||||
, Member Trace effects)
|
||||
=> m value (Resumable (BaseError (UnspecializedError value)) ': effects) a
|
||||
-> m value effects a
|
||||
resumingUnspecialized = runUnspecializedWith (\ (BaseError context err) -> traceError "UnspecializedError" err context *> case err of
|
||||
UnspecializedError _ -> pure hole)
|
||||
|
||||
@ -302,7 +328,13 @@ resumingValueError = runValueErrorWith (\ (BaseError context err) -> traceError
|
||||
KeyValueError{} -> pure (hole, hole)
|
||||
ArithmeticError{} -> pure hole)
|
||||
|
||||
resumingEnvironmentError :: (Monad (m (Hole (Maybe Name) address) value effects), Effectful (m (Hole (Maybe Name) address) value), Effects effects, Member Trace effects) => m (Hole (Maybe Name) address) value (Resumable (BaseError (EnvironmentError (Hole (Maybe Name) address))) ': effects) a -> m (Hole (Maybe Name) address) value effects a
|
||||
resumingEnvironmentError :: ( Monad (m (Hole (Maybe Name) address) value effects)
|
||||
, Effectful (m (Hole (Maybe Name) address) value)
|
||||
, Effects effects
|
||||
, Member Trace effects
|
||||
)
|
||||
=> m (Hole (Maybe Name) address) value (Resumable (BaseError (EnvironmentError (Hole (Maybe Name) address))) ': effects) a
|
||||
-> m (Hole (Maybe Name) address) value effects a
|
||||
resumingEnvironmentError = runResumableWith (\ (BaseError context err) -> traceError "EnvironmentError" err context >> (\ (FreeVariable name) -> pure (Partial (Just name))) err)
|
||||
|
||||
resumingTypeError :: ( Alternative (m address Type (State TypeMap ': effects))
|
||||
|
Loading…
Reference in New Issue
Block a user