1{-# LANGUAGE PatternGuards #-}
2module Language.Nix.Path ( Path, mkPath, path ) where
5import Control.Applicative
6import Distribution.Nixpkgs.Util.PrettyPrinting ( Pretty(..), punctuate, hcat, char )
7import Language.Nix.Identifier
9-- | Paths are non-empty lists of identifiers in Nix.
11newtype Path = Path { _segments :: [Identifier] }
12 deriving (Show, Eq, Ord)
14mkPath :: [Identifier] -> Path
15mkPath [] = error "Nix paths cannot be empty"
17 | [Identifier s] <- p, needsQuoting s = error ("invalid Nix path: " ++ show p)
20path :: Lens' Path [Identifier]
21path f (Path ids) = mkPath `fmap` f ids
23instance Pretty Path where
24 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