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
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
------------------------------------------------------------------------
-- The Agda standard library
--
-- Printf-style versions of typeError and debugPrint
------------------------------------------------------------------------
 
{-# OPTIONS --cubical-compatible --safe #-}
 
module Reflection.TCM.Format where
 
open import Agda.Builtin.Reflection using (Name; Term; ErrorPart; termErr; nameErr; strErr;
TC; typeError; debugPrint)
open import Level using (Level)
open import Function.Base using (_∘_)
open import Data.List.Base using (List; [_]; concat)
open import Data.Maybe.Base using (Maybe; nothing; just)
open import Data.Nat.Base using (ℕ)
open import Data.String.Base using (String)
open import Data.Sum.Base using (_⊎_; inj₁; inj₂)
open import Data.Unit.Base using (⊤)
 
import Text.Format as StdFormat using (formatSpec)
import Text.Printf as StdPrintf using (printfSpec)
 
open import Text.Format.Generic
open import Text.Printf.Generic
 
private
variable
ℓ : Level
A : Set ℓ
 
------------------------------------------------------------------------
-- Format specification.
-- This extends the formats from Text.Printf with
-- %t - Term
-- %q - Name
-- %e - List ErrorPart
-- Rendering goes to List ErrorPart.
 
module Specification where
 
data ErrorChunk : Set where
`Term `Name `Parts : ErrorChunk
 
errorSpec : FormatSpec
errorSpec .FormatSpec.ArgChunk = ErrorChunk
errorSpec .FormatSpec.ArgType `Term = Term
errorSpec .FormatSpec.ArgType `Name = Name
errorSpec .FormatSpec.ArgType `Parts = List ErrorPart
errorSpec .FormatSpec.lexArg 't' = just `Term
errorSpec .FormatSpec.lexArg 'q' = just `Name
errorSpec .FormatSpec.lexArg 'e' = just `Parts
errorSpec .FormatSpec.lexArg _ = nothing
 
formatSpec : FormatSpec
formatSpec = unionSpec errorSpec StdFormat.formatSpec
 
open PrintfSpec
 
printfSpec : PrintfSpec formatSpec (List ErrorPart)
printfSpec .renderArg (inj₁ `Term) t = [ termErr t ]
printfSpec .renderArg (inj₁ `Name) n = [ nameErr n ]
printfSpec .renderArg (inj₁ `Parts) es = es
printfSpec .renderArg (inj₂ arg) x = [ strErr (StdPrintf.printfSpec .renderArg arg x) ]
printfSpec .renderStr s = [ strErr s ]
 
open Specification
 
open Format formatSpec
open Type formatSpec renaming (map to mapPrintf)
open Render printfSpec
 
------------------------------------------------------------------------
-- Printf versions of typeError and debugPrint
 
typeErrorFmt : (fmt : String) → Printf (lexer fmt) (TC A)
typeErrorFmt fmt = mapPrintf (lexer fmt) (typeError ∘ concat) (printf fmt)
 
debugPrintFmt : String → ℕ → (fmt : String) → Printf (lexer fmt) (TC ⊤)
debugPrintFmt tag lvl fmt = mapPrintf (lexer fmt) (debugPrint tag lvl ∘ concat) (printf fmt)
 
-- Combine with "%e" format for nested format calls.
errorPartFmt : (fmt : String) → Printf (lexer fmt) (List ErrorPart)
errorPartFmt fmt = mapPrintf (lexer fmt) concat (printf fmt)