-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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._++_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters