mirror of
https://github.com/github/semantic.git
synced 2024-12-27 00:44:57 +03:00
Generalize everything we can to PureEffects.
This commit is contained in:
parent
182c539718
commit
be526492ff
@ -159,10 +159,10 @@ data Allocator address value (m :: * -> *) return where
|
||||
GC :: Live address -> Allocator address value m ()
|
||||
|
||||
runAllocator :: ( Addressable address effects
|
||||
, Effects effects
|
||||
, Foldable (Cell address)
|
||||
, Member (Resumable (AddressError address value)) effects
|
||||
, Member (State (Heap address (Cell address) value)) effects
|
||||
, PureEffects effects
|
||||
, Reducer value (Cell address value)
|
||||
, ValueRoots address value
|
||||
)
|
||||
|
@ -68,9 +68,9 @@ instance Effect (Modules address) where
|
||||
sendModules :: Member (Modules address) effects => Modules address (Eff effects) return -> Evaluator address value effects return
|
||||
sendModules = send
|
||||
|
||||
runModules :: ( Effects effects
|
||||
, Member (Reader (ModuleTable (NonEmpty (Module (Environment address, address))))) effects
|
||||
runModules :: ( Member (Reader (ModuleTable (NonEmpty (Module (Environment address, address))))) effects
|
||||
, Member (Resumable (LoadError address)) effects
|
||||
, PureEffects effects
|
||||
)
|
||||
=> Set ModulePath
|
||||
-> Evaluator address value (Modules address ': effects) a
|
||||
|
@ -58,7 +58,7 @@ runParser parser blobSource = unsafeUseAsCStringLen (sourceBytes blobSource) $
|
||||
|
||||
-- | Parse 'Source' with the given 'TS.Language' and return its AST.
|
||||
-- Returns Nothing if the operation timed out.
|
||||
parseToAST :: (Bounded grammar, Enum grammar, Member (Lift IO) effects, Member Trace effects, Effects effects) => Timeout -> Ptr TS.Language -> Blob -> Eff effects (Maybe (AST [] grammar))
|
||||
parseToAST :: (Bounded grammar, Enum grammar, Member (Lift IO) effects, Member Trace effects, PureEffects effects) => Timeout -> Ptr TS.Language -> Blob -> Eff effects (Maybe (AST [] grammar))
|
||||
parseToAST (Milliseconds s) language Blob{..} = bracket TS.ts_parser_new TS.ts_parser_delete $ \ parser -> do
|
||||
let parserTimeout = s * 1000
|
||||
|
||||
|
@ -228,7 +228,7 @@ instance Effect Files where
|
||||
handleState c dist (Request (Write destination builder) k) = Request (Write destination builder) (dist . (<$ c) . k)
|
||||
|
||||
-- | Run a 'Files' effect in 'IO'.
|
||||
runFiles :: (Member (Exc SomeException) effs, Member (Lift IO) effs, Effects effs) => Eff (Files ': effs) a -> Eff effs a
|
||||
runFiles :: (Member (Exc SomeException) effs, Member (Lift IO) effs, PureEffects effs) => Eff (Files ': effs) a -> Eff effs a
|
||||
runFiles = interpret $ \ files -> case files of
|
||||
Read (FromPath path) -> rethrowing (readBlobFromPath path)
|
||||
Read (FromHandle handle) -> rethrowing (readBlobsFromHandle handle)
|
||||
|
@ -49,7 +49,7 @@ instance Effect Resolution where
|
||||
handleState c dist (Request (NodeJSResolution path key paths) k) = Request (NodeJSResolution path key paths) (dist . (<$ c) . k)
|
||||
handleState c dist (Request NoResolution k) = Request NoResolution (dist . (<$ c) . k)
|
||||
|
||||
runResolution :: (Member Files effs, Effects effs) => Eff (Resolution ': effs) a -> Eff effs a
|
||||
runResolution :: (Member Files effs, PureEffects effs) => Eff (Resolution ': effs) a -> Eff effs a
|
||||
runResolution = interpret $ \ res -> case res of
|
||||
NodeJSResolution dir prop excludeDirs -> nodeJSResolutionMap dir prop excludeDirs
|
||||
NoResolution -> pure Map.empty
|
||||
|
@ -154,7 +154,7 @@ runTaskWithConfig options logger statter task = do
|
||||
queueStat statter stat
|
||||
pure result
|
||||
|
||||
runTraceInTelemetry :: (Member Telemetry effects, Effects effects) => Eff (Trace ': effects) a -> Eff effects a
|
||||
runTraceInTelemetry :: (Member Telemetry effects, PureEffects effects) => Eff (Trace ': effects) a -> Eff effects a
|
||||
runTraceInTelemetry = interpret (\ (Trace str) -> writeLog Debug str [])
|
||||
|
||||
|
||||
@ -177,7 +177,7 @@ instance Effect Task where
|
||||
handleState c dist (Request (Serialize format input) k) = Request (Serialize format input) (dist . (<$ c) . k)
|
||||
|
||||
-- | Run a 'Task' effect by performing the actions in 'IO'.
|
||||
runTaskF :: (Member (Exc SomeException) effs, Member (Lift IO) effs, Member (Reader Config) effs, Member Telemetry effs, Member Trace effs, Effects effs) => Eff (Task ': effs) a -> Eff effs a
|
||||
runTaskF :: (Member (Exc SomeException) effs, Member (Lift IO) effs, Member (Reader Config) effs, Member Telemetry effs, Member Trace effs, PureEffects effs) => Eff (Task ': effs) a -> Eff effs a
|
||||
runTaskF = interpret $ \ task -> case task of
|
||||
Parse parser blob -> runParser blob parser
|
||||
Analyze interpret analysis -> pure (interpret analysis)
|
||||
@ -198,7 +198,7 @@ data ParserCancelled = ParserTimedOut deriving (Show, Typeable)
|
||||
instance Exception ParserCancelled
|
||||
|
||||
-- | Parse a 'Blob' in 'IO'.
|
||||
runParser :: (Member (Exc SomeException) effs, Member (Lift IO) effs, Member (Reader Config) effs, Member Telemetry effs, Member Trace effs, Effects effs) => Blob -> Parser term -> Eff effs term
|
||||
runParser :: (Member (Exc SomeException) effs, Member (Lift IO) effs, Member (Reader Config) effs, Member Telemetry effs, Member Trace effs, PureEffects effs) => Blob -> Parser term -> Eff effs term
|
||||
runParser blob@Blob{..} parser = case parser of
|
||||
ASTParser language ->
|
||||
time "parse.tree_sitter_ast_parse" languageTag $ do
|
||||
@ -228,7 +228,7 @@ runParser blob@Blob{..} parser = case parser of
|
||||
, Member (Reader Config) effs
|
||||
, Member Telemetry effs
|
||||
, Member Trace effs
|
||||
, Effects effs
|
||||
, PureEffects effs
|
||||
)
|
||||
=> (Source -> assignment (Term (Sum syntaxes) (Record Assignment.Location)) -> ast -> Either (Error.Error String) (Term (Sum syntaxes) (Record Assignment.Location)))
|
||||
-> Parser ast
|
||||
|
@ -139,13 +139,13 @@ instance Effect Telemetry where
|
||||
handleState c dist (Request (WriteLog level message pairs) k) = Request (WriteLog level message pairs) (dist . (<$ c) . k)
|
||||
|
||||
-- | Run a 'Telemetry' effect by expecting a 'Reader' of 'Queue's to write stats and logs to.
|
||||
runTelemetry :: (Member (Lift IO) effects, Effects effects) => LogQueue -> StatQueue -> Eff (Telemetry ': effects) a -> Eff effects a
|
||||
runTelemetry :: (Member (Lift IO) effects, PureEffects effects) => LogQueue -> StatQueue -> Eff (Telemetry ': effects) a -> Eff effects a
|
||||
runTelemetry logger statter = interpret (\ t -> case t of
|
||||
WriteStat stat -> queueStat statter stat
|
||||
WriteLog level message pairs -> queueLogMessage logger level message pairs)
|
||||
|
||||
-- | Run a 'Telemetry' effect by ignoring statting/logging.
|
||||
ignoreTelemetry :: Effects effs => Eff (Telemetry ': effs) a -> Eff effs a
|
||||
ignoreTelemetry :: PureEffects effs => Eff (Telemetry ': effs) a -> Eff effs a
|
||||
ignoreTelemetry = interpret (\ t -> case t of
|
||||
WriteStat{} -> pure ()
|
||||
WriteLog{} -> pure ())
|
||||
|
Loading…
Reference in New Issue
Block a user