{-# LANGUAGE FlexibleContexts #-}
module GHC.Unit.Finder (
FindResult(..),
InstalledFindResult(..),
FinderCache,
initFinderCache,
flushFinderCaches,
findImportedModule,
findPluginModule,
findExactModule,
findHomeModule,
findExposedPackageModule,
mkHomeModLocation,
mkHomeModLocation2,
mkHiOnlyModLocation,
mkHiPath,
mkObjPath,
addHomeModuleToFinder,
uncacheModule,
mkStubPaths,
findObjectLinkableMaybe,
findObjectLinkable,
) where
import GHC.Prelude
import GHC.Driver.Session
import GHC.Platform.Ways
import GHC.Builtin.Names ( gHC_PRIM )
import GHC.Unit.Types
import GHC.Unit.Module
import GHC.Unit.Home
import GHC.Unit.State
import GHC.Unit.Finder.Types
import GHC.Data.FastString
import GHC.Data.Maybe ( expectJust )
import qualified GHC.Data.ShortText as ST
import GHC.Utils.Misc
import GHC.Utils.Outputable as Outputable
import GHC.Utils.Panic
import GHC.Linker.Types
import Data.IORef
import System.Directory
import System.FilePath
import Control.Monad
import Data.Time
type FileExt = String
type BaseName = String
initFinderCache :: IO FinderCache
initFinderCache :: IO FinderCache
initFinderCache = IORef FinderCacheState -> FinderCache
FinderCache (IORef FinderCacheState -> FinderCache)
-> IO (IORef FinderCacheState) -> IO FinderCache
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FinderCacheState -> IO (IORef FinderCacheState)
forall a. a -> IO (IORef a)
newIORef FinderCacheState
forall a. InstalledModuleEnv a
emptyInstalledModuleEnv
flushFinderCaches :: FinderCache -> HomeUnit -> IO ()
flushFinderCaches :: FinderCache -> HomeUnit -> IO ()
flushFinderCaches (FinderCache IORef FinderCacheState
ref) HomeUnit
home_unit =
IORef FinderCacheState
-> (FinderCacheState -> (FinderCacheState, ())) -> IO ()
forall a b. IORef a -> (a -> (a, b)) -> IO b
atomicModifyIORef' IORef FinderCacheState
ref ((FinderCacheState -> (FinderCacheState, ())) -> IO ())
-> (FinderCacheState -> (FinderCacheState, ())) -> IO ()
forall a b. (a -> b) -> a -> b
$ \FinderCacheState
fm -> ((InstalledModule -> InstalledFindResult -> Bool)
-> FinderCacheState -> FinderCacheState
forall a.
(InstalledModule -> a -> Bool)
-> InstalledModuleEnv a -> InstalledModuleEnv a
filterInstalledModuleEnv InstalledModule -> InstalledFindResult -> Bool
is_ext FinderCacheState
fm, ())
where
is_ext :: InstalledModule -> InstalledFindResult -> Bool
is_ext InstalledModule
mod InstalledFindResult
_ = Bool -> Bool
not (HomeUnit -> InstalledModule -> Bool
forall u. GenHomeUnit u -> InstalledModule -> Bool
isHomeInstalledModule HomeUnit
home_unit InstalledModule
mod)
addToFinderCache :: FinderCache -> InstalledModule -> InstalledFindResult -> IO ()
addToFinderCache :: FinderCache -> InstalledModule -> InstalledFindResult -> IO ()
addToFinderCache (FinderCache IORef FinderCacheState
ref) InstalledModule
key InstalledFindResult
val =
IORef FinderCacheState
-> (FinderCacheState -> (FinderCacheState, ())) -> IO ()
forall a b. IORef a -> (a -> (a, b)) -> IO b
atomicModifyIORef' IORef FinderCacheState
ref ((FinderCacheState -> (FinderCacheState, ())) -> IO ())
-> (FinderCacheState -> (FinderCacheState, ())) -> IO ()
forall a b. (a -> b) -> a -> b
$ \FinderCacheState
c -> (FinderCacheState
-> InstalledModule -> InstalledFindResult -> FinderCacheState
forall a.
InstalledModuleEnv a
-> InstalledModule -> a -> InstalledModuleEnv a
extendInstalledModuleEnv FinderCacheState
c InstalledModule
key InstalledFindResult
val, ())
removeFromFinderCache :: FinderCache -> InstalledModule -> IO ()
removeFromFinderCache :: FinderCache -> InstalledModule -> IO ()
removeFromFinderCache (FinderCache IORef FinderCacheState
ref) InstalledModule
key =
IORef FinderCacheState
-> (FinderCacheState -> (FinderCacheState, ())) -> IO ()
forall a b. IORef a -> (a -> (a, b)) -> IO b
atomicModifyIORef' IORef FinderCacheState
ref ((FinderCacheState -> (FinderCacheState, ())) -> IO ())
-> (FinderCacheState -> (FinderCacheState, ())) -> IO ()
forall a b. (a -> b) -> a -> b
$ \FinderCacheState
c -> (FinderCacheState -> InstalledModule -> FinderCacheState
forall a.
InstalledModuleEnv a -> InstalledModule -> InstalledModuleEnv a
delInstalledModuleEnv FinderCacheState
c InstalledModule
key, ())
lookupFinderCache :: FinderCache -> InstalledModule -> IO (Maybe InstalledFindResult)
lookupFinderCache :: FinderCache -> InstalledModule -> IO (Maybe InstalledFindResult)
lookupFinderCache (FinderCache IORef FinderCacheState
ref) InstalledModule
key = do
FinderCacheState
c <- IORef FinderCacheState -> IO FinderCacheState
forall a. IORef a -> IO a
readIORef IORef FinderCacheState
ref
Maybe InstalledFindResult -> IO (Maybe InstalledFindResult)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe InstalledFindResult -> IO (Maybe InstalledFindResult))
-> Maybe InstalledFindResult -> IO (Maybe InstalledFindResult)
forall a b. (a -> b) -> a -> b
$! FinderCacheState -> InstalledModule -> Maybe InstalledFindResult
forall a. InstalledModuleEnv a -> InstalledModule -> Maybe a
lookupInstalledModuleEnv FinderCacheState
c InstalledModule
key
findImportedModule
:: FinderCache
-> UnitState
-> HomeUnit
-> DynFlags
-> ModuleName
-> Maybe FastString
-> IO FindResult
findImportedModule :: FinderCache
-> UnitState
-> HomeUnit
-> DynFlags
-> ModuleName
-> Maybe FastString
-> IO FindResult
findImportedModule FinderCache
fc UnitState
units HomeUnit
home_unit DynFlags
dflags ModuleName
mod_name Maybe FastString
mb_pkg =
case Maybe FastString
mb_pkg of
Maybe FastString
Nothing -> IO FindResult
unqual_import
Just FastString
pkg | FastString
pkg FastString -> FastString -> Bool
forall a. Eq a => a -> a -> Bool
== String -> FastString
fsLit String
"this" -> IO FindResult
home_import
| Bool
otherwise -> IO FindResult
pkg_import
where
home_import :: IO FindResult
home_import = FinderCache -> HomeUnit -> DynFlags -> ModuleName -> IO FindResult
findHomeModule FinderCache
fc HomeUnit
home_unit DynFlags
dflags ModuleName
mod_name
pkg_import :: IO FindResult
pkg_import = FinderCache
-> UnitState
-> DynFlags
-> ModuleName
-> Maybe FastString
-> IO FindResult
findExposedPackageModule FinderCache
fc UnitState
units DynFlags
dflags ModuleName
mod_name Maybe FastString
mb_pkg
unqual_import :: IO FindResult
unqual_import = IO FindResult
home_import
IO FindResult -> IO FindResult -> IO FindResult
forall (m :: * -> *).
Monad m =>
m FindResult -> m FindResult -> m FindResult
`orIfNotFound`
FinderCache
-> UnitState
-> DynFlags
-> ModuleName
-> Maybe FastString
-> IO FindResult
findExposedPackageModule FinderCache
fc UnitState
units DynFlags
dflags ModuleName
mod_name Maybe FastString
forall a. Maybe a
Nothing
findPluginModule :: FinderCache -> UnitState -> HomeUnit -> DynFlags -> ModuleName -> IO FindResult
findPluginModule :: FinderCache
-> UnitState -> HomeUnit -> DynFlags -> ModuleName -> IO FindResult
findPluginModule FinderCache
fc UnitState
units HomeUnit
home_unit DynFlags
dflags ModuleName
mod_name =
FinderCache -> HomeUnit -> DynFlags -> ModuleName -> IO FindResult
findHomeModule FinderCache
fc HomeUnit
home_unit DynFlags
dflags ModuleName
mod_name
IO FindResult -> IO FindResult -> IO FindResult
forall (m :: * -> *).
Monad m =>
m FindResult -> m FindResult -> m FindResult
`orIfNotFound`
FinderCache -> UnitState -> DynFlags -> ModuleName -> IO FindResult
findExposedPluginPackageModule FinderCache
fc UnitState
units DynFlags
dflags ModuleName
mod_name
findExactModule :: FinderCache -> DynFlags -> UnitState -> HomeUnit -> InstalledModule -> IO InstalledFindResult
findExactModule :: FinderCache
-> DynFlags
-> UnitState
-> HomeUnit
-> InstalledModule
-> IO InstalledFindResult
findExactModule FinderCache
fc DynFlags
dflags UnitState
unit_state HomeUnit
home_unit InstalledModule
mod = do
if HomeUnit -> InstalledModule -> Bool
forall u. GenHomeUnit u -> InstalledModule -> Bool
isHomeInstalledModule HomeUnit
home_unit InstalledModule
mod
then FinderCache
-> DynFlags -> HomeUnit -> ModuleName -> IO InstalledFindResult
findInstalledHomeModule FinderCache
fc DynFlags
dflags HomeUnit
home_unit (InstalledModule -> ModuleName
forall unit. GenModule unit -> ModuleName
moduleName InstalledModule
mod)
else FinderCache
-> UnitState
-> DynFlags
-> InstalledModule
-> IO InstalledFindResult
findPackageModule FinderCache
fc UnitState
unit_state DynFlags
dflags InstalledModule
mod
orIfNotFound :: Monad m => m FindResult -> m FindResult -> m FindResult
orIfNotFound :: m FindResult -> m FindResult -> m FindResult
orIfNotFound m FindResult
this m FindResult
or_this = do
FindResult
res <- m FindResult
this
case FindResult
res of
NotFound { fr_paths :: FindResult -> [String]
fr_paths = [String]
paths1, fr_mods_hidden :: FindResult -> [Unit]
fr_mods_hidden = [Unit]
mh1
, fr_pkgs_hidden :: FindResult -> [Unit]
fr_pkgs_hidden = [Unit]
ph1, fr_unusables :: FindResult -> [(Unit, UnusableUnitReason)]
fr_unusables = [(Unit, UnusableUnitReason)]
u1, fr_suggestions :: FindResult -> [ModuleSuggestion]
fr_suggestions = [ModuleSuggestion]
s1 }
-> do FindResult
res2 <- m FindResult
or_this
case FindResult
res2 of
NotFound { fr_paths :: FindResult -> [String]
fr_paths = [String]
paths2, fr_pkg :: FindResult -> Maybe Unit
fr_pkg = Maybe Unit
mb_pkg2, fr_mods_hidden :: FindResult -> [Unit]
fr_mods_hidden = [Unit]
mh2
, fr_pkgs_hidden :: FindResult -> [Unit]
fr_pkgs_hidden = [Unit]
ph2, fr_unusables :: FindResult -> [(Unit, UnusableUnitReason)]
fr_unusables = [(Unit, UnusableUnitReason)]
u2
, fr_suggestions :: FindResult -> [ModuleSuggestion]
fr_suggestions = [ModuleSuggestion]
s2 }
-> FindResult -> m FindResult
forall (m :: * -> *) a. Monad m => a -> m a
return (NotFound :: [String]
-> Maybe Unit
-> [Unit]
-> [Unit]
-> [(Unit, UnusableUnitReason)]
-> [ModuleSuggestion]
-> FindResult
NotFound { fr_paths :: [String]
fr_paths = [String]
paths1 [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String]
paths2
, fr_pkg :: Maybe Unit
fr_pkg = Maybe Unit
mb_pkg2
, fr_mods_hidden :: [Unit]
fr_mods_hidden = [Unit]
mh1 [Unit] -> [Unit] -> [Unit]
forall a. [a] -> [a] -> [a]
++ [Unit]
mh2
, fr_pkgs_hidden :: [Unit]
fr_pkgs_hidden = [Unit]
ph1 [Unit] -> [Unit] -> [Unit]
forall a. [a] -> [a] -> [a]
++ [Unit]
ph2
, fr_unusables :: [(Unit, UnusableUnitReason)]
fr_unusables = [(Unit, UnusableUnitReason)]
u1 [(Unit, UnusableUnitReason)]
-> [(Unit, UnusableUnitReason)] -> [(Unit, UnusableUnitReason)]
forall a. [a] -> [a] -> [a]
++ [(Unit, UnusableUnitReason)]
u2
, fr_suggestions :: [ModuleSuggestion]
fr_suggestions = [ModuleSuggestion]
s1 [ModuleSuggestion] -> [ModuleSuggestion] -> [ModuleSuggestion]
forall a. [a] -> [a] -> [a]
++ [ModuleSuggestion]
s2 })
FindResult
_other -> FindResult -> m FindResult
forall (m :: * -> *) a. Monad m => a -> m a
return FindResult
res2
FindResult
_other -> FindResult -> m FindResult
forall (m :: * -> *) a. Monad m => a -> m a
return FindResult
res
homeSearchCache :: FinderCache -> HomeUnit -> ModuleName -> IO InstalledFindResult -> IO InstalledFindResult
homeSearchCache :: FinderCache
-> HomeUnit
-> ModuleName
-> IO InstalledFindResult
-> IO InstalledFindResult
homeSearchCache FinderCache
fc HomeUnit
home_unit ModuleName
mod_name IO InstalledFindResult
do_this = do
let mod :: InstalledModule
mod = HomeUnit -> ModuleName -> InstalledModule
forall u. GenHomeUnit u -> ModuleName -> InstalledModule
mkHomeInstalledModule HomeUnit
home_unit ModuleName
mod_name
FinderCache
-> InstalledModule
-> IO InstalledFindResult
-> IO InstalledFindResult
modLocationCache FinderCache
fc InstalledModule
mod IO InstalledFindResult
do_this
findExposedPackageModule :: FinderCache -> UnitState -> DynFlags -> ModuleName -> Maybe FastString -> IO FindResult
findExposedPackageModule :: FinderCache
-> UnitState
-> DynFlags
-> ModuleName
-> Maybe FastString
-> IO FindResult
findExposedPackageModule FinderCache
fc UnitState
units DynFlags
dflags ModuleName
mod_name Maybe FastString
mb_pkg =
FinderCache -> DynFlags -> LookupResult -> IO FindResult
findLookupResult FinderCache
fc DynFlags
dflags
(LookupResult -> IO FindResult) -> LookupResult -> IO FindResult
forall a b. (a -> b) -> a -> b
$ UnitState -> ModuleName -> Maybe FastString -> LookupResult
lookupModuleWithSuggestions UnitState
units ModuleName
mod_name Maybe FastString
mb_pkg
findExposedPluginPackageModule :: FinderCache -> UnitState -> DynFlags -> ModuleName -> IO FindResult
findExposedPluginPackageModule :: FinderCache -> UnitState -> DynFlags -> ModuleName -> IO FindResult
findExposedPluginPackageModule FinderCache
fc UnitState
units DynFlags
dflags ModuleName
mod_name =
FinderCache -> DynFlags -> LookupResult -> IO FindResult
findLookupResult FinderCache
fc DynFlags
dflags
(LookupResult -> IO FindResult) -> LookupResult -> IO FindResult
forall a b. (a -> b) -> a -> b
$ UnitState -> ModuleName -> Maybe FastString -> LookupResult
lookupPluginModuleWithSuggestions UnitState
units ModuleName
mod_name Maybe FastString
forall a. Maybe a
Nothing
findLookupResult :: FinderCache -> DynFlags -> LookupResult -> IO FindResult
findLookupResult :: FinderCache -> DynFlags -> LookupResult -> IO FindResult
findLookupResult FinderCache
fc DynFlags
dflags LookupResult
r = case LookupResult
r of
LookupFound Module
m UnitInfo
pkg_conf -> do
let im :: InstalledModule
im = (InstalledModule, Maybe InstantiatedModule) -> InstalledModule
forall a b. (a, b) -> a
fst (Module -> (InstalledModule, Maybe InstantiatedModule)
getModuleInstantiation Module
m)
InstalledFindResult
r' <- FinderCache
-> DynFlags
-> InstalledModule
-> UnitInfo
-> IO InstalledFindResult
findPackageModule_ FinderCache
fc DynFlags
dflags InstalledModule
im UnitInfo
pkg_conf
case InstalledFindResult
r' of
InstalledFound ModLocation
loc InstalledModule
_ -> FindResult -> IO FindResult
forall (m :: * -> *) a. Monad m => a -> m a
return (ModLocation -> Module -> FindResult
Found ModLocation
loc Module
m)
InstalledNoPackage UnitId
_ -> FindResult -> IO FindResult
forall (m :: * -> *) a. Monad m => a -> m a
return (Unit -> FindResult
NoPackage (Module -> Unit
forall unit. GenModule unit -> unit
moduleUnit Module
m))
InstalledNotFound [String]
fp Maybe UnitId
_ -> FindResult -> IO FindResult
forall (m :: * -> *) a. Monad m => a -> m a
return (NotFound :: [String]
-> Maybe Unit
-> [Unit]
-> [Unit]
-> [(Unit, UnusableUnitReason)]
-> [ModuleSuggestion]
-> FindResult
NotFound{ fr_paths :: [String]
fr_paths = [String]
fp, fr_pkg :: Maybe Unit
fr_pkg = Unit -> Maybe Unit
forall a. a -> Maybe a
Just (Module -> Unit
forall unit. GenModule unit -> unit
moduleUnit Module
m)
, fr_pkgs_hidden :: [Unit]
fr_pkgs_hidden = []
, fr_mods_hidden :: [Unit]
fr_mods_hidden = []
, fr_unusables :: [(Unit, UnusableUnitReason)]
fr_unusables = []
, fr_suggestions :: [ModuleSuggestion]
fr_suggestions = []})
LookupMultiple [(Module, ModuleOrigin)]
rs ->
FindResult -> IO FindResult
forall (m :: * -> *) a. Monad m => a -> m a
return ([(Module, ModuleOrigin)] -> FindResult
FoundMultiple [(Module, ModuleOrigin)]
rs)
LookupHidden [(Module, ModuleOrigin)]
pkg_hiddens [(Module, ModuleOrigin)]
mod_hiddens ->
FindResult -> IO FindResult
forall (m :: * -> *) a. Monad m => a -> m a
return (NotFound :: [String]
-> Maybe Unit
-> [Unit]
-> [Unit]
-> [(Unit, UnusableUnitReason)]
-> [ModuleSuggestion]
-> FindResult
NotFound{ fr_paths :: [String]
fr_paths = [], fr_pkg :: Maybe Unit
fr_pkg = Maybe Unit
forall a. Maybe a
Nothing
, fr_pkgs_hidden :: [Unit]
fr_pkgs_hidden = ((Module, ModuleOrigin) -> Unit)
-> [(Module, ModuleOrigin)] -> [Unit]
forall a b. (a -> b) -> [a] -> [b]
map (Module -> Unit
forall unit. GenModule unit -> unit
moduleUnit(Module -> Unit)
-> ((Module, ModuleOrigin) -> Module)
-> (Module, ModuleOrigin)
-> Unit
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(Module, ModuleOrigin) -> Module
forall a b. (a, b) -> a
fst) [(Module, ModuleOrigin)]
pkg_hiddens
, fr_mods_hidden :: [Unit]
fr_mods_hidden = ((Module, ModuleOrigin) -> Unit)
-> [(Module, ModuleOrigin)] -> [Unit]
forall a b. (a -> b) -> [a] -> [b]
map (Module -> Unit
forall unit. GenModule unit -> unit
moduleUnit(Module -> Unit)
-> ((Module, ModuleOrigin) -> Module)
-> (Module, ModuleOrigin)
-> Unit
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(Module, ModuleOrigin) -> Module
forall a b. (a, b) -> a
fst) [(Module, ModuleOrigin)]
mod_hiddens
, fr_unusables :: [(Unit, UnusableUnitReason)]
fr_unusables = []
, fr_suggestions :: [ModuleSuggestion]
fr_suggestions = [] })
LookupUnusable [(Module, ModuleOrigin)]
unusable ->
let unusables' :: [(Unit, UnusableUnitReason)]
unusables' = ((Module, ModuleOrigin) -> (Unit, UnusableUnitReason))
-> [(Module, ModuleOrigin)] -> [(Unit, UnusableUnitReason)]
forall a b. (a -> b) -> [a] -> [b]
map (Module, ModuleOrigin) -> (Unit, UnusableUnitReason)
forall a. (GenModule a, ModuleOrigin) -> (a, UnusableUnitReason)
get_unusable [(Module, ModuleOrigin)]
unusable
get_unusable :: (GenModule a, ModuleOrigin) -> (a, UnusableUnitReason)
get_unusable (GenModule a
m, ModUnusable UnusableUnitReason
r) = (GenModule a -> a
forall unit. GenModule unit -> unit
moduleUnit GenModule a
m, UnusableUnitReason
r)
get_unusable (GenModule a
_, ModuleOrigin
r) =
String -> SDoc -> (a, UnusableUnitReason)
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"findLookupResult: unexpected origin" (ModuleOrigin -> SDoc
forall a. Outputable a => a -> SDoc
ppr ModuleOrigin
r)
in FindResult -> IO FindResult
forall (m :: * -> *) a. Monad m => a -> m a
return (NotFound :: [String]
-> Maybe Unit
-> [Unit]
-> [Unit]
-> [(Unit, UnusableUnitReason)]
-> [ModuleSuggestion]
-> FindResult
NotFound{ fr_paths :: [String]
fr_paths = [], fr_pkg :: Maybe Unit
fr_pkg = Maybe Unit
forall a. Maybe a
Nothing
, fr_pkgs_hidden :: [Unit]
fr_pkgs_hidden = []
, fr_mods_hidden :: [Unit]
fr_mods_hidden = []
, fr_unusables :: [(Unit, UnusableUnitReason)]
fr_unusables = [(Unit, UnusableUnitReason)]
unusables'
, fr_suggestions :: [ModuleSuggestion]
fr_suggestions = [] })
LookupNotFound [ModuleSuggestion]
suggest -> do
let suggest' :: [ModuleSuggestion]
suggest'
| GeneralFlag -> DynFlags -> Bool
gopt GeneralFlag
Opt_HelpfulErrors DynFlags
dflags = [ModuleSuggestion]
suggest
| Bool
otherwise = []
FindResult -> IO FindResult
forall (m :: * -> *) a. Monad m => a -> m a
return (NotFound :: [String]
-> Maybe Unit
-> [Unit]
-> [Unit]
-> [(Unit, UnusableUnitReason)]
-> [ModuleSuggestion]
-> FindResult
NotFound{ fr_paths :: [String]
fr_paths = [], fr_pkg :: Maybe Unit
fr_pkg = Maybe Unit
forall a. Maybe a
Nothing
, fr_pkgs_hidden :: [Unit]
fr_pkgs_hidden = []
, fr_mods_hidden :: [Unit]
fr_mods_hidden = []
, fr_unusables :: [(Unit, UnusableUnitReason)]
fr_unusables = []
, fr_suggestions :: [ModuleSuggestion]
fr_suggestions = [ModuleSuggestion]
suggest' })
modLocationCache :: FinderCache -> InstalledModule -> IO InstalledFindResult -> IO InstalledFindResult
modLocationCache :: FinderCache
-> InstalledModule
-> IO InstalledFindResult
-> IO InstalledFindResult
modLocationCache FinderCache
fc InstalledModule
mod IO InstalledFindResult
do_this = do
Maybe InstalledFindResult
m <- FinderCache -> InstalledModule -> IO (Maybe InstalledFindResult)
lookupFinderCache FinderCache
fc InstalledModule
mod
case Maybe InstalledFindResult
m of
Just InstalledFindResult
result -> InstalledFindResult -> IO InstalledFindResult
forall (m :: * -> *) a. Monad m => a -> m a
return InstalledFindResult
result
Maybe InstalledFindResult
Nothing -> do
InstalledFindResult
result <- IO InstalledFindResult
do_this
FinderCache -> InstalledModule -> InstalledFindResult -> IO ()
addToFinderCache FinderCache
fc InstalledModule
mod InstalledFindResult
result
InstalledFindResult -> IO InstalledFindResult
forall (m :: * -> *) a. Monad m => a -> m a
return InstalledFindResult
result
addHomeModuleToFinder :: FinderCache -> HomeUnit -> ModuleName -> ModLocation -> IO Module
addHomeModuleToFinder :: FinderCache -> HomeUnit -> ModuleName -> ModLocation -> IO Module
addHomeModuleToFinder FinderCache
fc HomeUnit
home_unit ModuleName
mod_name ModLocation
loc = do
let mod :: InstalledModule
mod = HomeUnit -> ModuleName -> InstalledModule
forall u. GenHomeUnit u -> ModuleName -> InstalledModule
mkHomeInstalledModule HomeUnit
home_unit ModuleName
mod_name
FinderCache -> InstalledModule -> InstalledFindResult -> IO ()
addToFinderCache FinderCache
fc InstalledModule
mod (ModLocation -> InstalledModule -> InstalledFindResult
InstalledFound ModLocation
loc InstalledModule
mod)
Module -> IO Module
forall (m :: * -> *) a. Monad m => a -> m a
return (HomeUnit -> ModuleName -> Module
mkHomeModule HomeUnit
home_unit ModuleName
mod_name)
uncacheModule :: FinderCache -> HomeUnit -> ModuleName -> IO ()
uncacheModule :: FinderCache -> HomeUnit -> ModuleName -> IO ()
uncacheModule FinderCache
fc HomeUnit
home_unit ModuleName
mod_name = do
let mod :: InstalledModule
mod = HomeUnit -> ModuleName -> InstalledModule
forall u. GenHomeUnit u -> ModuleName -> InstalledModule
mkHomeInstalledModule HomeUnit
home_unit ModuleName
mod_name
FinderCache -> InstalledModule -> IO ()
removeFromFinderCache FinderCache
fc InstalledModule
mod
findHomeModule :: FinderCache -> HomeUnit -> DynFlags -> ModuleName -> IO FindResult
findHomeModule :: FinderCache -> HomeUnit -> DynFlags -> ModuleName -> IO FindResult
findHomeModule FinderCache
fc HomeUnit
home_unit DynFlags
dflags ModuleName
mod_name = do
let uid :: Unit
uid = HomeUnit -> Unit
homeUnitAsUnit HomeUnit
home_unit
InstalledFindResult
r <- FinderCache
-> DynFlags -> HomeUnit -> ModuleName -> IO InstalledFindResult
findInstalledHomeModule FinderCache
fc DynFlags
dflags HomeUnit
home_unit ModuleName
mod_name
FindResult -> IO FindResult
forall (m :: * -> *) a. Monad m => a -> m a
return (FindResult -> IO FindResult) -> FindResult -> IO FindResult
forall a b. (a -> b) -> a -> b
$ case InstalledFindResult
r of
InstalledFound ModLocation
loc InstalledModule
_ -> ModLocation -> Module -> FindResult
Found ModLocation
loc (HomeUnit -> ModuleName -> Module
mkHomeModule HomeUnit
home_unit ModuleName
mod_name)
InstalledNoPackage UnitId
_ -> Unit -> FindResult
NoPackage Unit
uid
InstalledNotFound [String]
fps Maybe UnitId
_ -> NotFound :: [String]
-> Maybe Unit
-> [Unit]
-> [Unit]
-> [(Unit, UnusableUnitReason)]
-> [ModuleSuggestion]
-> FindResult
NotFound {
fr_paths :: [String]
fr_paths = [String]
fps,
fr_pkg :: Maybe Unit
fr_pkg = Unit -> Maybe Unit
forall a. a -> Maybe a
Just Unit
uid,
fr_mods_hidden :: [Unit]
fr_mods_hidden = [],
fr_pkgs_hidden :: [Unit]
fr_pkgs_hidden = [],
fr_unusables :: [(Unit, UnusableUnitReason)]
fr_unusables = [],
fr_suggestions :: [ModuleSuggestion]
fr_suggestions = []
}
findInstalledHomeModule :: FinderCache -> DynFlags -> HomeUnit -> ModuleName -> IO InstalledFindResult
findInstalledHomeModule :: FinderCache
-> DynFlags -> HomeUnit -> ModuleName -> IO InstalledFindResult
findInstalledHomeModule FinderCache
fc DynFlags
dflags HomeUnit
home_unit ModuleName
mod_name = do
FinderCache
-> HomeUnit
-> ModuleName
-> IO InstalledFindResult
-> IO InstalledFindResult
homeSearchCache FinderCache
fc HomeUnit
home_unit ModuleName
mod_name (IO InstalledFindResult -> IO InstalledFindResult)
-> IO InstalledFindResult -> IO InstalledFindResult
forall a b. (a -> b) -> a -> b
$
let
home_path :: [String]
home_path = DynFlags -> [String]
importPaths DynFlags
dflags
hisuf :: String
hisuf = DynFlags -> String
hiSuf DynFlags
dflags
mod :: InstalledModule
mod = HomeUnit -> ModuleName -> InstalledModule
forall u. GenHomeUnit u -> ModuleName -> InstalledModule
mkHomeInstalledModule HomeUnit
home_unit ModuleName
mod_name
source_exts :: [(String, String -> String -> IO ModLocation)]
source_exts =
[ (String
"hs", DynFlags
-> ModuleName -> String -> String -> String -> IO ModLocation
mkHomeModLocationSearched DynFlags
dflags ModuleName
mod_name String
"hs")
, (String
"lhs", DynFlags
-> ModuleName -> String -> String -> String -> IO ModLocation
mkHomeModLocationSearched DynFlags
dflags ModuleName
mod_name String
"lhs")
, (String
"hsig", DynFlags
-> ModuleName -> String -> String -> String -> IO ModLocation
mkHomeModLocationSearched DynFlags
dflags ModuleName
mod_name String
"hsig")
, (String
"lhsig", DynFlags
-> ModuleName -> String -> String -> String -> IO ModLocation
mkHomeModLocationSearched DynFlags
dflags ModuleName
mod_name String
"lhsig")
]
hi_exts :: [(String, String -> String -> IO ModLocation)]
hi_exts = [ (String
hisuf, DynFlags -> ModuleName -> String -> String -> IO ModLocation
mkHomeModHiOnlyLocation DynFlags
dflags ModuleName
mod_name)
, (String -> String
addBootSuffix String
hisuf, DynFlags -> ModuleName -> String -> String -> IO ModLocation
mkHomeModHiOnlyLocation DynFlags
dflags ModuleName
mod_name)
]
exts :: [(String, String -> String -> IO ModLocation)]
exts | GhcMode -> Bool
isOneShot (DynFlags -> GhcMode
ghcMode DynFlags
dflags) = [(String, String -> String -> IO ModLocation)]
hi_exts
| Bool
otherwise = [(String, String -> String -> IO ModLocation)]
source_exts
in
if InstalledModule
mod InstalledModule -> Module -> Bool
`installedModuleEq` Module
gHC_PRIM
then InstalledFindResult -> IO InstalledFindResult
forall (m :: * -> *) a. Monad m => a -> m a
return (ModLocation -> InstalledModule -> InstalledFindResult
InstalledFound (String -> ModLocation
forall a. HasCallStack => String -> a
error String
"GHC.Prim ModLocation") InstalledModule
mod)
else [String]
-> InstalledModule
-> [(String, String -> String -> IO ModLocation)]
-> IO InstalledFindResult
searchPathExts [String]
home_path InstalledModule
mod [(String, String -> String -> IO ModLocation)]
exts
findPackageModule :: FinderCache -> UnitState -> DynFlags -> InstalledModule -> IO InstalledFindResult
findPackageModule :: FinderCache
-> UnitState
-> DynFlags
-> InstalledModule
-> IO InstalledFindResult
findPackageModule FinderCache
fc UnitState
unit_state DynFlags
dflags InstalledModule
mod = do
let pkg_id :: UnitId
pkg_id = InstalledModule -> UnitId
forall unit. GenModule unit -> unit
moduleUnit InstalledModule
mod
case UnitState -> UnitId -> Maybe UnitInfo
lookupUnitId UnitState
unit_state UnitId
pkg_id of
Maybe UnitInfo
Nothing -> InstalledFindResult -> IO InstalledFindResult
forall (m :: * -> *) a. Monad m => a -> m a
return (UnitId -> InstalledFindResult
InstalledNoPackage UnitId
pkg_id)
Just UnitInfo
u -> FinderCache
-> DynFlags
-> InstalledModule
-> UnitInfo
-> IO InstalledFindResult
findPackageModule_ FinderCache
fc DynFlags
dflags InstalledModule
mod UnitInfo
u
findPackageModule_ :: FinderCache -> DynFlags -> InstalledModule -> UnitInfo -> IO InstalledFindResult
findPackageModule_ :: FinderCache
-> DynFlags
-> InstalledModule
-> UnitInfo
-> IO InstalledFindResult
findPackageModule_ FinderCache
fc DynFlags
dflags InstalledModule
mod UnitInfo
pkg_conf = do
Bool -> SDoc -> IO ()
forall (m :: * -> *).
(HasCallStack, Applicative m) =>
Bool -> SDoc -> m ()
massertPpr (InstalledModule -> UnitId
forall unit. GenModule unit -> unit
moduleUnit InstalledModule
mod UnitId -> UnitId -> Bool
forall a. Eq a => a -> a -> Bool
== UnitInfo -> UnitId
forall compid srcpkgid srcpkgname uid modulename mod.
GenericUnitInfo compid srcpkgid srcpkgname uid modulename mod
-> uid
unitId UnitInfo
pkg_conf)
(UnitId -> SDoc
forall a. Outputable a => a -> SDoc
ppr (InstalledModule -> UnitId
forall unit. GenModule unit -> unit
moduleUnit InstalledModule
mod) SDoc -> SDoc -> SDoc
<+> UnitId -> SDoc
forall a. Outputable a => a -> SDoc
ppr (UnitInfo -> UnitId
forall compid srcpkgid srcpkgname uid modulename mod.
GenericUnitInfo compid srcpkgid srcpkgname uid modulename mod
-> uid
unitId UnitInfo
pkg_conf))
FinderCache
-> InstalledModule
-> IO InstalledFindResult
-> IO InstalledFindResult
modLocationCache FinderCache
fc InstalledModule
mod (IO InstalledFindResult -> IO InstalledFindResult)
-> IO InstalledFindResult -> IO InstalledFindResult
forall a b. (a -> b) -> a -> b
$
if InstalledModule
mod InstalledModule -> Module -> Bool
`installedModuleEq` Module
gHC_PRIM
then InstalledFindResult -> IO InstalledFindResult
forall (m :: * -> *) a. Monad m => a -> m a
return (ModLocation -> InstalledModule -> InstalledFindResult
InstalledFound (String -> ModLocation
forall a. HasCallStack => String -> a
error String
"GHC.Prim ModLocation") InstalledModule
mod)
else
let
tag :: String
tag = Ways -> String
waysBuildTag (DynFlags -> Ways
ways DynFlags
dflags)
package_hisuf :: String
package_hisuf | String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
tag = String
"hi"
| Bool
otherwise = String
tag String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"_hi"
mk_hi_loc :: String -> String -> IO ModLocation
mk_hi_loc = DynFlags -> String -> String -> String -> IO ModLocation
mkHiOnlyModLocation DynFlags
dflags String
package_hisuf
import_dirs :: [String]
import_dirs = (ShortText -> String) -> [ShortText] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map ShortText -> String
ST.unpack ([ShortText] -> [String]) -> [ShortText] -> [String]
forall a b. (a -> b) -> a -> b
$ UnitInfo -> [ShortText]
forall compid srcpkgid srcpkgname uid modulename mod.
GenericUnitInfo compid srcpkgid srcpkgname uid modulename mod
-> [ShortText]
unitImportDirs UnitInfo
pkg_conf
in
case [String]
import_dirs of
[String
one] | GhcMode
MkDepend <- DynFlags -> GhcMode
ghcMode DynFlags
dflags -> do
let basename :: String
basename = ModuleName -> String
moduleNameSlashes (InstalledModule -> ModuleName
forall unit. GenModule unit -> ModuleName
moduleName InstalledModule
mod)
ModLocation
loc <- String -> String -> IO ModLocation
mk_hi_loc String
one String
basename
InstalledFindResult -> IO InstalledFindResult
forall (m :: * -> *) a. Monad m => a -> m a
return (ModLocation -> InstalledModule -> InstalledFindResult
InstalledFound ModLocation
loc InstalledModule
mod)
[String]
_otherwise ->
[String]
-> InstalledModule
-> [(String, String -> String -> IO ModLocation)]
-> IO InstalledFindResult
searchPathExts [String]
import_dirs InstalledModule
mod [(String
package_hisuf, String -> String -> IO ModLocation
mk_hi_loc)]
searchPathExts :: [FilePath]
-> InstalledModule
-> [ (
FileExt,
FilePath -> BaseName -> IO ModLocation
)
]
-> IO InstalledFindResult
searchPathExts :: [String]
-> InstalledModule
-> [(String, String -> String -> IO ModLocation)]
-> IO InstalledFindResult
searchPathExts [String]
paths InstalledModule
mod [(String, String -> String -> IO ModLocation)]
exts = [(String, IO ModLocation)] -> IO InstalledFindResult
search [(String, IO ModLocation)]
to_search
where
basename :: String
basename = ModuleName -> String
moduleNameSlashes (InstalledModule -> ModuleName
forall unit. GenModule unit -> ModuleName
moduleName InstalledModule
mod)
to_search :: [(FilePath, IO ModLocation)]
to_search :: [(String, IO ModLocation)]
to_search = [ (String
file, String -> String -> IO ModLocation
fn String
path String
basename)
| String
path <- [String]
paths,
(String
ext,String -> String -> IO ModLocation
fn) <- [(String, String -> String -> IO ModLocation)]
exts,
let base :: String
base | String
path String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"." = String
basename
| Bool
otherwise = String
path String -> String -> String
</> String
basename
file :: String
file = String
base String -> String -> String
<.> String
ext
]
search :: [(String, IO ModLocation)] -> IO InstalledFindResult
search [] = InstalledFindResult -> IO InstalledFindResult
forall (m :: * -> *) a. Monad m => a -> m a
return ([String] -> Maybe UnitId -> InstalledFindResult
InstalledNotFound (((String, IO ModLocation) -> String)
-> [(String, IO ModLocation)] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (String, IO ModLocation) -> String
forall a b. (a, b) -> a
fst [(String, IO ModLocation)]
to_search) (UnitId -> Maybe UnitId
forall a. a -> Maybe a
Just (InstalledModule -> UnitId
forall unit. GenModule unit -> unit
moduleUnit InstalledModule
mod)))
search ((String
file, IO ModLocation
mk_result) : [(String, IO ModLocation)]
rest) = do
Bool
b <- String -> IO Bool
doesFileExist String
file
if Bool
b
then do { ModLocation
loc <- IO ModLocation
mk_result; InstalledFindResult -> IO InstalledFindResult
forall (m :: * -> *) a. Monad m => a -> m a
return (ModLocation -> InstalledModule -> InstalledFindResult
InstalledFound ModLocation
loc InstalledModule
mod) }
else [(String, IO ModLocation)] -> IO InstalledFindResult
search [(String, IO ModLocation)]
rest
mkHomeModLocationSearched :: DynFlags -> ModuleName -> FileExt
-> FilePath -> BaseName -> IO ModLocation
mkHomeModLocationSearched :: DynFlags
-> ModuleName -> String -> String -> String -> IO ModLocation
mkHomeModLocationSearched DynFlags
dflags ModuleName
mod String
suff String
path String
basename =
DynFlags -> ModuleName -> String -> String -> IO ModLocation
mkHomeModLocation2 DynFlags
dflags ModuleName
mod (String
path String -> String -> String
</> String
basename) String
suff
mkHomeModLocation :: DynFlags -> ModuleName -> FilePath -> IO ModLocation
mkHomeModLocation :: DynFlags -> ModuleName -> String -> IO ModLocation
mkHomeModLocation DynFlags
dflags ModuleName
mod String
src_filename = do
let (String
basename,String
extension) = String -> (String, String)
splitExtension String
src_filename
DynFlags -> ModuleName -> String -> String -> IO ModLocation
mkHomeModLocation2 DynFlags
dflags ModuleName
mod String
basename String
extension
mkHomeModLocation2 :: DynFlags
-> ModuleName
-> FilePath
-> String
-> IO ModLocation
mkHomeModLocation2 :: DynFlags -> ModuleName -> String -> String -> IO ModLocation
mkHomeModLocation2 DynFlags
dflags ModuleName
mod String
src_basename String
ext = do
let mod_basename :: String
mod_basename = ModuleName -> String
moduleNameSlashes ModuleName
mod
obj_fn :: String
obj_fn = DynFlags -> String -> String -> String
mkObjPath DynFlags
dflags String
src_basename String
mod_basename
hi_fn :: String
hi_fn = DynFlags -> String -> String -> String
mkHiPath DynFlags
dflags String
src_basename String
mod_basename
hie_fn :: String
hie_fn = DynFlags -> String -> String -> String
mkHiePath DynFlags
dflags String
src_basename String
mod_basename
ModLocation -> IO ModLocation
forall (m :: * -> *) a. Monad m => a -> m a
return (ModLocation :: Maybe String -> String -> String -> String -> ModLocation
ModLocation{ ml_hs_file :: Maybe String
ml_hs_file = String -> Maybe String
forall a. a -> Maybe a
Just (String
src_basename String -> String -> String
<.> String
ext),
ml_hi_file :: String
ml_hi_file = String
hi_fn,
ml_obj_file :: String
ml_obj_file = String
obj_fn,
ml_hie_file :: String
ml_hie_file = String
hie_fn })
mkHomeModHiOnlyLocation :: DynFlags
-> ModuleName
-> FilePath
-> BaseName
-> IO ModLocation
mkHomeModHiOnlyLocation :: DynFlags -> ModuleName -> String -> String -> IO ModLocation
mkHomeModHiOnlyLocation DynFlags
dflags ModuleName
mod String
path String
basename = do
ModLocation
loc <- DynFlags -> ModuleName -> String -> String -> IO ModLocation
mkHomeModLocation2 DynFlags
dflags ModuleName
mod (String
path String -> String -> String
</> String
basename) String
""
ModLocation -> IO ModLocation
forall (m :: * -> *) a. Monad m => a -> m a
return ModLocation
loc { ml_hs_file :: Maybe String
ml_hs_file = Maybe String
forall a. Maybe a
Nothing }
mkHiOnlyModLocation :: DynFlags -> Suffix -> FilePath -> String
-> IO ModLocation
mkHiOnlyModLocation :: DynFlags -> String -> String -> String -> IO ModLocation
mkHiOnlyModLocation DynFlags
dflags String
hisuf String
path String
basename
= do let full_basename :: String
full_basename = String
path String -> String -> String
</> String
basename
obj_fn :: String
obj_fn = DynFlags -> String -> String -> String
mkObjPath DynFlags
dflags String
full_basename String
basename
hie_fn :: String
hie_fn = DynFlags -> String -> String -> String
mkHiePath DynFlags
dflags String
full_basename String
basename
ModLocation -> IO ModLocation
forall (m :: * -> *) a. Monad m => a -> m a
return ModLocation :: Maybe String -> String -> String -> String -> ModLocation
ModLocation{ ml_hs_file :: Maybe String
ml_hs_file = Maybe String
forall a. Maybe a
Nothing,
ml_hi_file :: String
ml_hi_file = String
full_basename String -> String -> String
<.> String
hisuf,
ml_obj_file :: String
ml_obj_file = String
obj_fn,
ml_hie_file :: String
ml_hie_file = String
hie_fn
}
mkObjPath
:: DynFlags
-> FilePath
-> String
-> FilePath
mkObjPath :: DynFlags -> String -> String -> String
mkObjPath DynFlags
dflags String
basename String
mod_basename = String
obj_basename String -> String -> String
<.> String
osuf
where
odir :: Maybe String
odir = DynFlags -> Maybe String
objectDir DynFlags
dflags
osuf :: String
osuf = DynFlags -> String
objectSuf DynFlags
dflags
obj_basename :: String
obj_basename | Just String
dir <- Maybe String
odir = String
dir String -> String -> String
</> String
mod_basename
| Bool
otherwise = String
basename
mkHiPath
:: DynFlags
-> FilePath
-> String
-> FilePath
mkHiPath :: DynFlags -> String -> String -> String
mkHiPath DynFlags
dflags String
basename String
mod_basename = String
hi_basename String -> String -> String
<.> String
hisuf
where
hidir :: Maybe String
hidir = DynFlags -> Maybe String
hiDir DynFlags
dflags
hisuf :: String
hisuf = DynFlags -> String
hiSuf DynFlags
dflags
hi_basename :: String
hi_basename | Just String
dir <- Maybe String
hidir = String
dir String -> String -> String
</> String
mod_basename
| Bool
otherwise = String
basename
mkHiePath
:: DynFlags
-> FilePath
-> String
-> FilePath
mkHiePath :: DynFlags -> String -> String -> String
mkHiePath DynFlags
dflags String
basename String
mod_basename = String
hie_basename String -> String -> String
<.> String
hiesuf
where
hiedir :: Maybe String
hiedir = DynFlags -> Maybe String
hieDir DynFlags
dflags
hiesuf :: String
hiesuf = DynFlags -> String
hieSuf DynFlags
dflags
hie_basename :: String
hie_basename | Just String
dir <- Maybe String
hiedir = String
dir String -> String -> String
</> String
mod_basename
| Bool
otherwise = String
basename
mkStubPaths
:: DynFlags
-> ModuleName
-> ModLocation
-> FilePath
mkStubPaths :: DynFlags -> ModuleName -> ModLocation -> String
mkStubPaths DynFlags
dflags ModuleName
mod ModLocation
location
= let
stubdir :: Maybe String
stubdir = DynFlags -> Maybe String
stubDir DynFlags
dflags
mod_basename :: String
mod_basename = ModuleName -> String
moduleNameSlashes ModuleName
mod
src_basename :: String
src_basename = String -> String
dropExtension (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ String -> Maybe String -> String
forall a. HasCallStack => String -> Maybe a -> a
expectJust String
"mkStubPaths"
(ModLocation -> Maybe String
ml_hs_file ModLocation
location)
stub_basename0 :: String
stub_basename0
| Just String
dir <- Maybe String
stubdir = String
dir String -> String -> String
</> String
mod_basename
| Bool
otherwise = String
src_basename
stub_basename :: String
stub_basename = String
stub_basename0 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"_stub"
in
String
stub_basename String -> String -> String
<.> String
"h"
findObjectLinkableMaybe :: Module -> ModLocation -> IO (Maybe Linkable)
findObjectLinkableMaybe :: Module -> ModLocation -> IO (Maybe Linkable)
findObjectLinkableMaybe Module
mod ModLocation
locn
= do let obj_fn :: String
obj_fn = ModLocation -> String
ml_obj_file ModLocation
locn
Maybe UTCTime
maybe_obj_time <- String -> IO (Maybe UTCTime)
modificationTimeIfExists String
obj_fn
case Maybe UTCTime
maybe_obj_time of
Maybe UTCTime
Nothing -> Maybe Linkable -> IO (Maybe Linkable)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Linkable
forall a. Maybe a
Nothing
Just UTCTime
obj_time -> (Linkable -> Maybe Linkable) -> IO Linkable -> IO (Maybe Linkable)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Linkable -> Maybe Linkable
forall a. a -> Maybe a
Just (Module -> String -> UTCTime -> IO Linkable
findObjectLinkable Module
mod String
obj_fn UTCTime
obj_time)
findObjectLinkable :: Module -> FilePath -> UTCTime -> IO Linkable
findObjectLinkable :: Module -> String -> UTCTime -> IO Linkable
findObjectLinkable Module
mod String
obj_fn UTCTime
obj_time = Linkable -> IO Linkable
forall (m :: * -> *) a. Monad m => a -> m a
return (UTCTime -> Module -> [Unlinked] -> Linkable
LM UTCTime
obj_time Module
mod [String -> Unlinked
DotO String
obj_fn])