Restore strictness annotations

It doesn't help speed, but seems to reduce max resident.
This commit is contained in:
John Wiegley 2018-04-10 22:52:30 -07:00
parent f8ff1c7522
commit 77bc4cb334

View file

@ -49,45 +49,45 @@ type VarName = Text
-- them. The actual 'NExpr' type is a fixed point of this functor, defined
-- below.
data NExprF r
= NConstant NAtom
= NConstant !NAtom
-- ^ Constants: ints, bools, URIs, and null.
| NStr (NString r)
| NStr !(NString r)
-- ^ A string, with interpolated expressions.
| NSym VarName
| NSym !VarName
-- ^ A variable. For example, in the expression @f a@, @f@ is represented
-- as @NSym "f"@ and @a@ as @NSym "a"@.
| NList [r]
| NList ![r]
-- ^ A list literal.
| NSet [Binding r]
| NSet ![Binding r]
-- ^ An attribute set literal, not recursive.
| NRecSet [Binding r]
| NRecSet ![Binding r]
-- ^ An attribute set literal, recursive.
| NLiteralPath FilePath
| NLiteralPath !FilePath
-- ^ 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.
| NEnvPath FilePath
| NEnvPath !FilePath
-- ^ A path which refers to something in the Nix search path (the NIX_PATH
-- environment variable. For example, @<nixpkgs/pkgs>@.
| NUnary NUnaryOp r
| NUnary !NUnaryOp !r
-- ^ Application of a unary operator to an expression.
| NBinary NBinaryOp r r
| NBinary !NBinaryOp !r !r
-- ^ Application of a binary operator to two expressions.
| NSelect r (NAttrPath r) (Maybe r)
| NSelect !r !(NAttrPath r) !(Maybe r)
-- ^ Dot-reference into an attribute set, optionally providing an
-- alternative if the key doesn't exist.
| NHasAttr r (NAttrPath r)
| NHasAttr !r !(NAttrPath r)
-- ^ Ask if a set contains a given attribute path.
| NAbs (Params r) r
| NAbs !(Params r) !r
-- ^ A function literal (lambda abstraction).
| NLet [Binding r] r
| NLet ![Binding r] !r
-- ^ Evaluate the second argument after introducing the bindings.
| NIf r r r
| NIf !r !r !r
-- ^ If-then-else statement.
| NWith r r
| NWith !r !r
-- ^ Evaluate an attribute set, bring its bindings into scope, and
-- evaluate the second argument.
| NAssert r r
| NAssert !r !r
-- ^ Assert that the first returns true before evaluating the second.
deriving (Ord, Eq, Generic, Generic1, Typeable, Data, Functor,
Foldable, Traversable, Show, NFData, NFData1)
@ -109,9 +109,9 @@ type NExpr = Fix NExprF
-- | A single line of the bindings section of a let expression or of a set.
data Binding r
= NamedVar (NAttrPath r) r
= NamedVar !(NAttrPath r) !r
-- ^ An explicit naming, such as @x = y@ or @x.y = z@.
| Inherit (Maybe r) (NAttrPath r)
| Inherit !(Maybe r) !(NAttrPath r)
-- ^ Using a name already in scope, such as @inherit x;@ which is shorthand
-- for @x = x;@ or @inherit (x) y;@ which means @y = x.y;@.
deriving (Generic, Generic1, Typeable, Data, Ord, Eq, Functor,
@ -120,9 +120,9 @@ data Binding r
-- | @Params@ represents all the ways the formal parameters to a
-- function can be represented.
data Params r
= Param VarName
= Param !VarName
-- ^ For functions with a single named argument, such as @x: x + 1@.
| ParamSet (ParamSet r) Bool (Maybe VarName)
| ParamSet !(ParamSet r) !Bool !(Maybe VarName)
-- ^ 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.
@ -138,7 +138,7 @@ instance IsString (Params r) where
-- | 'Antiquoted' represents an expression that is either
-- antiquoted (surrounded by ${...}) or plain (not antiquoted).
data Antiquoted (v :: *) (r :: *) = Plain v | EscapedNewline | Antiquoted r
data Antiquoted (v :: *) (r :: *) = Plain !v | EscapedNewline | Antiquoted !r
deriving (Ord, Eq, Generic, Generic1, Typeable, Data, Functor,
Foldable, Traversable, Show, NFData, NFData1)
@ -146,10 +146,10 @@ data Antiquoted (v :: *) (r :: *) = Plain v | EscapedNewline | Antiquoted r
-- or an antiquoted expression. After the antiquotes have been evaluated,
-- the final string is constructed by concating all the parts.
data NString r
= DoubleQuoted [Antiquoted Text r]
= DoubleQuoted ![Antiquoted Text r]
-- ^ Strings wrapped with double-quotes (") can contain literal newline
-- characters, but the newlines are preserved and no indentation is stripped.
| Indented [Antiquoted Text r]
| Indented ![Antiquoted Text r]
-- ^ Strings wrapped with two single quotes ('') can contain newlines,
-- and their indentation will be stripped.
deriving (Eq, Ord, Generic, Generic1, Typeable, Data, Functor,
@ -180,8 +180,8 @@ instance IsString (NString r) where
-- allowed even if the context requires a static keyname, but the
-- parser still considers it a 'DynamicKey' for simplicity.
data NKeyName r
= DynamicKey (Antiquoted (NString r) r)
| StaticKey VarName (Maybe SourcePos)
= DynamicKey !(Antiquoted (NString r) r)
| StaticKey !VarName !(Maybe SourcePos)
deriving (Eq, Ord, Generic, Typeable, Data, Show, NFData)
instance Generic1 NKeyName where