Debian Codegraph @

src/Data/Default.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- A way to specify that a function's argument takes a default value
5 -- if the argument is not passed explicitly.
6 ------------------------------------------------------------------------
7
8 {-# OPTIONS --cubical-compatible --safe #-}
9
10 module Data.Default where
11
12 -- An argument of type `WithDefault {a} {A} x` is an argument of type
13 -- `A` that happens to default to `x` if no other value is specified
14 -- (as long as the `default` instance is in scope)
15
16 infixl 0 _!
17 record WithDefault {a} {A : Set a} (x : A) : Set a where
18 constructor _!
19 field value : A
20 open WithDefault public
21
22 instance
23 default : ∀ {a} {A : Set a} {x : A} → WithDefault x
24 default {x = x} .value = x
25
26 -- See README.Data.Default for an example