| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Language.Nix.Identifier
- data Identifier
- ident :: Iso' Identifier String
- quote :: String -> String
- needsQuoting :: String -> Bool
Documentation
Identifiers in Nix are essentially strings. They can be constructed
(and viewed) with the ident isomorphism. For the sake of convenience,
Identifiers are an instance of the IsString class.
Reasonable people restrict themselves to identifiers of the form
[a-zA-Z_][a-zA-Z0-9_'-]*, because these don't need quoting. The
methods of the Pretty class can be used to pretty-print an identifier
with proper quoting:
>>>pPrint (ident # "test")test>>>pPrint (ident # "foo.bar")"foo.bar"
data Identifier Source
An isomorphism that allows conversion of Identifier from/to the
standard String type via review.
\str -> fromString str == ident # str
\str -> set ident str undefined == ident # str
\str -> view ident (review ident str) == str
Helper function to quote a given identifier string if necessary.
>>>putStrLn (quote "abc")abc>>>putStrLn (quote "abc.def")"abc.def"
Checks whether a given string needs quoting when interpreted as an
Identifier.
needsQuoting :: String -> Bool Source