logo
Formal Ledger Specification
Instances
Initializing search
    GitHub
    • Navigation
    GitHub
      • Home
      • Guide for Contributors
        • Notation
      • Ledger
        • Prelude
        • Introduction
          • Base
            • HSTypes
            • Util
          • HasCoin
          • Instances
          • Numeric
            • PositiveNat
            • UnitInterval
            • Address
            • Crypto
            • Epoch
        • Conway
          • Specification
            • Abstract
            • Certs
              • Properties
                • PoV
                • PoVLemmas
                • VoteDelegsVDeleg
            • Chain
              • Properties
                • CredDepsEqualDomRwds
                • EpochStep
                • GovDepsMatch
                • PParamsWellFormed
            • Enact
              • Properties
            • Epoch
              • Properties
                • ConstRwds
                • GovDepsMatch
                • NoPropSameDReps
            • Fees
            • Gov
              • Base
              • Actions
              • Properties
                • ChangePPGroup
            • Ledger.Ledger
              • Properties
                • GovDepsMatch
                • PoV
            • PParams
            • Properties
            • Ratify
              • Properties
            • Rewards
            • Script
              • Base
              • Timelock
              • Validation
              • Base
              • Coin
              • ValueSet
              • ValueVector
            • Transaction
            • Utxo
              • Properties
                • MinSpend
                • PoV
            • Utxow
              • Properties
              • Examples
                • HelloWorld
                • SucceedIfNumber
              • LedgerImplementation
              • Lib
              • Prelude
              • StructuredContracts
              • GovStructure
            • ConwayBootstrap
            • ConwayBootstrapEnact
            • ExternalFunctions
            • HSLedger
              • Address
              • BaseTypes
              • Cert
              • Certs
              • Chain
              • Core
              • Enact
              • Epoch
              • ExternalStructures
              • Gov
                • Core
                • Actions
              • Ledger
              • NewEpoch
              • PParams
              • Ratify
              • Transaction
              • Utxo
          • Conformance
            • Certs
              • Properties
            • Chain
              • Properties
            • Epoch
              • Properties
            • Equivalence
              • Bisimilarity
              • Certs
              • Convert
              • Deposits
              • Map
              • Utxo
            • Gov
            • Ledger
              • Properties
            • Properties
            • Script
            • Utxo
              • Properties
            • Utxow
              • Properties
        • PreConway
            • NewPP
              • Properties
            • PPUp
              • Properties
          • NewPP
            • Properties
          • PPUp
            • Properties
        • Convertible
          • Deriving
          • DerivingTest
        • HaskellTypes
          • Deriving
        • Agda Prelude
            • ComputationalRelation
            • HasSubset
            • HasSubtract
              • Instance
            • Hashable
            • STS
          • MyDebugOptions

    Instances

    {-# OPTIONS --safe #-}
    
    module Ledger.Prelude.Instances where
    
    open import Prelude
    open import Ledger.Prelude.Base
    open import Ledger.Prelude.HasCoin
    open import Interface.HasSubtract
    open import Interface.HasSubset
    
    open import abstract-set-theory.FiniteSetTheory
      renaming (_⊆_ to _⊆ˢ_)
    
    instance
      CommMonoid-ℕ-+ = NonUniqueInstances.CommMonoid-ℕ-+
    
      HasCoin-Map : ∀ {A} → ⦃ DecEq A ⦄ → HasCoin (A ⇀ Coin)
      HasCoin-Map .getCoin s = ∑[ x ← s ] x
    
      HasCoin-Set : ∀ {A} → ⦃ DecEq A ⦄ → HasCoin (ℙ (A × Coin))
      HasCoin-Set .getCoin s = ∑ˢ[ (a , c) ← s ] c
    
      HasSubset-Set : ∀ {A} → HasSubset (ℙ A)
      HasSubset-Set ._⊆_ = _⊆ˢ_
    
      HasSubtract-ℙ : ∀ {A} → ⦃ DecEq A ⦄ → HasSubtract (ℙ A) (ℙ A)
      HasSubtract-ℙ {A} ._-_ = _\_
    
      HasSubset-Map : {A B : Set} → HasSubset (A ⇀ B)
      HasSubset-Map {A} {B} ._⊆_ m₁ m₂ = {k : A} {v : B} → (k , v) ∈ (m₁ ˢ) → (k , v) ∈ (m₂ ˢ)
    
    
    
    Previous
    HasCoin
    Next
    Numeric
    Made with Material for MkDocs