blog/posts/idris2-features.md

2.4 KiB

title date tags header-includes
undocumented idris2 features 2022-11-12
computer
idris
<style> .sidebyside { display: grid; grid-template-columns: 1fr 1fr; } .sidebyside :is(.input, .goal) { box-sizing: border-box; width: 95%; height: 95%; } .sidebyside .input { grid-area: 0 / 1; } .sidebyside .goal { grid-area: 1 / 2; } </style>

blah_rhs : w = w


``` {.idris .input}
blah2 : (n : Nat) -> 2 * n = n + (n + 0)
blah2 n with %syntactic (2 * n)
  blah2 n | w = ?blah2_rhs
   w : Nat
   n : Nat
------------------------------
blah2_rhs : w = plus n (plus n 0)

:::

in blah2, only the exact syntactic occurrence of 2 * n is replaced, and the n + (n + 0) is left alone.

equality proof in with

a with-abstraction can also have a proof of equality between the pattern and the original expression, like the old inspect pattern.

:::sidebyside

blah : (n : Nat) -> 2 * n = n + (n + 0)
blah n with (2 * n) proof eq
  blah n | w = ?blah_rhs
   w : Nat
   n : Nat
   eq : plus n (plus n 0) = w
------------------------------
blah_rhs : w = w

:::