Skip to content

Commit

Permalink
[Bodigrim#128] Add EuclideanDomain class
Browse files Browse the repository at this point in the history
  • Loading branch information
rockbmb committed Aug 30, 2018
1 parent 1bbb5f4 commit f096eee
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Math/NumberTheory/EuclideanDomain.hs
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)
1 change: 1 addition & 0 deletions arithmoi.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f096eee

Please sign in to comment.