Created
May 9, 2017 09:24
-
-
Save gallais/95c699fdebf60cb23b1f324f6996047c to your computer and use it in GitHub Desktop.
Default named arguments
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
record Default {ℓ} (A : Set ℓ) (a : A) : Set ℓ where | |
constructor _! | |
field value : A | |
instance | |
default : ∀ {ℓ} {A : Set ℓ} a → Default A a | |
default a = record { value = a } | |
open import Agda.Builtin.Nat | |
incr : Nat → {{steps : Default Nat 1}} → Nat | |
incr n {{steps}} = Default.value steps + n | |
open import Relation.Binary.PropositionalEquality | |
_ : incr 3 ≡ 4 | |
_ = refl | |
_ : incr 3 {{steps = 2 !}} ≡ 5 | |
_ = refl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment