Skip to content

Commit 9f25658

Browse files
committed
Effects: class MonadEffects: (make -> to)AbsolutePath
Since function does not construct a path, it takes a path & checks-converts it to be absolute path.
1 parent 6ce83f9 commit 9f25658

File tree

6 files changed

+18
-19
lines changed

6 files changed

+18
-19
lines changed

src/Nix/Effects.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,11 @@ class
6161
)
6262
=> MonadEffects t f m where
6363

64-
-- | Determine the absolute path of relative path in the current context
65-
makeAbsolutePath :: Path -> m Path
64+
-- | Determine the absolute path in the current context.
65+
toAbsolutePath :: Path -> m Path
6666
findEnvPath :: String -> m Path
6767

68-
-- | Having an explicit list of sets corresponding to the NIX_PATH
69-
-- and a file path try to find an existing path
68+
-- | Having an explicit list of sets corresponding to the @NIX_PATH@ and a file path try to find an existing path.
7069
findPath :: [NValue t f m] -> Path -> m Path
7170

7271
importPath :: Path -> m (NValue t f m)

src/Nix/Effects/Basic.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ import Nix.Value.Monad
3434
import GHC.DataSize
3535
#endif
3636

37-
defaultMakeAbsolutePath :: MonadNix e t f m => Path -> m Path
38-
defaultMakeAbsolutePath origPath = do
37+
defaultToAbsolutePath :: MonadNix e t f m => Path -> m Path
38+
defaultToAbsolutePath origPath = do
3939
origPathExpanded <- expandHomePath origPath
4040
absPath <-
4141
bool
@@ -102,12 +102,12 @@ findEnvPathM name = do
102102
where
103103
nixFilePath :: MonadEffects t f m => Path -> m (Maybe Path)
104104
nixFilePath path = do
105-
absPath <- makeAbsolutePath @t @f path
105+
absPath <- toAbsolutePath @t @f path
106106
isDir <- doesDirectoryExist absPath
107107
absFile <-
108108
bool
109109
(pure absPath)
110-
(makeAbsolutePath @t @f $ coerce $ (coerce absPath) </> "default.nix")
110+
(toAbsolutePath @t @f $ coerce $ (coerce absPath) </> "default.nix")
111111
isDir
112112
exists <- doesFileExist absFile
113113
pure $
@@ -232,7 +232,7 @@ findPathM = findPathBy existingPath
232232
existingPath :: MonadEffects t f m => Path -> m (Maybe Path)
233233
existingPath path =
234234
do
235-
apath <- makeAbsolutePath @t @f path
235+
apath <- toAbsolutePath @t @f path
236236
doesExist <- doesPathExist apath
237237
pure $ pure apath `whenTrue` doesExist
238238

src/Nix/Exec.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ instance MonadNix e t f m => MonadEval (NValue t f m) m where
212212
scope <- currentScopes
213213
span <- currentPos
214214
nvPathP (Provenance scope $ NLiteralPathAnnF span p) <$>
215-
makeAbsolutePath @t @f @m p
215+
toAbsolutePath @t @f @m p
216216

217217
evalEnvPath p = do
218218
scope <- currentScopes
@@ -422,10 +422,10 @@ execBinaryOpForced scope span op lval rval = case op of
422422
(throwError $ ErrorCall "A string that refers to a store path cannot be appended to a path.") -- data/nix/src/libexpr/eval.cc:1412
423423
(\ rs2 ->
424424
nvPathP prov <$>
425-
makeAbsolutePath @t @f (ls <> (coerce $ toString rs2))
425+
toAbsolutePath @t @f (ls <> (coerce $ toString rs2))
426426
)
427427
(getStringNoContext rs)
428-
(NVPath ls, NVPath rs) -> nvPathP prov <$> makeAbsolutePath @t @f (ls <> rs)
428+
(NVPath ls, NVPath rs) -> nvPathP prov <$> toAbsolutePath @t @f (ls <> rs)
429429

430430
(ls@NVSet{}, NVStr rs) ->
431431
(\ls2 -> nvStrP prov (ls2 <> rs)) <$>

src/Nix/Frames.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ import Nix.Utils ( Has(..)
3030
)
3131

3232
data NixLevel = Fatal | Error | Warning | Info | Debug
33-
deriving (Ord, Eq, Bounded, Enum, Show)
33+
deriving (Ord, Eq, Bounded, Enum, Show)
3434

3535
data NixFrame = NixFrame
36-
{ frameLevel :: NixLevel
37-
, frame :: SomeException
38-
}
36+
{ frameLevel :: NixLevel
37+
, frame :: SomeException
38+
}
3939

4040
instance Show NixFrame where
4141
show (NixFrame level f) =
@@ -46,7 +46,7 @@ type Frames = [NixFrame]
4646
type Framed e m = (MonadReader e m, Has e Frames, MonadThrow m)
4747

4848
newtype NixException = NixException Frames
49-
deriving Show
49+
deriving Show
5050

5151
instance Exception NixException
5252

src/Nix/Fresh/Basic.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ instance MonadExec m => MonadExec (StdIdT m)
2929

3030
instance (MonadEffects t f m, MonadDataContext f m)
3131
=> MonadEffects t f (StdIdT m) where
32-
makeAbsolutePath = lift . makeAbsolutePath @t @f @m
32+
toAbsolutePath = lift . toAbsolutePath @t @f @m
3333
findEnvPath = lift . findEnvPath @t @f @m
3434
findPath vs path = do
3535
i <- FreshIdT ask

src/Nix/Standard.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ instance
106106
, MonadValue (StdValue m) m
107107
)
108108
=> MonadEffects (StdThunk m) (StdCited m) m where
109-
makeAbsolutePath = defaultMakeAbsolutePath
109+
toAbsolutePath = defaultToAbsolutePath
110110
findEnvPath = defaultFindEnvPath
111111
findPath = defaultFindPath
112112
importPath = defaultImportPath

0 commit comments

Comments
 (0)