Case-folding typeclass. Provides a function to fold a value to a canonical case. $$\text{foldCase} : \alpha \to \alpha$$
- foldCase : α → α
Instances
A case-insensitive wrapper. Stores the original value and a pre-computed case-folded version. Equality and hashing compare only the folded form.
$$\text{CI}(\alpha) = \{ \text{original} : \alpha,\; \text{foldedCase} : \alpha \}$$
Invariant: foldedCase = FoldCase.foldCase original
- original : α
The original, unmodified value.
- foldedCase : α
The case-folded value, used for comparison.
Invariant:
foldedCaseis always the case-folded form oforiginal.
Instances For
Smart constructor that computes the folded form automatically. $$\text{mk'}(x) = \text{CI}(x, \text{foldCase}(x))$$
Equations
- Data.CI.mk' x = { original := x, foldedCase := Data.FoldCase.foldCase x, inv := ⋯ }
Instances For
Map a function over both original and folded values. $$\text{map}(f, \text{CI}(o, fc)) = \text{CI}(f(o), \text{foldCase}(f(o)))$$
Equations
- Data.CI.map f ci = Data.CI.mk' (f ci.original)
Instances For
Equations
- Data.CI.instBEq = { beq := fun (a b : Data.CI α) => a.foldedCase == b.foldedCase }
Equations
- Data.CI.instHashable = { hash := fun (ci : Data.CI α) => hash ci.foldedCase }
Equations
- Data.CI.instOrd = { compare := fun (a b : Data.CI α) => compare a.foldedCase b.foldedCase }
Two CI values are equal iff their folded cases are equal.