-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathInstances.agda
More file actions
57 lines (44 loc) · 1.76 KB
/
Copy pathInstances.agda
File metadata and controls
57 lines (44 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{-# OPTIONS --cubical-compatible #-}
module Class.Functor.Instances where
open import Class.Prelude
open import Class.Functor.Core
private Functor↓ = Functor {id}
instance
Functor-Maybe : Functor↓ Maybe
Functor-Maybe = record {M}
where import Data.Maybe as M renaming (map to _<$>_)
FunctorLaws-Maybe : FunctorLaws Maybe
FunctorLaws-Maybe = λ where
.fmap-id → λ where (just _) → refl; nothing → refl
.fmap-∘ → λ where (just _) → refl; nothing → refl
Functor-List : Functor↓ List
Functor-List ._<$>_ = map
FunctorLaws-List : FunctorLaws List
FunctorLaws-List = record {fmap-id = p; fmap-∘ = q}
where
p : ∀ {A : Type ℓ} (x : List A) → fmap id x ≡ x
p = λ where
[] → refl
(x ∷ xs) → cong (x ∷_) (p xs)
q : ∀ {A : Type ℓ} {B : Type ℓ′} {C : Type ℓ″} {f : B → C} {g : A → B} (x : List A) →
fmap (f ∘ g) x ≡ (fmap f ∘ fmap g) x
q {f = f}{g} = λ where
[] → refl
(x ∷ xs) → cong (f (g x) ∷_) (q xs)
Functor-List⁺ : Functor↓ List⁺
Functor-List⁺ = record {L}
where import Data.List.NonEmpty as L renaming (map to _<$>_)
Functor-Vec : ∀ {n} → Functor↓ (flip Vec n)
Functor-Vec = record {V}
where import Data.Vec as V renaming (map to _<$>_)
Functor-TC : Functor↓ TC
Functor-TC = record {R}
where import Reflection.TCM.Syntax as R
Functor-Abs : Functor↓ Abs
Functor-Abs = record {R}
where import Reflection.AST.Abstraction as R renaming (map to _<$>_)
Functor-Arg : Functor↓ Arg
Functor-Arg = record {R}
where import Reflection.AST.Argument as R renaming (map to _<$>_)
Functor-∃Vec : Functor↓ (∃ ∘ Vec)
Functor-∃Vec ._<$>_ f (_ , xs) = -, (f <$> xs)