{-# OPTIONS --safe #-}
module Cubical.Experiments.Generic where
open import Agda.Builtin.String
open import Agda.Builtin.List
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Univalence
open import Cubical.Data.Nat
open import Cubical.Data.Int
open import Cubical.Data.Prod
There : Type₀ → Type₀
There X = List (ℕ × String × (X × ℕ))
Database : Type₀
Database = There (ℕ × ℕ)
us : Database
us = (4 , "John" , (30 , 5) , 1956)
∷ (8 , "Hugo" , (29 , 12) , 1978)
∷ (15 , "James" , (1 , 7) , 1968)
∷ (16 , "Sayid" , (2 , 10) , 1967)
∷ (23 , "Jack" , (3 , 12) , 1969)
∷ (42 , "Sun" , (20 , 3) , 1980)
∷ []
convert : Database → Database
convert d = transport (λ i → There (swapEq ℕ ℕ i)) d
eu : Database
eu = convert us
_ : us ≡ convert eu
_ = refl
Address : Type₀
Address = String
Name : Type₀
Name = String
data Person : Type₀ where
P : Name → Address → Person
data Salary (A : Type₀) : Type₀ where
S : A → Salary A
data Employee (A : Type₀) : Type₀ where
E : Person → Salary A → Employee A
Manager : Type₀ → Type₀
Manager A = Employee A
mutual
data Dept (A : Type₀) : Type₀ where
D : Name → Manager A → List (SubUnit A) → Dept A
data SubUnit (A : Type₀) : Type₀ where
PU : Employee A → SubUnit A
DU : Dept A → SubUnit A
data Company (A : Type₀) : Type₀ where
C : List (Dept A) → Company A
anders : Employee ℤ
anders = E (P "Anders" "Pittsburgh") (S (pos 2500))
andrea : Employee ℤ
andrea = E (P "Andrea" "Copenhagen") (S (pos 2000))
andreas : Employee ℤ
andreas = E (P "Andreas" "Gothenburg") (S (pos 3000))
genCom : Company ℤ
genCom =
C ( D "Research" andreas (PU anders ∷ PU andrea ∷ [])
∷ [])
incSalary : Company ℤ → Company ℤ
incSalary c = transport (λ i → Company (sucPathℤ i)) c
genCom1 : Company ℤ
genCom1 = incSalary genCom
incSalaryℕ : ℕ → Company ℤ → Company ℤ
incSalaryℕ n c = transport (λ i → Company (addEq n i)) c
genCom2 : Company ℤ
genCom2 = incSalaryℕ 2 genCom
genCom10 : Company ℤ
genCom10 = incSalaryℕ 10 genCom