diff --git a/Math/NumberTheory/EuclideanDomain.hs b/Math/NumberTheory/EuclideanDomain.hs new file mode 100644 index 000000000..193e6dcae --- /dev/null +++ b/Math/NumberTheory/EuclideanDomain.hs @@ -0,0 +1,38 @@ +-- | +-- Module: Math.NumberTheory.EuclideanDomain +-- Copyright: (c) 2018 Alexandre Rodrigues Baldé +-- Licence: MIT +-- Maintainer: Alexandre Rodrigues Baldé +-- 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) \ No newline at end of file diff --git a/arithmoi.cabal b/arithmoi.cabal index 07d975d2e..5634b1f64 100644 --- a/arithmoi.cabal +++ b/arithmoi.cabal @@ -59,6 +59,7 @@ library Math.NumberTheory.ArithmeticFunctions.Standard Math.NumberTheory.Curves.Montgomery Math.NumberTheory.EisensteinIntegers + Math.NumberTheory.EuclideanDomain Math.NumberTheory.GaussianIntegers Math.NumberTheory.GCD Math.NumberTheory.GCD.LowLevel