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
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
------------------------------------------------------------------------
-- The Agda standard library
--
-- Generic printf function.
------------------------------------------------------------------------
 
{-# OPTIONS --cubical-compatible --safe #-}
 
module Text.Printf.Generic where
 
open import Level using (Level; 0ℓ; _⊔_; Lift)
open import Data.List.Base as List using (List; []; _∷_)
open import Data.Char.Base
open import Data.Maybe.Base hiding (map)
open import Data.Nat.Base using (ℕ)
open import Data.Product.Base hiding (map)
open import Data.Product.Nary.NonDependent
open import Data.String.Base using (String)
open import Data.Sum.Base using (_⊎_; inj₁; inj₂)
open import Data.Unit.Base using (⊤)
open import Function.Nary.NonDependent
open import Function.Base
 
open import Text.Format.Generic
 
private
variable
ℓ : Level
A B : Set ℓ
 
------------------------------------------------------------------------
-- Printf argument specifications.
-- Defines the rendering of chunks.
 
record PrintfSpec {ℓ} (spec : FormatSpec) (A : Set ℓ) : Set (Level.suc 0ℓ ⊔ ℓ) where
 
open FormatSpec spec public
 
field
renderArg : ∀ arg → ArgType arg → A
renderStr : String → A
 
module Type (spec : FormatSpec) where
 
open Format spec renaming (Error to FormatError)
 
record Error (e : FormatError) : Set ℓ where
 
private
 
Size : FormatError ⊎ Format → ℕ
Size (inj₁ err) = 0
Size (inj₂ fmt) = size fmt
 
Printf : ∀ pr → Set ℓ → Set (ℓ ⊔ ⨆ (Size pr) 0ℓs)
Printf (inj₁ err) _ = Error err
Printf (inj₂ fmt) B = Arrows _ ⟦ fmt ⟧ B
 
map : ∀ pr → (A → B) → Printf pr A → Printf pr B
map (inj₁ err) f p = _
map (inj₂ fmt) f p = mapₙ _ f p
 
module Render {spec : FormatSpec} (render : PrintfSpec spec A) where
 
open PrintfSpec render
open Type spec
 
open Format spec renaming (Error to FormatError)
 
assemble : ∀ fmt → Product⊤ _ ⟦ fmt ⟧ → List A
assemble [] vs = []
assemble (Arg a ∷ fmt) (x , vs) = renderArg a x ∷ assemble fmt vs
assemble (Raw str ∷ fmt) vs = renderStr str ∷ assemble fmt vs
 
private
 
printf′ : ∀ pr → Printf pr (List A)
printf′ (inj₁ err) = _
printf′ (inj₂ fmt) = curry⊤ₙ _ (assemble fmt)
 
printf : (input : String) → Printf (lexer input) (List A)
printf input = printf′ (lexer input)