Skip to content

Instantly share code, notes, and snippets.

@bond15
Last active July 7, 2021 15:40
Show Gist options
  • Save bond15/dd760d1369a0991b3409c0f2e7407c3f to your computer and use it in GitHub Desktop.
Save bond15/dd760d1369a0991b3409c0f2e7407c3f to your computer and use it in GitHub Desktop.
Copattern matching
{-# 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