I found this code doesn't produce any warnings though is clearly dead. It’s probably related to the type system. AFAIU it should be relatively easy to construct a derivation chain at least when there’s no branching (but I guess it might affect compiling performance?). In the example, the closure (it can be an external function) doesn't use the first argument so it should be predictable that the preceding code in the pipeline does nothing
x =
1
|> \_ -> 3
Im not sure I understand why it should produce a warning? You are intentionally throwing away the value by using _
.
if x
isn't used elsewhere, x
should have a warning.
Otherwise, for the lambda, idk. Since it is an inline lambda, a warning is probably reasonable, but in general \_
is fine, it is explictly ignoring an arg.
For example,
createExpensiveThing : {} -> ExpensiveThing
createExpensiveThing = \_ -> ... # arg not used, but needed to make this lazy
# or
fnMatchingSomeApi : U8, U8, I32 -> I32
fnMatchingSomeApi = \a, b, _ -> ... # last arg not used but needed to match api.
To rephrase my example:
ignoreEverythingAbove = \_, x-> x
y =
1
|> expensiveComputation
|> ignoreEverythingAbove 42
Since there are no side effects - both 1
and expensiveComputation
call are dead.
Can’t say if it’s a real world problem tho.
Yeah, that's probably reasonable, but we have to be smart about it cause:
{}
is often an unused empty arg.Last updated: Jul 05 2025 at 12:14 UTC