mirror of
https://github.com/edwinb/Idris2-boot.git
synced 2024-12-24 05:12:29 +03:00
e6121e0935
This is the result of running the command: $ find . -name '*.idr' -type f -exec sed -i -E 's/\s+$//' {} + I confirmed before running it that this would not affect any markdown formatting in documentation comments.
27 lines
540 B
Idris
27 lines
540 B
Idris
|
|
import Data.Fin
|
|
import Data.Vect
|
|
|
|
tail : {0 A : Type} -> {n : Nat} -> (Fin (S n) -> A) -> (Fin n -> A)
|
|
tail f = f . FS
|
|
|
|
toVect : {0 A : Type} -> {n : Nat} -> (Fin n -> A) -> Vect n A
|
|
toVect {n = Z} _ = Nil
|
|
toVect {n = S m} f = (f FZ) :: (toVect (tail f))
|
|
|
|
record Iso a b where
|
|
constructor MkIso
|
|
to : a -> b
|
|
from : b -> a
|
|
toFrom : (y : b) -> to (from y) = y
|
|
fromTo : (x : a) -> from (to x) = x
|
|
|
|
interface Finite t where
|
|
card : Nat
|
|
iso : Iso t (Fin card)
|
|
|
|
-- default methods
|
|
|
|
foo : Vect card t
|
|
foo = toVect (from iso)
|