1
1
mirror of https://github.com/github/semantic.git synced 2024-12-20 21:31:48 +03:00

Add helper function to get the path of the current module

This commit is contained in:
Timothy Clem 2018-03-29 14:07:42 -07:00
parent 4b751034a5
commit edc2d02559

View File

@ -1,6 +1,7 @@
{-# LANGUAGE ConstrainedClassMethods, DataKinds, FunctionalDependencies, TypeFamilies, UndecidableInstances #-} {-# LANGUAGE ConstrainedClassMethods, DataKinds, FunctionalDependencies, TypeFamilies, UndecidableInstances #-}
module Control.Abstract.Evaluator module Control.Abstract.Evaluator
( MonadEvaluator(..) ( MonadEvaluator(..)
, currentModuleFilePath
, MonadEnvironment(..) , MonadEnvironment(..)
, modifyEnv , modifyEnv
, modifyExports , modifyExports
@ -60,6 +61,9 @@ class ( MonadControl term m
-- With great power comes great responsibility. If you 'evaluateModule' any of these, you probably deserve what you get. -- With great power comes great responsibility. If you 'evaluateModule' any of these, you probably deserve what you get.
askModuleStack :: m [Module term] askModuleStack :: m [Module term]
-- | Get the path of the current module.
currentModuleFilePath :: (MonadEvaluator term value m) => m FilePath
currentModuleFilePath = modulePath . head <$> askModuleStack
-- | A 'Monad' abstracting local and global environments. -- | A 'Monad' abstracting local and global environments.
class Monad m => MonadEnvironment value m | m -> value where class Monad m => MonadEnvironment value m | m -> value where