Last active
July 7, 2021 15:40
-
-
Save bond15/dd760d1369a0991b3409c0f2e7407c3f to your computer and use it in GitHub Desktop.
Copattern matching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# OPTIONS --copatterns #-} | |
module copattern where | |
record Bar : Set where | |
field | |
x : List Unit | |
y : Unit | |
z : ℕ | |
open Bar | |
-- define a record the usual way | |
_ : Bar | |
_ = record { x = cons unit nil ; y = unit ; z = 2 } | |
-- define a record using copatterns | |
b : Bar | |
x b = cons unit nil | |
y b = unit | |
z b = 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment