mirror of
https://github.com/github/semantic.git
synced 2024-12-19 12:51:52 +03:00
Define helpers to run actions with locally-updated ModuleInfo/PackageInfo.
This commit is contained in:
parent
2aae3dbdd3
commit
81f4d99688
@ -2,7 +2,9 @@ module Control.Abstract.Context
|
||||
( ModuleInfo
|
||||
, PackageInfo
|
||||
, currentModule
|
||||
, withCurrentModule
|
||||
, currentPackage
|
||||
, withCurrentPackage
|
||||
) where
|
||||
|
||||
import Control.Effect
|
||||
@ -15,6 +17,14 @@ import Prologue
|
||||
currentModule :: (Effectful m, Member (Reader ModuleInfo) effects) => m effects ModuleInfo
|
||||
currentModule = raise ask
|
||||
|
||||
-- | Run an action with a locally-replaced 'ModuleInfo'.
|
||||
withCurrentModule :: (Effectful m, Member (Reader ModuleInfo) effects) => ModuleInfo -> m effects a -> m effects a
|
||||
withCurrentModule = raiseHandler . local . const
|
||||
|
||||
-- | Get the currently evaluating 'PackageInfo'.
|
||||
currentPackage :: (Effectful m, Member (Reader PackageInfo) effects) => m effects PackageInfo
|
||||
currentPackage = raise ask
|
||||
|
||||
-- | Run an action with a locally-replaced 'PackageInfo'.
|
||||
withCurrentPackage :: (Effectful m, Member (Reader PackageInfo) effects) => PackageInfo -> m effects a -> m effects a
|
||||
withCurrentPackage = raiseHandler . local . const
|
||||
|
Loading…
Reference in New Issue
Block a user