0 | ||| A module defining the `DEq` interface
5 | -------------------------------------------------------------------------------
6 | -- (=?)
7 | -------------------------------------------------------------------------------
13 | ||| Takes a function and an optional proof of the equality between two values
14 | ||| and returns a proof of the equality between the results of that function
15 | ||| applied to these values
16 | |||
17 | ||| @ f the function
18 | ||| @ x y the values
19 | ||| @ prf the potential proof of `x = y`
20 | export
22 | -- A "kosher" definition of `mcong would be this:
23 | -- ```
24 | -- mcong f Nothing = Nothing
25 | -- mcong f (Just Refl) = Just Refl
26 | -- ```
27 | -- but, for performance resons, I will skip the pattern matching and use
28 | -- `believe_me` since the values are indistinguishible runtime-wise.
29 | --
30 | -- This should be dafinable with the `cong` function
31 | -- (`mcong f prf = map (cong f) prf`)
32 | -- but I cannot figure out why it doesn't type check.
35 | ||| Like `mcong` but the function is implicit
36 | export
40 | ||| When the condition holds, return the (optional) equality proof
41 | ||| @ meq the (optional) equality proof
42 | ||| @ cond the condition
43 | export
48 | ||| Returns the (optional) equality, but only when the condition holds
49 | ||| @ meq the (optional) equality proof
50 | ||| @ cond the condition
51 | export
55 | export
56 | and
67 | -------------------------------------------------------------------------------
68 | -- PEq, DEq interfaces
69 | -------------------------------------------------------------------------------
70 | ||| Similar to `Eq` but the comparison operator returns a proof that the
71 | ||| operands are equal (in the case where they are)
72 | |||
73 | ||| The "P" in `PEq` stands for "proof"
74 | ||| Note, this is not the same as `EqP` from the "some" package from Hackage
77 | ||| Returns a proof that the operands are equal when they are,
78 | ||| otherwise, returns `Nothing`
81 | ||| Constructors of types that allow for deciding the equality between values
82 | ||| of such types, even in the case when their types are constructed from
83 | ||| different parameters
84 | |||
85 | ||| Modeled after the `GEq` typeclass from Haskells "some" package
86 | |||
87 | ||| @ f the type constructor
88 | ||| @ t the parameter type
91 | ||| If the operands are equal, returns a proof, that their type parameters
92 | ||| are equal
95 | ||| Compare the operands and ignore the equality proof
96 | export
100 | ||| Decide the inequality of the operands
101 | export
105 | -------------------------------------------------------------------------------
106 | -- PEq implementations
107 | -------------------------------------------------------------------------------
108 | ||| Use only when absolutely sure that `x == y` returns `True` only when `x`
109 | ||| and `y` are identical.
110 | export
114 | export
118 | export
122 | -- A "kosher" definition:
123 | -- peq : (n1, n2 : Nat) -> Maybe (n1 = n2)
124 | -- peq Z Z = Just Refl
125 | -- peq (S n) (S n') = mcong S (peq n n')
126 | -- peq _ _ = Nothing
128 | export
132 | export
136 | export
140 | export
144 | export
150 | export