4 | -- The most primitive data types; things which are used by desugaring
6 | -- Totality assertions
8 | ||| Assert to the totality checker that the given expression will always
9 | ||| terminate.
10 | |||
11 | ||| The multiplicity of its argument is 1, so `assert_total` won't affect how
12 | ||| many times variables are used. If you're not writing a linear function,
13 | ||| this doesn't make a difference.
14 | |||
15 | ||| Note: assert_total can reduce at compile time, if required for unification,
16 | ||| which might mean that it's no longer guarded a subexpression. Therefore,
17 | ||| it is best to use it around the smallest possible subexpression.
23 | ||| Assert to the totality checker that y is always structurally smaller than x
24 | ||| (which is typically a pattern argument, and *must* be in normal form for
25 | ||| this to work).
26 | |||
27 | ||| The multiplicity of x is 0, so in a linear function, you can pass values to
28 | ||| x even if they have already been used.
29 | ||| The multiplicity of y is 1, so `assert_smaller` won't affect how many times
30 | ||| its y argument is used.
31 | ||| If you're not writing a linear function, the multiplicities don't make a
32 | ||| difference.
33 | |||
34 | ||| @ x the larger value (typically a pattern argument)
35 | ||| @ y the smaller value (typically an argument to a recursive call)
41 | -- Unit type and pairs
43 | ||| The canonical single-element type, also known as the trivially true
44 | ||| proposition.
47 | ||| The trivial constructor for `()`.
48 | MkUnit
50 | ||| The non-dependent pair type, also known as conjunction.
53 | ||| A pair of elements.
54 | ||| @ a the left element of the pair
55 | ||| @ b the right element of the pair
58 | ||| Return the first element of a pair.
63 | ||| Return the second element of a pair.
68 | ||| Swap the elements in a pair
73 | -- This directive tells auto implicit search what to use to look inside pairs
74 | %pair Pair fst snd
78 | ||| A pair type where each component is linear
81 | ||| A linear pair of elements.
82 | ||| If you take one copy of the linear pair apart
83 | ||| then you only get one copy of its left and right elements.
84 | ||| @ a the left element of the pair
85 | ||| @ b the right element of the pair
89 | ||| Dependent pairs aid in the construction of dependent types by providing
90 | ||| evidence that some value resides in the type.
91 | |||
92 | ||| Formally, speaking, dependent pairs represent existential quantification -
93 | ||| they consist of a witness for the existential claim and a proof that the
94 | ||| property holds for it.
95 | |||
96 | ||| @ a the value to place in the type.
97 | ||| @ p the dependent type that requires the value.
104 | ||| A dependent variant of LPair, pairing a result value with a resource
105 | ||| that depends on the result value
110 | -- The empty type
112 | ||| The empty type, also known as the trivially false proposition.
113 | |||
114 | ||| Use `void` or `absurd` to prove anything if you have a variable of type
115 | ||| `Void` in scope.
119 | -- Equality
130 | -- An equality type for when you want to assert that each side of the
131 | -- equality has the same type, but there's not other evidence available
132 | -- to help with unification
137 | ||| Explicit heterogeneous ("John Major") equality. Use this when Idris
138 | ||| incorrectly chooses homogeneous equality for `(=)`.
139 | ||| @ a the type of the left side
140 | ||| @ b the type of the right side
141 | ||| @ x the left side
142 | ||| @ y the right side
147 | ||| Perform substitution in a term according to some equality.
148 | |||
149 | ||| Like `replace`, but with an explicit predicate, and applying the rewrite in
150 | ||| the other direction, which puts it in a form usable by the `rewrite` tactic
151 | ||| and term.
152 | %inline
158 | %rewrite Equal rewrite__impl
160 | ||| Perform substitution in a term according to some equality.
161 | %inline
166 | ||| Symmetry of propositional equality.
167 | %inline
172 | ||| Transitivity of propositional equality.
173 | %inline
178 | ||| Injectivity of MkDPair (first components)
179 | export
183 | ||| Injectivity of MkDPair (snd components)
184 | export
188 | ||| Subvert the type checker. This function is abstract, so it will not reduce
189 | ||| in the type checker. Use it with care - it can result in segfaults or
190 | ||| worse!
195 | ||| Assert to the usage checker that the given function uses its argument linearly.
199 | where
215 | %stringLit fromString
217 | ||| Interface for types that can be constructed from string literals.
221 | ||| Conversion from String.
224 | %allow_overloads fromString
226 | %inline
231 | %defaulthint
232 | %inline
237 | %charLit fromChar
239 | ||| Interface for types that can be constructed from char literals.
243 | ||| Conversion from Char.
246 | %allow_overloads fromChar
248 | %inline
253 | %defaulthint
254 | %inline
259 | %doubleLit fromDouble
261 | ||| Interface for types that can be constructed from double literals.
265 | ||| Conversion from Double.
268 | %allow_overloads fromDouble
270 | %inline
275 | %defaulthint
276 | %inline