Skip to content
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ Deprecated names
New modules
-----------

* `Number` literals derivable from any `RawSuccessorSet`:
```agda
Algebra.Literals
```

* Bundled morphisms between (raw) algebraic structures:
```
Algebra.Morphism.Bundles
Expand Down
1 change: 0 additions & 1 deletion src/Algebra/Bundles.agda
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ record SuccessorSet c ℓ : Set (suc (c ⊔ ℓ)) where
rawSuccessorSet : RawSuccessorSet _ _
rawSuccessorSet = record { _≈_ = _≈_; suc# = suc#; zero# = zero# }

open RawSuccessorSet rawSuccessorSet public

------------------------------------------------------------------------
-- Bundles with 1 binary operation
Expand Down
29 changes: 29 additions & 0 deletions src/Algebra/Literals.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
------------------------------------------------------------------------
-- The Agda standard library
--
-- Algebra Literals, from a SuccessorSet
------------------------------------------------------------------------

{-# OPTIONS --cubical-compatible --safe #-}

open import Algebra.Bundles.Raw using (RawSuccessorSet)

module Algebra.Literals {c ℓ} (rawSuccessorSet : RawSuccessorSet c ℓ) where

open import Agda.Builtin.FromNat using (Number)
open import Data.Nat.Base as ℕ using (ℕ; zero; suc)
open import Data.Unit.Polymorphic.Base using (⊤)

open RawSuccessorSet rawSuccessorSet


------------------------------------------------------------------------
-- Number instance

number : Number Carrier
number = record { Constraint = λ _ → ⊤ ; fromNat = λ n → fromℕ n }
where
fromℕ : (n : ℕ) → Carrier
fromℕ zero = zero#
fromℕ (suc n) = suc# (fromℕ n)

Loading