1{-# LANGUAGE DeriveGeneric #-}
2{-# LANGUAGE TemplateHaskell #-}
4module Language.Nix.FilePath where
11import Distribution.Compat.ReadP as ReadP
12import Distribution.Text
13import GHC.Generics (Generic)
14import Prelude hiding (FilePath)
15import qualified System.FilePath.Posix as Posix
16import Test.QuickCheck as QC
17import Text.PrettyPrint as PP
20newtype FilePath = FilePath { unFilePath :: String }
21 deriving (Show, Eq, Ord, Generic)
25instance NFData FilePath where
26 rnf = rnf . unFilePath
28instance Arbitrary FilePath where
29 arbitrary = FilePath <$> QC.suchThat arbitrary Posix.isValid
30 shrink = fmap FilePath . shrink . unFilePath
32instance Text FilePath where
33 disp = text . renderFilePath
36instance IsString FilePath where
37 fromString s = fromMaybe (error $ "invalid Nix file path:" ++ s) (simpleParse s)
39parseFilePath :: ReadP r FilePath
41 path <- ReadP.munch (const True)
43 then pure (FilePath path)
46renderFilePath :: FilePath -> String
47renderFilePath = Posix.combine "." . Posix.normalise . unFilePath
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