Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
The Nix expression type and supporting types.
Brief introduction of the Nix expression language.
This module is a beginning of a deep embedding (term) of a Nix language into Haskell. Brief on shallow & deep embedding.
(additiona info for dev): Big use of TemplateHaskell in the module requires proper (top-down) organization of declarations.
Synopsis
- data Params r
- data Variadic
- type ParamSet r = [(VarName, Maybe r)]
- newtype VarName = VarName Text
- type PositionSet = AttrSet NSourcePos
- type AttrSet = HashMap VarName
- data NSourcePos = NSourcePos {
- getSourceName :: Path
- getSourceLine :: !NPos
- getSourceColumn :: !NPos
- newtype NPos = NPos Pos
- toNSourcePos :: SourcePos -> NSourcePos
- toSourcePos :: NSourcePos -> SourcePos
- data Antiquoted (v :: Type) (r :: Type)
- = Plain !v
- | EscapedNewline
- | Antiquoted !r
- _Param :: Applicative f => (VarName -> f VarName) -> Params r -> f (Params r)
- _ParamSet :: Applicative f => ((Maybe VarName, Variadic, ParamSet r) -> f (Maybe VarName, Variadic, ParamSet r)) -> Params r -> f (Params r)
- data NString r
- = DoubleQuoted ![Antiquoted Text r]
- | Indented !Int ![Antiquoted Text r]
- _Plain :: Applicative f => (t -> f v) -> Antiquoted t r -> f (Antiquoted v r)
- _EscapedNewline :: Applicative f => (() -> f ()) -> Antiquoted v r -> f (Antiquoted v r)
- _Antiquoted :: Applicative f => (t -> f r) -> Antiquoted v t -> f (Antiquoted v r)
- data NKeyName r
- = DynamicKey !(Antiquoted (NString r) r)
- | StaticKey !VarName
- _DoubleQuoted :: Applicative f => ([Antiquoted Text r] -> f [Antiquoted Text r]) -> NString r -> f (NString r)
- _Indented :: Applicative f => ((Int, [Antiquoted Text r]) -> f (Int, [Antiquoted Text r])) -> NString r -> f (NString r)
- data Binding r
- = NamedVar !(NAttrPath r) !r !NSourcePos
- | Inherit !(Maybe r) ![VarName] !NSourcePos
- type NAttrPath r = NonEmpty (NKeyName r)
- _DynamicKey :: Applicative f => (Antiquoted (NString r) r -> f (Antiquoted (NString r) r)) -> NKeyName r -> f (NKeyName r)
- _StaticKey :: Applicative f => (VarName -> f VarName) -> NKeyName r -> f (NKeyName r)
- data NUnaryOp
- data Recursivity
- _NamedVar :: Applicative f => ((NAttrPath r, r, NSourcePos) -> f (NAttrPath r, r, NSourcePos)) -> Binding r -> f (Binding r)
- _Inherit :: Applicative f => ((Maybe r, [VarName], NSourcePos) -> f (Maybe r, [VarName], NSourcePos)) -> Binding r -> f (Binding r)
- data NBinaryOp
- _NNeg :: Applicative f => (() -> f ()) -> NUnaryOp -> f NUnaryOp
- _NNot :: Applicative f => (() -> f ()) -> NUnaryOp -> f NUnaryOp
- data NExprF r
- = NConstant !NAtom
- | NStr !(NString r)
- | NSym !VarName
- | NList ![r]
- | NSet !Recursivity ![Binding r]
- | NLiteralPath !Path
- | NEnvPath !Path
- | NApp !r !r
- | NUnary !NUnaryOp !r
- | NBinary !NBinaryOp !r !r
- | NSelect !(Maybe r) !r !(NAttrPath r)
- | NHasAttr !r !(NAttrPath r)
- | NAbs !(Params r) !r
- | NLet ![Binding r] !r
- | NIf !r !r !r
- | NWith !r !r
- | NAssert !r !r
- | NSynHole !VarName
- _NEq :: Applicative f => (() -> f ()) -> NBinaryOp -> f NBinaryOp
- _NNEq :: Applicative f => (() -> f ()) -> NBinaryOp -> f NBinaryOp
- _NLt :: Applicative f => (() -> f ()) -> NBinaryOp -> f NBinaryOp
- _NLte :: Applicative f => (() -> f ()) -> NBinaryOp -> f NBinaryOp
- _NGt :: Applicative f => (() -> f ()) -> NBinaryOp -> f NBinaryOp
- _NGte :: Applicative f => (() -> f ()) -> NBinaryOp -> f NBinaryOp
- _NAnd :: Applicative f => (() -> f ()) -> NBinaryOp -> f NBinaryOp
- _NOr :: Applicative f => (() -> f ()) -> NBinaryOp -> f NBinaryOp
- _NImpl :: Applicative f => (() -> f ()) -> NBinaryOp -> f NBinaryOp
- _NUpdate :: Applicative f => (() -> f ()) -> NBinaryOp -> f NBinaryOp
- _NPlus :: Applicative f => (() -> f ()) -> NBinaryOp -> f NBinaryOp
- _NMinus :: Applicative f => (() -> f ()) -> NBinaryOp -> f NBinaryOp
- _NMult :: Applicative f => (() -> f ()) -> NBinaryOp -> f NBinaryOp
- _NDiv :: Applicative f => (() -> f ()) -> NBinaryOp -> f NBinaryOp
- _NConcat :: Applicative f => (() -> f ()) -> NBinaryOp -> f NBinaryOp
- class NExprAnn ann g | g -> ann where
- type NExpr = Fix NExprF
- _NConstant :: Applicative f => (NAtom -> f NAtom) -> NExprF r -> f (NExprF r)
- _NStr :: Applicative f => (NString r -> f (NString r)) -> NExprF r -> f (NExprF r)
- _NSym :: Applicative f => (VarName -> f VarName) -> NExprF r -> f (NExprF r)
- _NList :: Applicative f => ([r] -> f [r]) -> NExprF r -> f (NExprF r)
- _NSet :: Applicative f => ((Recursivity, [Binding r]) -> f (Recursivity, [Binding r])) -> NExprF r -> f (NExprF r)
- _NLiteralPath :: Applicative f => (Path -> f Path) -> NExprF r -> f (NExprF r)
- _NEnvPath :: Applicative f => (Path -> f Path) -> NExprF r -> f (NExprF r)
- _NApp :: Applicative f => ((r, r) -> f (r, r)) -> NExprF r -> f (NExprF r)
- _NUnary :: Applicative f => ((NUnaryOp, r) -> f (NUnaryOp, r)) -> NExprF r -> f (NExprF r)
- _NBinary :: Applicative f => ((NBinaryOp, r, r) -> f (NBinaryOp, r, r)) -> NExprF r -> f (NExprF r)
- _NSelect :: Applicative f => ((Maybe r, r, NAttrPath r) -> f (Maybe r, r, NAttrPath r)) -> NExprF r -> f (NExprF r)
- _NHasAttr :: Applicative f => ((r, NAttrPath r) -> f (r, NAttrPath r)) -> NExprF r -> f (NExprF r)
- _NAbs :: Applicative f => ((Params r, r) -> f (Params r, r)) -> NExprF r -> f (NExprF r)
- _NLet :: Applicative f => (([Binding r], r) -> f ([Binding r], r)) -> NExprF r -> f (NExprF r)
- _NIf :: Applicative f => ((r, r, r) -> f (r, r, r)) -> NExprF r -> f (NExprF r)
- _NWith :: Applicative f => ((r, r) -> f (r, r)) -> NExprF r -> f (NExprF r)
- _NAssert :: Applicative f => ((r, r) -> f (r, r)) -> NExprF r -> f (NExprF r)
- _NSynHole :: Applicative f => (VarName -> f VarName) -> NExprF r -> f (NExprF r)
- hashAt :: Functor f => VarName -> (Maybe v -> f (Maybe v)) -> AttrSet v -> f (AttrSet v)
- paramName :: Params r -> Maybe VarName
- stringParts :: NString r -> [Antiquoted Text r]
- stripPositionInfo :: NExpr -> NExpr
- nullPos :: NSourcePos
- ekey :: forall ann g. NExprAnn ann g => NonEmpty VarName -> NSourcePos -> Lens' (Fix g) (Maybe (Fix g))
- getFreeVars :: NExpr -> Set VarName
- data SourcePos = SourcePos FilePath !Pos !Pos
- unPos :: Pos -> Int
- mkPos :: Int -> Pos
Documentation
Params
represents all the ways the formal parameters to a
function can be represented.
Param !VarName | For functions with a single named argument, such as Param "x" ~ x |
ParamSet !(Maybe VarName) !Variadic !(ParamSet r) | Explicit parameters (argument must be a set). Might specify a name to bind to the set in the function body. The bool indicates whether it is variadic or not. ParamSet Nothing False [("x",Nothing)] ~ { x } ParamSet (pure "s") True [("x", pure y)] ~ s@{ x ? y, ... } |
Instances
Instances
FromJSON Variadic Source # | |
ToJSON Variadic Source # | |
Defined in Nix.Expr.Types | |
Data Variadic Source # | |
Defined in Nix.Expr.Types gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Variadic -> c Variadic # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Variadic # toConstr :: Variadic -> Constr # dataTypeOf :: Variadic -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Variadic) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Variadic) # gmapT :: (forall b. Data b => b -> b) -> Variadic -> Variadic # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Variadic -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Variadic -> r # gmapQ :: (forall d. Data d => d -> u) -> Variadic -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Variadic -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Variadic -> m Variadic # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Variadic -> m Variadic # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Variadic -> m Variadic # | |
Monoid Variadic Source # | |
Semigroup Variadic Source # | |
Generic Variadic Source # | |
Read Variadic Source # | |
Show Variadic Source # | |
Binary Variadic Source # | |
NFData Variadic Source # | |
Defined in Nix.Expr.Types | |
Eq Variadic Source # | |
Ord Variadic Source # | |
Defined in Nix.Expr.Types | |
Hashable Variadic Source # | |
Defined in Nix.Expr.Types | |
Serialise Variadic Source # | |
type Rep Variadic Source # | |
Instances
type PositionSet = AttrSet NSourcePos Source #
Holds file positionng information for abstrations.
A type synonym for HashMap VarName NSourcePos
.
data NSourcePos Source #
Represents source positions. Source line & column positions change intensively during parsing, so they are declared strict to avoid memory leaks.
NSourcePos | |
|
Instances
Instances
FromJSON NPos Source # | |
ToJSON NPos Source # | |
Defined in Nix.Expr.Types | |
Data NPos Source # | |
Defined in Nix.Expr.Types gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NPos -> c NPos # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c NPos # dataTypeOf :: NPos -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c NPos) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NPos) # gmapT :: (forall b. Data b => b -> b) -> NPos -> NPos # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NPos -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NPos -> r # gmapQ :: (forall d. Data d => d -> u) -> NPos -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> NPos -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> NPos -> m NPos # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NPos -> m NPos # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NPos -> m NPos # | |
Semigroup NPos Source # | |
Generic NPos Source # | |
Read NPos Source # | |
Show NPos Source # | |
Binary NPos Source # | |
NFData NPos Source # | |
Defined in Nix.Expr.Types | |
Eq NPos Source # | |
Ord NPos Source # | |
Hashable NPos Source # | |
Defined in Nix.Expr.Types | |
Serialise NPos Source # | |
type Rep NPos Source # | |
Defined in Nix.Expr.Types |
toNSourcePos :: SourcePos -> NSourcePos Source #
Helper for SourcePos
-> NSourcePos
coersion.
toSourcePos :: NSourcePos -> SourcePos Source #
Helper for NSourcePos
-> SourcePos
coersion.
data Antiquoted (v :: Type) (r :: Type) Source #
Antiquoted
represents an expression that is either
antiquoted (surrounded by ${...}) or plain (not antiquoted).
Plain !v | |
EscapedNewline |
''\n in an indented string. It is equivalent to a single newline character: ''''\n'' ≡ "\n" |
Antiquoted !r |
Instances
_ParamSet :: Applicative f => ((Maybe VarName, Variadic, ParamSet r) -> f (Maybe VarName, Variadic, ParamSet r)) -> Params r -> f (Params r) Source #
An NString
is a list of things that are either a plain string
or an antiquoted expression. After the antiquotes have been evaluated,
the final string is constructed by concatenating all the parts.
DoubleQuoted ![Antiquoted Text r] | Strings wrapped with double-quotes ( DoubleQuoted [Plain "x",Antiquoted y] ~ "x${y}" |
Indented !Int ![Antiquoted Text r] | Strings wrapped with two single quotes ( Indented 1 [Plain "x"] ~ '' x'' Indented 0 [EscapedNewline] ~ ''''\n'' Indented 0 [Plain "x\n ",Antiquoted y] ~ '' x ${y}'' |
Instances
_Plain :: Applicative f => (t -> f v) -> Antiquoted t r -> f (Antiquoted v r) Source #
_EscapedNewline :: Applicative f => (() -> f ()) -> Antiquoted v r -> f (Antiquoted v r) Source #
_Antiquoted :: Applicative f => (t -> f r) -> Antiquoted v t -> f (Antiquoted v r) Source #
A KeyName
is something that can appear on the left side of an
equals sign. For example, a
is a KeyName
in { a = 3; }
, let a = 3;
in ...
, {}.a
or {} ? a
.
Nix supports both static keynames (just an identifier) and dynamic
identifiers. Dynamic identifiers can be either a string (e.g.:
{ "a" = 3; }
) or an antiquotation (e.g.: let a = "example";
in { ${a} = 3; }.example
).
Note: There are some places where a dynamic keyname is not allowed. In particular, those include:
- The RHS of a
binding
insidelet
:let ${"a"} = 3; in ...
produces a syntax fail. - The attribute names of an
inherit
:inherit ${"a"};
is forbidden.
Note: In Nix, a simple string without antiquotes such as "foo"
is
allowed even if the context requires a static keyname, but the
parser still considers it a DynamicKey
for simplicity.
DynamicKey !(Antiquoted (NString r) r) | DynamicKey (Plain (DoubleQuoted [Plain "x"])) ~ "x" DynamicKey (Antiquoted x) ~ ${x} DynamicKey (Plain (DoubleQuoted [Antiquoted x])) ~ "${x}" |
StaticKey !VarName | StaticKey "x" ~ x |
Instances
Foldable NKeyName Source # | |
Defined in Nix.Expr.Types fold :: Monoid m => NKeyName m -> m # foldMap :: Monoid m => (a -> m) -> NKeyName a -> m # foldMap' :: Monoid m => (a -> m) -> NKeyName a -> m # foldr :: (a -> b -> b) -> b -> NKeyName a -> b # foldr' :: (a -> b -> b) -> b -> NKeyName a -> b # foldl :: (b -> a -> b) -> b -> NKeyName a -> b # foldl' :: (b -> a -> b) -> b -> NKeyName a -> b # foldr1 :: (a -> a -> a) -> NKeyName a -> a # foldl1 :: (a -> a -> a) -> NKeyName a -> a # elem :: Eq a => a -> NKeyName a -> Bool # maximum :: Ord a => NKeyName a -> a # minimum :: Ord a => NKeyName a -> a # | |
Eq1 NKeyName Source # | |
Ord1 NKeyName Source # | Since: 0.10.1 |
Defined in Nix.Expr.Types | |
Show1 NKeyName Source # | |
Traversable NKeyName Source # | |
Functor NKeyName Source # | |
NFData1 NKeyName Source # | |
Defined in Nix.Expr.Types | |
Hashable1 NKeyName Source # | |
Defined in Nix.Expr.Types | |
FromJSON r => FromJSON (NKeyName r) Source # | |
ToJSON r => ToJSON (NKeyName r) Source # | |
Defined in Nix.Expr.Types | |
Data r => Data (NKeyName r) Source # | |
Defined in Nix.Expr.Types gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NKeyName r -> c (NKeyName r) # gunfold :: (forall b r0. Data b => c (b -> r0) -> c r0) -> (forall r1. r1 -> c r1) -> Constr -> c (NKeyName r) # toConstr :: NKeyName r -> Constr # dataTypeOf :: NKeyName r -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (NKeyName r)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (NKeyName r)) # gmapT :: (forall b. Data b => b -> b) -> NKeyName r -> NKeyName r # gmapQl :: (r0 -> r' -> r0) -> r0 -> (forall d. Data d => d -> r') -> NKeyName r -> r0 # gmapQr :: forall r0 r'. (r' -> r0 -> r0) -> r0 -> (forall d. Data d => d -> r') -> NKeyName r -> r0 # gmapQ :: (forall d. Data d => d -> u) -> NKeyName r -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> NKeyName r -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> NKeyName r -> m (NKeyName r) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NKeyName r -> m (NKeyName r) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NKeyName r -> m (NKeyName r) # | |
IsString (NKeyName r) Source # | Most key names are just static text, so this instance is convenient. |
Defined in Nix.Expr.Types fromString :: String -> NKeyName r # | |
Generic (NKeyName r) Source # | |
Read r => Read (NKeyName r) Source # | |
Show r => Show (NKeyName r) Source # | |
Binary r => Binary (NKeyName r) Source # | |
NFData r => NFData (NKeyName r) Source # | |
Defined in Nix.Expr.Types | |
Eq r => Eq (NKeyName r) Source # | |
Ord r => Ord (NKeyName r) Source # | |
Hashable r => Hashable (NKeyName r) Source # | |
Defined in Nix.Expr.Types | |
Serialise r => Serialise (NKeyName r) Source # | |
type Rep (NKeyName r) Source # | |
Defined in Nix.Expr.Types type Rep (NKeyName r) = D1 ('MetaData "NKeyName" "Nix.Expr.Types" "hnix-0.17.0-8saIMbclRB9HPH4JCEpCXn" 'False) (C1 ('MetaCons "DynamicKey" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Antiquoted (NString r) r))) :+: C1 ('MetaCons "StaticKey" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 VarName))) |
_DoubleQuoted :: Applicative f => ([Antiquoted Text r] -> f [Antiquoted Text r]) -> NString r -> f (NString r) Source #
_Indented :: Applicative f => ((Int, [Antiquoted Text r]) -> f (Int, [Antiquoted Text r])) -> NString r -> f (NString r) Source #
A single line of the bindings section of a let expression or of a set.
NamedVar !(NAttrPath r) !r !NSourcePos | An explicit naming. NamedVar (StaticKey "x" :| [StaticKey "y"]) z NSourcePos{} ~ x.y = z; | ||||||||||||
Inherit !(Maybe r) ![VarName] !NSourcePos | Inheriting an attribute (binding) into the attribute set from the other scope (attribute set). No denoted scope means to inherit from the closest outside scope.
(2021-07-07 use details):
Inherits the position of the first name through |
Instances
type NAttrPath r = NonEmpty (NKeyName r) Source #
A selector (for example in a let
or an attribute set) is made up
of strung-together key names.
StaticKey "x" :| [DynamicKey (Antiquoted y)] ~ x.${y}
_DynamicKey :: Applicative f => (Antiquoted (NString r) r -> f (Antiquoted (NString r) r)) -> NKeyName r -> f (NKeyName r) Source #
_StaticKey :: Applicative f => (VarName -> f VarName) -> NKeyName r -> f (NKeyName r) Source #
There are two unary operations: logical not and integer negation.
Instances
data Recursivity Source #
Distinguishes between recursive and non-recursive. Mainly for attribute sets.
NonRecursive | { ... } |
Recursive | rec { ... } |
Instances
_NamedVar :: Applicative f => ((NAttrPath r, r, NSourcePos) -> f (NAttrPath r, r, NSourcePos)) -> Binding r -> f (Binding r) Source #
_Inherit :: Applicative f => ((Maybe r, [VarName], NSourcePos) -> f (Maybe r, [VarName], NSourcePos)) -> Binding r -> f (Binding r) Source #
Binary operators expressible in the nix language.
NEq | Equality ( |
NNEq | Inequality ( |
NLt | Less than ( |
NLte | Less than or equal ( |
NGt | Greater than ( |
NGte | Greater than or equal ( |
NAnd | Logical and ( |
NOr | Logical or ( |
NImpl | Logical implication ( |
NUpdate | Get the left attr set, extend it with the right one & override equal keys ( |
NPlus | Addition ( |
NMinus | Subtraction ( |
NMult | Multiplication ( |
NDiv | Division ( |
NConcat | List concatenation ( |
Instances
The main Nix expression type. As it is polimorphic, has a functor,
which allows to traverse expressions and map functions over them.
The actual NExpr
type is a fixed point of this functor, defined
below.
NConstant !NAtom | Constants: ints, floats, bools, URIs, and null. |
NStr !(NString r) | A string, with interpolated expressions. |
NSym !VarName | A variable. For example, in the expression NSym "x" ~ x |
NList ![r] | A list literal. NList [x,y] ~ [ x y ] |
NSet !Recursivity ![Binding r] | An attribute set literal NSet Recursive [NamedVar x y _] ~ rec { x = y; } NSet NonRecursive [Inherit Nothing [x] _] ~ { inherit x; } |
NLiteralPath !Path | A path expression, which is evaluated to a store path. The path here can be relative, in which case it's evaluated relative to the file in which it appears. NLiteralPath "/x" ~ /x NLiteralPath "x/y" ~ x/y |
NEnvPath !Path | A path which refers to something in the Nix search path (the NIX_PATH
environment variable. For example, NEnvPath "x" ~ <x> |
NApp !r !r | Functional application (aka F.A., apply a function to an argument). NApp f x ~ f x |
NUnary !NUnaryOp !r | Application of a unary operator to an expression. NUnary NNeg x ~ - x NUnary NNot x ~ ! x |
NBinary !NBinaryOp !r !r | Application of a binary operator to two expressions. NBinary NPlus x y ~ x + y NBinary NApp f x ~ f x |
NSelect !(Maybe r) !r !(NAttrPath r) | Dot-reference into an attribute set, optionally providing an alternative if the key doesn't exist. NSelect Nothing s (x :| []) ~ s.x NSelect (pure y) s (x :| []) ~ s.x or y |
NHasAttr !r !(NAttrPath r) | Ask if a set contains a given attribute path. NHasAttr s (x :| []) ~ s ? x |
NAbs !(Params r) !r | A function literal (lambda abstraction). NAbs (Param "x") y ~ x: y |
NLet ![Binding r] !r | Evaluate the second argument after introducing the bindings. NLet [] x ~ let in x NLet [NamedVar x y _] z ~ let x = y; in z NLet [Inherit Nothing x _] y ~ let inherit x; in y |
NIf !r !r !r | If-then-else statement. NIf x y z ~ if x then y else z |
NWith !r !r | Evaluate an attribute set, bring its bindings into scope, and evaluate the second argument. NWith x y ~ with x; y |
NAssert !r !r | Checks that the first argument is a predicate that is NAssert x y ~ assert x; y |
NSynHole !VarName | Syntactic hole. See https://github.com/haskell-nix/hnix/issues/197 for context. NSynHole "x" ~ ^x |
Instances
type NExpr = Fix NExprF Source #
The monomorphic expression type is a fixed point of the polymorphic one.
_NConstant :: Applicative f => (NAtom -> f NAtom) -> NExprF r -> f (NExprF r) Source #
_NSet :: Applicative f => ((Recursivity, [Binding r]) -> f (Recursivity, [Binding r])) -> NExprF r -> f (NExprF r) Source #
_NLiteralPath :: Applicative f => (Path -> f Path) -> NExprF r -> f (NExprF r) Source #
_NBinary :: Applicative f => ((NBinaryOp, r, r) -> f (NBinaryOp, r, r)) -> NExprF r -> f (NExprF r) Source #
_NSelect :: Applicative f => ((Maybe r, r, NAttrPath r) -> f (Maybe r, r, NAttrPath r)) -> NExprF r -> f (NExprF r) Source #
_NHasAttr :: Applicative f => ((r, NAttrPath r) -> f (r, NAttrPath r)) -> NExprF r -> f (NExprF r) Source #
_NLet :: Applicative f => (([Binding r], r) -> f ([Binding r], r)) -> NExprF r -> f (NExprF r) Source #
paramName :: Params r -> Maybe VarName Source #
Get the name out of the parameter (there might be none).
stringParts :: NString r -> [Antiquoted Text r] Source #
stripPositionInfo :: NExpr -> NExpr Source #
nullPos :: NSourcePos Source #
ekey :: forall ann g. NExprAnn ann g => NonEmpty VarName -> NSourcePos -> Lens' (Fix g) (Maybe (Fix g)) Source #
The data type SourcePos
represents source positions. It contains the
name of the source file, a line number, and a column number. Source line
and column positions change intensively during parsing, so we need to
make them strict to avoid memory leaks.
Instances
Data SourcePos | |
Defined in Text.Megaparsec.Pos gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SourcePos -> c SourcePos # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SourcePos # toConstr :: SourcePos -> Constr # dataTypeOf :: SourcePos -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SourcePos) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SourcePos) # gmapT :: (forall b. Data b => b -> b) -> SourcePos -> SourcePos # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SourcePos -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SourcePos -> r # gmapQ :: (forall d. Data d => d -> u) -> SourcePos -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> SourcePos -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> SourcePos -> m SourcePos # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SourcePos -> m SourcePos # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SourcePos -> m SourcePos # | |
Generic SourcePos | |
Read SourcePos | |
Show SourcePos | |
NFData SourcePos | |
Defined in Text.Megaparsec.Pos | |
Eq SourcePos | |
Ord SourcePos | |
Defined in Text.Megaparsec.Pos | |
type Rep SourcePos | |
Defined in Text.Megaparsec.Pos type Rep SourcePos = D1 ('MetaData "SourcePos" "Text.Megaparsec.Pos" "megaparsec-9.5.0-nV6NFlDOdsDHucVPlnquI" 'False) (C1 ('MetaCons "SourcePos" 'PrefixI 'True) (S1 ('MetaSel ('Just "sourceName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath) :*: (S1 ('MetaSel ('Just "sourceLine") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Pos) :*: S1 ('MetaSel ('Just "sourceColumn") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Pos)))) |