Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Number literals for any SuccessorSet #2406

Closed
wants to merge 11 commits into from
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,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