Modules

categorical-crypto

  • Prelude

CategoricalCrypto

  • CategoricalCrypto
  • Abstract
  • Abstract2
  • Abstract2.Equivalence
  • Abstract2.Morphism
  • Abstract2.OAPEmulation
  • Abstract2.WideSubcategory
  • Channel.Category
  • Channel.Core
  • Channel.Selection
  • Examples.Basic
  • Examples.Commitment
  • Examples.RelSetup
  • Examples.Signatures
  • FamilyCategory
  • Machine.Constraints
  • Machine.Core
  • MachineAxioms
  • RandomOracle
  • RandomOracle2
  • SFunM
  • Standard
  • Standard2
  • Standard2.Morphism
  • StandardTV
  • UCSetup
  • UCSetup.Morphism
  • VanishingTV

Categories

  • Actegory
  • Actegory.Underlying
  • Category.EquivClosureHelper
  • Coherence.Monoidal
  • Coherence.Monoidal.Compare
  • Coherence.Monoidal.Diagram
  • Coherence.Monoidal.Frontend
  • Coherence.Monoidal.Frontend.Core
  • Coherence.Monoidal.Frontend.Sigma
  • Coherence.Monoidal.MacLane
  • Coherence.Monoidal.Normalize
  • Coherence.Monoidal.Reflect
  • Coherence.Monoidal.Sigma
  • Coherence.Monoidal.Test.Frontend
  • Coherence.Monoidal.Test.InterchangeStress
  • Coherence.Monoidal.Test.Limitations
  • Coherence.Monoidal.Test.SigmaFrontend
  • Coherence.Monoidal.WireCoherence
  • CoherenceIsos
  • Diagram.Coend.Ext.Setoids
  • Discrete
  • FreeMonoidal
  • FreeStrictMonoidal
  • Functor.Monoidal.CurriedTensor
  • Functor.Monoidal.CurriedTensor.Properties
  • Functor.Monoidal.Properties.Ext
  • Functor.Presheaf.Morphism
  • GradedKleisli
  • GradedKleisli.Functorial
  • GradedKleisli.Functorial.Category
  • GradedKleisli.Regrade
  • KernelCongruence
  • KernelCongruence.Reindex
  • LocallyGraded
  • LocallyGraded.FreeActegory
  • LocallyGraded.FreeActegory.Kleisli
  • LocallyGraded.Kleisli
  • Monad.Graded.Ext
  • Monad.Graded.Morphism
  • Monad.Graded.Pullback
  • Monad.Graded.Uncurried
  • Morphism.Reasoning.Ext
  • NaturalTransformationHelper
  • Properties

Class

  • Monad.Ext

Data

  • List.Properties.Ext
  • Maybe.Ext
  • Nat.Poly

LibExt

  • LibExt
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
{-# OPTIONS --cubical-compatible #-}
module Class.Bifunctor where
 
open import Class.Prelude hiding (A; B; C)
open import Class.Core
import Data.Product as ×
import Data.Sum as ⊎
 
private variable
a b : Level
A : Type a; A′ : Type a; A″ : Type a
B : A → Type b; B′ : A → Type b; C : A′ → Type b
 
-- ** indexed/dependent version
record BifunctorI
(F : (A : Type a) (B : A → Type b) → Type (a ⊔ b)) : Type (lsuc (a ⊔ b)) where
field
bimap′ : (f : A → A′) → (∀ {x} → B x → C (f x)) → F A B → F A′ C
 
map₁′ : (A → A′) → F A (const A″) → F A′ (const A″)
map₁′ f = bimap′ f id
_<$>₁′_ = map₁′
 
map₂′ : (∀ {x} → B x → B′ x) → F A B → F A B′
map₂′ g = bimap′ id g
_<$>₂′_ = map₂′
 
infixl 4 _<$>₁′_ _<$>₂′_
 
open BifunctorI ⦃...⦄ public
 
instance
Bifunctor-Σ : BifunctorI {a}{b} Σ
Bifunctor-Σ .bimap′ = ×.map
 
-- ** non-dependent version
record Bifunctor (F : Type a → Type b → Type (a ⊔ b)) : Type (lsuc (a ⊔ b)) where
field
bimap : ∀ {A A′ : Type a} {B B′ : Type b} → (A → A′) → (B → B′) → F A B → F A′ B′
 
map₁ : ∀ {A A′ : Type a} {B : Type b} → (A → A′) → F A B → F A′ B
map₁ f = bimap f id
_<$>₁_ = map₁
 
map₂ : ∀ {A : Type a} {B B′ : Type b} → (B → B′) → F A B → F A B′
map₂ g = bimap id g
_<$>₂_ = map₂
 
infixl 4 _<$>₁_ _<$>₂_
 
open Bifunctor ⦃...⦄ public
 
map₁₂ : ∀ {F : Type a → Type a → Type a} {A B : Type a}
→ ⦃ Bifunctor F ⦄
→ (A → B) → F A A → F B B
map₁₂ f = bimap f f
_<$>₁₂_ = map₁₂
infixl 4 _<$>₁₂_
 
instance
Bifunctor-× : Bifunctor {a}{b} _×_
Bifunctor-× .bimap f g = ×.map f g
 
Bifunctor-⊎ : Bifunctor {a}{b} _⊎_
Bifunctor-⊎ .bimap = ⊎.map