1{-# LANGUAGE PatternGuards #-}
2module Language.Nix.Path ( Path, mkPath, path ) where
5import Distribution.Nixpkgs.Util.PrettyPrinting ( Pretty(..), punctuate, hcat, char )
6import Language.Nix.Identifier
8-- | Paths are non-empty lists of identifiers in Nix.
10newtype Path = Path { _segments :: [Identifier] }
11 deriving (Show, Eq, Ord)
13mkPath :: [Identifier] -> Path
14mkPath [] = error "Nix paths cannot be empty"
16 | [Identifier s] <- p, needsQuoting s = error ("invalid Nix path: " ++ show p)
19path :: Lens' Path [Identifier]
20path f (Path ids) = mkPath `fmap` f ids
22instance Pretty Path where
23 pPrint p = hcat $ punctuate (char '.') $ pPrint <$> p^.path
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list