-
Notifications
You must be signed in to change notification settings - Fork 259
Description
Looking again at README.Design.Hierarchies, Algebra.{Module.}Structures and Algebra.{Module.}Bundles.Raw, I can't help wondering at the mismatch in indices vs. fieldnames to the various IsXs, with the correspondingRawX (although this may simply be an artefact of parametrisation of the Algebra.Structures module), but my main question is:
- why are the
IsXrecords not indexed over a single underlyingRawXparameter? (this may be historical...) - should they be? (ie. should we at least reconsider revisiting this design...) (UPDATED: see below)
Apologies if my ignorance of the history of, and discussion on, the associated issues/PRs obscures what otherwise may be glaringly obvious to those more expert than me!
E.g., to define IsMagmaR in this style, and show it gives rise to a 'usual' IsMagma (and Magma! because the existing hierarchy permits this... so a genuine replacement, rather than enhancement, of the existing hierarchy would still require IsX and X to be separated; but here the existing concrete Raw bundles in eg Data.Nat could be generated using this extension instead...) instance etc.:
open import Algebra.Bundles
open import Algebra.Bundles.Raw
import Algebra.Definitions as Definitions
import Algebra.Structures as Structures
open import Level using (Level; _⊔_)
open import Relation.Binary.Structures using (IsEquivalence)
module Algebra.Structures.RawIndexed where
private
variable
c ℓ : Level
record IsMagmaR (raw : RawMagma c ℓ) : Set (c ⊔ ℓ) where
open RawMagma raw
open Definitions _≈_
field
isEquivalence : IsEquivalence _≈_
∙-cong : Congruent₂ _∙_
isMagma : Structures.IsMagma _≈_ _∙_
isMagma = record { isEquivalence = isEquivalence ; ∙-cong = ∙-cong }
magma : Magma c ℓ
magma = record { isMagma = isMagma }Is it because to define any instance of a hypothetical IsMagmaR rawMagma one first has to (already have) open RawMagma rawMagma to be able to define the fields? Is this such a high price to pay?
The above may be a con, but pro might be not having to redefine in RawX the manifest operation fields defined in IsX... cf. #2251
Moreover, redefining the bundle X takes on the satisfyingly generic X = Σ RawX IsX form:
open import Algebra.Bundles.Raw
open import Algebra.Structures.RawIndexed
open import Level using (Level; suc; _⊔_)
module Algebra.Bundles.RawIndexed where
private
variable
c ℓ : Level
record MagmaR c ℓ : Set (suc (c ⊔ ℓ)) where
field
rawMagma : RawMagma c ℓ
isMagmaR : IsMagmaR rawMagma