Note [idArity varies independently of dmdTypeDepth]
In general, an Id `f` has two independently varying attributes: * f's idArity, and * the dmdTypeDepth of f's demand signature For example, if f's demand signature is <L><L>, f's arity could be greater than, or less than 2. Why? Because both are conservative approximations: * Arity n means "does no expensive work until applied to at least n args" (e.g. (f x1..xm) is cheap to bring to HNF for m<n) * Dmd sig with n args means "here is how to transform the incoming demand when applied to n args". This is /semantic/ property, unrelated to arity. See GHC.Types.Demand Note [Understanding DmdType and DmdSig] We used to check in GHC.Core.Lint that dmdTypeDepth <= idArity for a let-bound identifier. But that means we would have to zap demand signatures every time we reset or decrease arity. For example, consider the following expression: (let go x y = `x` seq ... in go) |> co `go` might have a strictness signature of `<1L><L>`. The simplifier will identify `go` as a nullary join point through `joinPointBinding_maybe` and float the coercion into the binding, leading to an arity decrease: join go = (\x y -> `x` seq ...) |> co in go With the CoreLint check, we would have to zap `go`'s perfectly viable strictness signature. However, in the case of a /bottoming/ signature, f : <L><L>b, we /can/ say that f's arity is no greater than 2, because it'd be false to say that f does no work when applied to 3 args. Lint checks this constraint, in `GHC.Core.Lint.lintLetBind`.
References 1
- Understanding DmdType and DmdSig GHC.Types.Demand
Referenced by 5
- GHC.Core.Lint call site ×2
- The demand for the RHS of a binding GHC.Core.Opt.DmdAnal
- Bottoming bindings GHC.Core.Opt.Simplify.Iteration
- GHC.Types.Id.Info call site