Skip to content

Commit

Permalink
Upstream HasAdd
Browse files Browse the repository at this point in the history
  • Loading branch information
WhatisRT committed Oct 11, 2024
1 parent 53153fc commit d944cb4
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Class/HasAdd.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{-# OPTIONS --safe --cubical-compatible #-}
module Class.HasAdd where

open import Class.HasAdd.Core public
open import Class.HasAdd.Instance public
8 changes: 8 additions & 0 deletions Class/HasAdd/Core.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{-# OPTIONS --safe --cubical-compatible #-}
module Class.HasAdd.Core where

record HasAdd (A : Set) : Set where
infixl 6 _+_
field _+_ : A A A

open HasAdd ⦃ ... ⦄ public
21 changes: 21 additions & 0 deletions Class/HasAdd/Instance.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{-# OPTIONS --safe --cubical-compatible #-}
module Class.HasAdd.Instance where

open import Class.HasAdd.Core
open import Data.Integer as ℤ using (ℤ)
open import Data.Nat as ℕ using (ℕ)
open import Data.Rational as ℚ using (ℚ)
open import Data.String as Str

instance
addInt : HasAdd ℤ
addInt ._+_ = ℤ._+_

addNat : HasAdd ℕ
addNat ._+_ = ℕ._+_

addRat : HasAdd ℚ
addRat ._+_ = ℚ._+_

addString : HasAdd String
addString ._+_ = Str._++_
4 changes: 3 additions & 1 deletion standard-library-classes.agda
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ open import Class.DecEq.WithK public
open import Class.Decidable public

-- ** Others
open import Class.Show public
open import Class.Default public
open import Class.HasAdd public
open import Class.HasOrder public
open import Class.Show public
open import Class.ToBool public

-- ** Tests
Expand Down

0 comments on commit d944cb4

Please sign in to comment.