------------------------------------------------------------------------
-- The Agda standard library
--
-- Rational Literals
------------------------------------------------------------------------

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

module Data.Rational.Literals where

open import Agda.Builtin.FromNat
open import Agda.Builtin.FromNeg
open import Data.Unit using ()
open import Data.Nat.Base using (; zero)
open import Data.Nat.Coprimality using (sym; 1-coprimeTo)
open import Data.Integer.Base using (; ∣_∣; +_; -_)
open import Data.Rational.Base using ()

fromℤ :   
fromℤ z = record
  { numerator     = z
  ; denominator-1 = zero
  ; isCoprime     = sym (1-coprimeTo  z )
  }

number : Number 
number = record
  { Constraint = λ _  
  ; fromNat    = λ n  fromℤ (+ n)
  }

negative : Negative 
negative = record
  { Constraint = λ _  
  ; fromNeg    = λ n  fromℤ (- (+ n))
  }