{-# OPTIONS --cubical --safe #-}
module Container.List.Isomorphism where
open import Prelude
open import Container
open import Container.List
open import Data.Fin
open import Data.List using (tabulate; length ; _!_) renaming (_ā·_ to _Lā·_; [] to L[]; List to š)
open import Data.List.Properties
āāš : List A ā š A
āāš = uncurry tabulate
šāā : š A ā List A
šāā xs .fst = length xs
šāā xs .snd i = xs ! i
āāšāā : ā n (xs : Fin n ā A) ā šāā (āāš (n , xs)) ā” (n , xs)
āāšāā n xs i .fst = tab-length n xs i
āāšāā n xs i .snd = tab-id n xs i
šāāāš : ā (xs : š A) ā āāš (šāā xs) ā” xs
šāāāš L[] _ = L[]
šāāāš (x Lā· xs) i = x Lā· šāāāš xs i
šāā : š A ā List A
šāā .fun = šāā
šāā .inv = āāš
šāā .rightInv = uncurry āāšāā
šāā .leftInv = šāāāš