forked from Bodigrim/arithmoi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bodigrim#128] Add
EuclideanDomain
class
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
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,38 @@ | ||
-- | | ||
-- Module: Math.NumberTheory.EuclideanDomain | ||
-- Copyright: (c) 2018 Alexandre Rodrigues Baldé | ||
-- Licence: MIT | ||
-- Maintainer: Alexandre Rodrigues Baldé <[email protected]> | ||
-- Stability: Provisional | ||
-- Portability: Non-portable (GHC extensions) | ||
-- | ||
-- This module exports a class to represent Euclidean domains. | ||
-- | ||
|
||
module Math.NumberTheory.EuclideanDomain | ||
( EuclideanDomain (..) | ||
, divMod | ||
, div | ||
, mod | ||
, quotRem | ||
, quot | ||
, rem | ||
) where | ||
|
||
import Prelude hiding (divMod, div, mod, quotRem, quot, rem) | ||
|
||
class EuclideanDomain a where | ||
quotRem :: a -> a -> (a, a) | ||
divMod :: a -> a -> (a, a) | ||
|
||
quot :: EuclideanDomain a => a -> a -> a | ||
quot x y = fst (quotRem x y) | ||
|
||
rem :: EuclideanDomain a => a -> a -> a | ||
rem x y = snd (quotRem x y) | ||
|
||
div :: EuclideanDomain a => a -> a -> a | ||
div x y = fst (divMod x y) | ||
|
||
mod :: EuclideanDomain a => a -> a -> a | ||
mod x y = snd (divMod x y) |
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