mirror of
https://github.com/github/semantic.git
synced 2024-12-26 08:25:19 +03:00
Rename the linker* family of functions.
This commit is contained in:
parent
37fcc4826b
commit
f96136918a
@ -84,7 +84,7 @@ require :: ( FreeVariables term
|
||||
)
|
||||
=> term
|
||||
-> m v
|
||||
require term = getModuleTable >>= maybe (load term) pure . linkerLookup name
|
||||
require term = getModuleTable >>= maybe (load term) pure . moduleTableLookup name
|
||||
where name = moduleName term
|
||||
|
||||
-- | Load another term/file and return an Effect.
|
||||
@ -96,7 +96,7 @@ load :: ( FreeVariables term
|
||||
)
|
||||
=> term
|
||||
-> m v
|
||||
load term = askModuleTable >>= maybe notFound evalAndCache . linkerLookup name
|
||||
load term = askModuleTable >>= maybe notFound evalAndCache . moduleTableLookup name
|
||||
where name = moduleName term
|
||||
notFound = fail ("cannot find " <> show name)
|
||||
evalAndCache e = do
|
||||
|
@ -1,16 +1,19 @@
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||
module Data.Abstract.ModuleTable where
|
||||
module Data.Abstract.ModuleTable
|
||||
( ModuleTable (..)
|
||||
, moduleTableLookup
|
||||
, moduleTableInsert
|
||||
)where
|
||||
|
||||
import Data.Semigroup
|
||||
import GHC.Generics
|
||||
import qualified Data.Map as Map
|
||||
|
||||
|
||||
newtype ModuleTable a = ModuleTable { unModuleTable :: Map.Map FilePath a }
|
||||
deriving (Eq, Foldable, Functor, Generic1, Monoid, Ord, Semigroup, Show, Traversable)
|
||||
|
||||
linkerLookup :: FilePath -> ModuleTable a -> Maybe a
|
||||
linkerLookup k = Map.lookup k . unModuleTable
|
||||
moduleTableLookup :: FilePath -> ModuleTable a -> Maybe a
|
||||
moduleTableLookup k = Map.lookup k . unModuleTable
|
||||
|
||||
linkerInsert :: FilePath -> a -> ModuleTable a -> ModuleTable a
|
||||
linkerInsert k v ModuleTable{..} = ModuleTable (Map.insert k v unModuleTable)
|
||||
moduleTableInsert :: FilePath -> a -> ModuleTable a -> ModuleTable a
|
||||
moduleTableInsert k v ModuleTable{..} = ModuleTable (Map.insert k v unModuleTable)
|
||||
|
Loading…
Reference in New Issue
Block a user