MFPS 2026 – Agda Code
Irrelevant
Initializing search
    pdmosses/mfps2026-agda
    • About
    • Notation
    • Examples
    • Properties
    • Tests
    • Library
    pdmosses/mfps2026-agda
    • About
      • Abstract
      • Background
        • Denotational-Semantics
        • Agda
      • Meta-notation
    • Notation
      • Domains
      • Flat
        • Booleans
        • Naturals
      • Functions
      • Products
        • Sequences
        • Tuples
      • Recursion
      • Sums
      • Updates
    • Examples
      • LC
        • Abstract-Syntax
        • Domain-Equations
        • Semantic-Functions
      • PCF
        • Abstract-Syntax
        • Domain-Equations
        • Semantic-Functions
      • Scm
        • Abstract-Syntax
        • Auxiliary-Functions
        • Domain-Equations
        • Semantic-Functions
    • Properties
      • Flat
        • Booleans
        • Naturals
      • Functions
      • Products
        • Sequences
        • Tuples
      • Recursion
      • Sums
      • Updates
    • Tests
      • LC
      • PCF
    • Library
          • Bool
          • Char
            • Properties
          • Equality
            • Rewrite
          • Int
          • List
          • Maybe
          • Nat
          • Sigma
          • String
            • Properties
          • Unit
        • Primitive
      • Algebra
        • Bundles
          • Raw
          • Base
          • Propositional
          • Setoid
            • Base
            • MaxOp
            • MinMaxOp
            • MinOp
        • Core
        • Definitions
          • RawMagma
          • Bundles
            • Raw
              • MaxOp
              • MinMaxOp
              • MinOp
            • BooleanAlgebra
            • DistributiveLattice
            • Lattice
            • Semilattice
          • Structures
        • Morphism
          • Definitions
          • Structures
          • CommutativeSemigroup
          • Semigroup
        • Structures
          • Biased
          • Propositional
        • UniquenessOfIdentityProofs
          • Base
          • Properties
          • Base
          • Properties
        • Empty
          • Polymorphic
          • Base
          • Patterns
          • Properties
          • Base
        • Irrelevant
          • Base
            • Propositional
            • Setoid
            • Base
          • Properties
              • Lex
                • Core
                • Strict
              • Pointwise
                • Base
                • Properties
              • All
              • AllPairs
                • Core
              • Any
          • Base
              • Any
          • Base
          • Divisibility
            • Core
          • DivMod
            • Core
          • GeneralisedArithmetic
          • Induction
          • Properties
          • Base
          • Algebra
          • Base
          • Properties
              • All
          • Base
          • Base
          • Properties
        • Sum
          • Algebra
          • Base
          • Properties
          • Base
          • Base
          • Polymorphic
            • Base
            • Properties
          • Base
        • Applicative
        • Choice
        • Empty
        • Functor
        • Monad
        • Base
        • Bundles
        • Consequences
          • Propositional
          • Setoid
          • Composition
          • Identity
          • Symmetry
        • Core
        • Definitions
          • Bundles
              • Equality
          • Bundles
          • Core
          • Definitions
          • Nat
            • Bundles
            • Core
            • Definitions
            • Structures
          • Structures
          • Inverse
          • RightInverse
        • Structures
      • Induction
        • WellFounded
      • Level
          • Bundles
            • Raw
          • Consequences
              • Reflexive
                • Properties
            • Composition
              • Core
              • EqAndOrd
            • Intersection
              • Left
            • NonStrictToStrict
            • True
          • Core
          • Definitions
            • Heterogeneous
              • Bundles
                • Trivial
              • Core
              • Definitions
              • Structures
          • Lattice
            • Bundles
            • Definitions
            • Structures
            • Definitions
            • Structures
            • Poset
            • Preorder
            • Setoid
            • TotalOrder
          • PropositionalEquality
            • Algebra
            • Core
            • Properties
              • Double
              • Single
              • Triple
            • Preorder
            • Setoid
            • Syntax
          • Structures
            • Biased
        • Nullary
          • Decidable
            • Core
          • Irrelevant
          • Negation
            • Core
          • Recomputable
            • Core
          • Reflects
        • Unary
          • PredicateTransformer
          • Properties
    1. Library
    2. Data

    Irrelevant

    ------------------------------------------------------------------------
    -- The Agda standard library
    --
    -- Wrapper for the proof irrelevance modality
    --
    -- This allows us to store proof irrelevant witnesses in a record and
    -- use projections to manipulate them without having to turn on the
    -- unsafe option --irrelevant-projections.
    -- Cf. Data.Refinement for a use case
    ------------------------------------------------------------------------
    
    {-# OPTIONS --cubical-compatible --safe #-}
    
    module Data.Irrelevant where
    
    open import Level using (Level)
    
    private
      variable
        a b c : Level
        A : Set a
        B : Set b
        C : Set c
    
    ------------------------------------------------------------------------
    -- Type
    
    record Irrelevant (A : Set a) : Set a where
      constructor [_]
      field .irrelevant : A
    open Irrelevant public
    
    ------------------------------------------------------------------------
    -- Algebraic structure: Functor, Appplicative and Monad-like
    
    map : (A → B) → Irrelevant A → Irrelevant B
    map f [ a ] = [ f a ]
    
    pure : A → Irrelevant A
    pure x = [ x ]
    
    infixl 4 _<*>_
    _<*>_ : Irrelevant (A → B) → Irrelevant A → Irrelevant B
    [ f ] <*> [ a ] = [ f a ]
    
    infixl 1 _>>=_
    _>>=_ : Irrelevant A → (.A → Irrelevant B) → Irrelevant B
    [ a ] >>= f = f a
    
    ------------------------------------------------------------------------
    -- Other functions
    
    zipWith : (A → B → C) → Irrelevant A → Irrelevant B → Irrelevant C
    zipWith f a b = ⦇ f a b ⦈
    
    Made with MaterialX