-
Notifications
You must be signed in to change notification settings - Fork 260
Closed
Description
I was experimenting with Integers, leading to agda/agda#8208 (so I don't see this going anywhere anytime soon, but the coupling between 'primitive's and Builtins looks as though it might benefit from a closer look?), towards defining instead:
{-# OPTIONS --cubical-compatible --safe #-}
module Data.Integer.Base where
open import Data.Nat.Base as ℕ using (ℕ) hiding (module ℕ)
------------------------------------------------------------------------
-- Integers: add `NonZero` as a premise to the `negsuc` constructor
data ℤ : Set where
pos : ∀ (n : ℕ) → ℤ
neg : ∀ (n : ℕ) → ℕ.NonZero n → ℤ
pattern negsuc n = neg (ℕ.suc n) _
{-# BUILTIN INTEGER ℤ #-}
{-# BUILTIN INTEGERPOS pos #-}and then most/all of the gymnastics associated with -[1+ n ] etc. ought to go away, which I think would be better for (user and developer intelligibility), esp. eg. #2878 because the Signed representation then becomes ... almost automatic.
NB. Again, for 'reasons', we can't define
data ℤ : Set where
pos : ∀ (n : ℕ) → ℤ
neg : ∀ (n : ℕ) → {{ℕ.NonZero n}} → ℤbut in view of #2644 maybe making the proof explicit (but being able to finesse it via the negsuc pattern synonym where needed) isn't such a bad thing...
Metadata
Metadata
Assignees
Labels
No labels