language-nix-2: Data types and useful functions to represent and manipulate the Nix language.

Safe HaskellNone
LanguageHaskell2010

Language.Nix.Path

Synopsis

Documentation

data Path Source

Paths are non-empty lists of identifiers in Nix.

>>> path # [ident # "yo"]
Path [Identifier "yo"]

Any attempt to construct the empty path throws an error:

>>> path # []
Path *** Exception: Nix paths cannot be empty

Identifier is an instance of IsString:

>>> :set -XOverloadedStrings
>>> pPrint $ path # ["yo","bar"]
yo.bar

Freaky quoted identifiers are fine except in the first segment:

>>> pPrint $ path # ["yo","b\"ar"]
yo."b\"ar"
>>> pPrint $ path # ["5ident"]
*** Exception: invalid Nix path: [Identifier "5ident"]
>>> pPrint $ path # ["5ident","foo","bar"]
*** Exception: invalid Nix path: [Identifier "5ident",Identifier "foo",Identifier "bar"]