Issue4580NegativeLiterals.agda 864 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. -- Andreas, 2020-04-12, issue #4580
  2. -- Highlighting for builtins FROMNAT, FROMNEG, FROMSTRING
  3. open import Agda.Builtin.Nat
  4. open import Agda.Builtin.Equality
  5. record Number (A : Set) : Set where
  6. field fromNat : Nat → A
  7. record Negative (A : Set) : Set where
  8. field fromNeg : Nat → A
  9. open Number {{...}} public
  10. open Negative {{...}} public
  11. {-# BUILTIN FROMNAT fromNat #-} -- Should be highlighted.
  12. {-# BUILTIN FROMNEG fromNeg #-} -- Jump to definition should work.
  13. instance
  14. NumberNat : Number Nat
  15. NumberNat = record { fromNat = λ n → n }
  16. data Int : Set where
  17. pos : Nat → Int
  18. neg : Nat → Int
  19. instance
  20. NumberInt : Number Int
  21. NumberInt = record { fromNat = pos }
  22. NegativeInt : Negative Int
  23. NegativeInt = record { fromNeg = λ { zero → pos 0 ; (suc n) → neg n } }
  24. minusFive : Int
  25. minusFive = -5
  26. thm : -5 ≡ neg 4
  27. thm = refl