mirror of
https://github.com/edwinb/Idris2-boot.git
synced 2024-12-23 04:42:05 +03:00
c260f6c90e
Allow matching rather than unification, as long as it doesn't solve any metavariables on the way. I noticed a potential unification bug on the way, forgetting to update whether holes are solved when unifying argument lists.
20 lines
513 B
Plaintext
20 lines
513 B
Plaintext
data Nat : Type where
|
|
Z : Nat
|
|
S : Nat -> Nat
|
|
|
|
plus : Nat -> Nat -> Nat
|
|
plus Z $y = y
|
|
plus (S $k) $y = S (plus k y)
|
|
|
|
data Baz : Nat -> Type where
|
|
AddThings : (x : Nat) -> (y : Nat) -> Baz (plus x y)
|
|
|
|
addBaz : (x : Nat) -> Baz x -> Nat
|
|
addBaz (plus x y) (AddThings x y) = plus x y
|
|
|
|
-- Can't unify because holes are solved as part of the dot pattern (plus x x)
|
|
-- which would accidentally lead to a non-linear pattern
|
|
addBaz3 : (x : Nat) -> Baz x -> Nat
|
|
addBaz3 (plus x x) (AddThings _ _) = plus x x
|
|
|