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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
{-# OPTIONS --safe --without-K #-}
 
module Reflection.Debug where
 
open import Meta.Prelude hiding (⊤; _∧_; _∨_; filter)
 
import Data.Bool as B
import Data.String as S
open import Data.Char
open import Data.List using (map)
 
open import Relation.Nullary.Decidable using (⌊_⌋)
 
open import Reflection
 
record IsErrorPart (A : Set) : Set where
field toErrorPart : A → ErrorPart
 
open IsErrorPart ⦃...⦄ public
 
instance
IsErrorPart-String : IsErrorPart String
IsErrorPart-String .toErrorPart = ErrorPart.strErr
 
IsErrorPart-Term : IsErrorPart Term
IsErrorPart-Term .toErrorPart = ErrorPart.termErr
 
IsErrorPart-Name : IsErrorPart Name
IsErrorPart-Name .toErrorPart = ErrorPart.nameErr
 
IsErrorPart-Pattern : IsErrorPart Pattern
IsErrorPart-Pattern .toErrorPart = ErrorPart.pattErr
 
IsErrorPart-Clause : IsErrorPart Clause
IsErrorPart-Clause .toErrorPart c = ErrorPart.termErr (pat-lam [ c ] [])
 
IsErrorPart-ListClause : IsErrorPart (List Clause)
IsErrorPart-ListClause .toErrorPart cs = ErrorPart.termErr (pat-lam cs [])
 
infixr 5 _∷ᵈ_ _++ᵈ_
_∷ᵈ_ : A → ⦃ _ : IsErrorPart A ⦄ → List ErrorPart → List ErrorPart
e ∷ᵈ es = toErrorPart e ∷ es
 
_++ᵈ_ : List A → ⦃ _ : IsErrorPart A ⦄ → List ErrorPart → List ErrorPart
es ++ᵈ es' = map toErrorPart es ++ es'
 
_ᵈ : ⦃ _ : IsErrorPart A ⦄ → List A → List ErrorPart
_ᵈ = map toErrorPart
 
data DebugSelection : Set where
FullPath : DebugSelection
Last : DebugSelection
All : DebugSelection
Custom : (List String → String) → DebugSelection
 
-- If All is selected, this pragma shows all debug info
-- {-# OPTIONS -v allTactics:100 #-}
 
Filter : Set
Filter = List String → Bool
 
module Filter where
open import Algebra.Lattice
open import Data.Bool.Properties
import Algebra.Function
 
Filter-Alg : BooleanAlgebra _ _
Filter-Alg = Algebra.Function.hom (List String) ∨-∧-booleanAlgebra
 
open BooleanAlgebra Filter-Alg public
 
private
_≣_ : String → String → Bool
s ≣ s' = ⌊ s S.≟ s' ⌋
 
contains : String → Filter
contains s l = foldl (λ acc s' → acc B.∨ s ≣ s') false l
 
noneOf : List String → Filter
noneOf [] = ⊤
noneOf (x ∷ l) = ¬ contains x ∧ noneOf l
 
endsWith : String → Filter
endsWith s l with last l
... | just x = s ≣ x
... | nothing = false
 
beginsWith : String → Filter
beginsWith s l with head l
... | just x = s ≣ x
... | nothing = false
 
record DebugOptions : Set where
field
path : List String
selection : DebugSelection
filter : Filter
level : ℕ
prefix : Char
 
defaultDebugOptions : DebugOptions
defaultDebugOptions = record
{ path = []; selection = All; filter = Filter.⊤; level = 100; prefix = '|' }
 
specializeDebugOptions : DebugOptions → DebugOptions → DebugOptions
specializeDebugOptions record { path = path₁ } opts@record { path = path₂ } =
record opts { path = path₁ ++ path₂ }
 
debugOptionsPath : DebugOptions → String
debugOptionsPath record { path = path ; selection = FullPath } = S.intersperse "/" path
debugOptionsPath record { path = path ; selection = Last } with last path
... | just x = x
... | nothing = ""
debugOptionsPath record { path = path ; selection = All } = "allTactics"
debugOptionsPath record { path = path ; selection = Custom f } = f path
 
debugPrintPrefix : DebugOptions → ErrorPart
debugPrintPrefix o = let open DebugOptions o in strErr (S.replicate (length path) prefix)