-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Data types and useful functions to represent and manipulate the Nix language.
--   
--   Data types and useful functions to represent and manipulate the Nix
--   language.
@package language-nix
@version 2.1.0.1

module Language.Nix.Identifier

-- | Identifiers in Nix are essentially strings. They can be constructed
--   (and viewed) with the <a>ident</a> isomorphism. For the sake of
--   convenience, <tt>Identifier</tt>s are an instance of the
--   <a>IsString</a> class.
--   
--   Reasonable people restrict themselves to identifiers of the form
--   <tt>[a-zA-Z_][a-zA-Z0-9_'-]*</tt>, because these don't need quoting.
--   The methods of the <a>Text</a> class can be used to parse and
--   pretty-print an identifier with proper quoting:
--   
--   <pre>
--   &gt;&gt;&gt; disp (ident # "test")
--   test
--   
--   &gt;&gt;&gt; disp (ident # "foo.bar")
--   "foo.bar"
--   </pre>
--   
--   <pre>
--   \str -&gt; Just (ident # str) == simpleParse (quote str)
--   </pre>
--   
--   <pre>
--   \i -&gt; Just (i :: Identifier) == simpleParse (display i)
--   </pre>
data Identifier

-- | An isomorphism that allows conversion of <a>Identifier</a> from/to the
--   standard <a>String</a> type via <a>review</a>.
--   
--   <pre>
--   \str -&gt; fromString str == ident # str
--   </pre>
--   
--   <pre>
--   \str -&gt; set ident str undefined == ident # str
--   </pre>
--   
--   <pre>
--   \str -&gt; view ident (review ident str) == str
--   </pre>
ident :: Iso' Identifier String

-- | Helper function to quote a given identifier string if necessary.
--   
--   <pre>
--   &gt;&gt;&gt; putStrLn (quote "abc")
--   abc
--   
--   &gt;&gt;&gt; putStrLn (quote "abc.def")
--   "abc.def"
--   </pre>
quote :: String -> String

-- | Checks whether a given string needs quoting when interpreted as an
--   <a>Identifier</a>. Simple identifiers that don't need quoting match
--   the regular expression <tt>^[a-zA-Z_][a-zA-Z0-9_'-]*$</tt>.
needsQuoting :: String -> Bool

-- | <a>ReadP</a> parser for simple identifiers, i.e. those that don't need
--   quoting.
parseSimpleIdentifier :: ReadP r Identifier

-- | <a>ReadP</a> parser for quoted identifiers, i.e. those that <i>do</i>
--   need quoting.
parseQuotedIdentifier :: ReadP r Identifier
instance GHC.Generics.Generic Language.Nix.Identifier.Identifier
instance Data.String.IsString Language.Nix.Identifier.Identifier
instance GHC.Classes.Ord Language.Nix.Identifier.Identifier
instance GHC.Classes.Eq Language.Nix.Identifier.Identifier
instance GHC.Show.Show Language.Nix.Identifier.Identifier
instance Control.DeepSeq.NFData Language.Nix.Identifier.Identifier
instance Test.QuickCheck.Arbitrary.Arbitrary Language.Nix.Identifier.Identifier
instance Distribution.Text.Text Language.Nix.Identifier.Identifier

module Language.Nix.Path

-- | Paths are non-empty lists of identifiers in Nix.
--   
--   <pre>
--   &gt;&gt;&gt; path # [ident # "yo"]
--   Path [Identifier "yo"]
--   </pre>
--   
--   Any attempt to construct the empty path throws an <a>error</a>:
--   
--   <pre>
--   &gt;&gt;&gt; :set -XScopedTypeVariables
--   
--   &gt;&gt;&gt; either (\(_::SomeException) -&gt; "empty paths are illegal") show &lt;$&gt; try (evaluate (path # []))
--   "empty paths are illegal"
--   </pre>
--   
--   Paths can be pretty-printed and parsed with the <a>Text</a> class:
--   
--   <pre>
--   &gt;&gt;&gt; simpleParse "foo.\"foo.bar\".bar" :: Maybe Path
--   Just (Path [Identifier "foo",Identifier "foo.bar",Identifier "bar"])
--   
--   &gt;&gt;&gt; maybe empty disp (simpleParse "foo.\"foo\".\"bar\".bar" :: Maybe Path)
--   foo.foo.bar.bar
--   </pre>
--   
--   <pre>
--   \p -&gt; Just (p :: Path) == simpleParse (display p)
--   </pre>
--   
--   Paths are instances of strings and can be implicitly converted:
--   
--   <pre>
--   &gt;&gt;&gt; :set -XOverloadedStrings
--   
--   &gt;&gt;&gt; disp $ ("yo.bar" :: Path)
--   yo.bar
--   
--   &gt;&gt;&gt; disp $ ("  yo  .  bar  " :: Path)
--   yo.bar
--   </pre>
--   
--   Freaky quoted identifiers are fine throughout:
--   
--   <pre>
--   &gt;&gt;&gt; disp $ path # ["yo","b\"ar"]
--   yo."b\"ar"
--   
--   &gt;&gt;&gt; disp ("\"5ident\"" :: Path)
--   "5ident"
--   
--   &gt;&gt;&gt; disp $ path # ["5ident","foo.bar","foo\nbar"]
--   "5ident"."foo.bar"."foo\nbar"
--   </pre>
data Path

-- | Use this isomorphism to construct a path from a list of identifiers,
--   or to access that list for a given path.
path :: Iso' Path [Identifier]
instance GHC.Generics.Generic Language.Nix.Path.Path
instance GHC.Classes.Ord Language.Nix.Path.Path
instance GHC.Classes.Eq Language.Nix.Path.Path
instance GHC.Show.Show Language.Nix.Path.Path
instance Control.DeepSeq.NFData Language.Nix.Path.Path
instance Distribution.Text.Text Language.Nix.Path.Path
instance Data.String.IsString Language.Nix.Path.Path
instance Test.QuickCheck.Arbitrary.Arbitrary Language.Nix.Path.Path

module Language.Nix.Binding

-- | A <a>Binding</a> represents an identifier that refers to some other
--   <a>Path</a>.
--   
--   <pre>
--   &gt;&gt;&gt; :set -XOverloadedStrings
--   
--   &gt;&gt;&gt; "inherit (foo.bar) abc" :: Binding
--   Bind (Identifier "abc") (Path [Identifier "foo",Identifier "bar",Identifier "abc"])
--   </pre>
--   
--   <pre>
--   \b -&gt; Just (b :: Binding) == simpleParse (display b)
--   </pre>
data Binding
binding :: Iso' Binding (Identifier, Path)
localName :: Lens' Binding Identifier
reference :: Lens' Binding Path
instance GHC.Generics.Generic Language.Nix.Binding.Binding
instance GHC.Classes.Ord Language.Nix.Binding.Binding
instance GHC.Classes.Eq Language.Nix.Binding.Binding
instance GHC.Show.Show Language.Nix.Binding.Binding
instance Control.DeepSeq.NFData Language.Nix.Binding.Binding
instance Test.QuickCheck.Arbitrary.Arbitrary Language.Nix.Binding.Binding
instance Distribution.Text.Text Language.Nix.Binding.Binding
instance Data.String.IsString Language.Nix.Binding.Binding

module Language.Nix
