2019-07-27 19:01:02 +03:00
|
|
|
|
|
|
|
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
|
2019-10-26 00:24:25 +03:00
|
|
|
iso : Iso t (Fin card)
|
2019-07-27 19:01:02 +03:00
|
|
|
|
|
|
|
-- default methods
|
|
|
|
|
|
|
|
foo : Vect card t
|
|
|
|
foo = toVect (from iso)
|