semirings-0.7: two monoids as one, in holy haskimony

Copyright | (c) 2019 Andrew Lelechenko
License | BSD3
Maintainer | Andrew Lelechenko <andrew.lelechenko@gmail.com>
Safe Haskell | None
Language | Haskell98

Data.Euclidean

Description

Synopsis

- class GcdDomain a => Euclidean a where
  - quotRem :: a -> a -> (a, a)
  - quot :: a -> a -> a
  - rem :: a -> a -> a
  - degree :: a -> Natural
- class (Euclidean a, Ring a) => Field a
- class Semiring a => GcdDomain a where
  - divide :: a -> a -> Maybe a
  - gcd :: a -> a -> a
  - lcm :: a -> a -> a
  - coprime :: a -> a -> Bool
- newtype WrappedIntegral a = WrapIntegral {
  - unwrapIntegral :: a
  }
- newtype WrappedFractional a = WrapFractional {
  - unwrapFractional :: a
  }
- gcdExt :: (Eq a, Euclidean a, Ring a) => a -> a -> (a, a)

# Documentation

class GcdDomain a => Euclidean a where #

Informally speaking, `Euclidean` is a superclass of `Integral`, lacking `toInteger`, which allows to define division with remainder for a wider range of types, e. g., complex integers and polynomials with rational coefficients.

`Euclidean` represents a Euclidean domain endowed by a given Euclidean function `degree`.

No particular rounding behaviour is expected of `quotRem`. E. g., it is not guaranteed to truncate towards zero or towards negative infinity (cf. `divMod`), and remainders are not guaranteed to be non-negative. For a faithful representation of residue classes one can use mod package instead.

Minimal complete definition

(quotRem | quot, rem), degree

Methods

quotRem :: a -> a -> (a, a) #

Division with remainder.

    \x y -> y == 0 || let (q, r) = x `quotRem` y in x == q * y + r

quot :: a -> a -> a infixl 7 #

Division. Must match its default definition:

    \x y -> quot x y == fst (quotRem x y)

rem :: a -> a -> a infixl 7 #

Remainder. Must match its default definition:

    \x y -> rem x y == snd (quotRem x y)

degree :: a -> Natural #

Euclidean (aka degree, valuation, gauge, norm) function on `a`. Usually ``fromIntegral` `.` `abs``.

`degree` is rarely used by itself. Its purpose is to provide an evidence of soundness of `quotRem` by testing the following property:

    \x y -> y == 0 || let (q, r) = x `quotRem` y in (r == 0 || degree r < degree y)

#### Instances

Instances details

Euclidean CDouble # |
Instance details Defined in Data.Euclidean Methods quotRem :: CDouble -> CDouble -> (CDouble, CDouble) # quot :: CDouble -> CDouble -> CDouble # rem :: CDouble -> CDouble -> CDouble # degree :: CDouble -> Natural #
Euclidean CFloat # |
Instance details Defined in Data.Euclidean Methods quotRem :: CFloat -> CFloat -> (CFloat, CFloat) # quot :: CFloat -> CFloat -> CFloat # rem :: CFloat -> CFloat -> CFloat # degree :: CFloat -> Natural #
Euclidean Int16 # |
Instance details Defined in Data.Euclidean Methods quotRem :: Int16 -> Int16 -> (Int16, Int16) # quot :: Int16 -> Int16 -> Int16 # rem :: Int16 -> Int16 -> Int16 # degree :: Int16 -> Natural #
Euclidean Int32 # |
Instance details Defined in Data.Euclidean Methods quotRem :: Int32 -> Int32 -> (Int32, Int32) # quot :: Int32 -> Int32 -> Int32 # rem :: Int32 -> Int32 -> Int32 # degree :: Int32 -> Natural #
Euclidean Int64 # |
Instance details Defined in Data.Euclidean Methods quotRem :: Int64 -> Int64 -> (Int64, Int64) # quot :: Int64 -> Int64 -> Int64 # rem :: Int64 -> Int64 -> Int64 # degree :: Int64 -> Natural #
Euclidean Int8 # |
Instance details Defined in Data.Euclidean Methods quotRem :: Int8 -> Int8 -> (Int8, Int8) # quot :: Int8 -> Int8 -> Int8 # rem :: Int8 -> Int8 -> Int8 # degree :: Int8 -> Natural #
Euclidean Word16 # |
Instance details Defined in Data.Euclidean Methods quotRem :: Word16 -> Word16 -> (Word16, Word16) # quot :: Word16 -> Word16 -> Word16 # rem :: Word16 -> Word16 -> Word16 # degree :: Word16 -> Natural #
Euclidean Word32 # |
Instance details Defined in Data.Euclidean Methods quotRem :: Word32 -> Word32 -> (Word32, Word32) # quot :: Word32 -> Word32 -> Word32 # rem :: Word32 -> Word32 -> Word32 # degree :: Word32 -> Natural #
Euclidean Word64 # |
Instance details Defined in Data.Euclidean Methods quotRem :: Word64 -> Word64 -> (Word64, Word64) # quot :: Word64 -> Word64 -> Word64 # rem :: Word64 -> Word64 -> Word64 # degree :: Word64 -> Natural #
Euclidean Word8 # |
Instance details Defined in Data.Euclidean Methods quotRem :: Word8 -> Word8 -> (Word8, Word8) # quot :: Word8 -> Word8 -> Word8 # rem :: Word8 -> Word8 -> Word8 # degree :: Word8 -> Natural #
Euclidean Mod2 # |
Instance details Defined in Data.Euclidean Methods quotRem :: Mod2 -> Mod2 -> (Mod2, Mod2) # quot :: Mod2 -> Mod2 -> Mod2 # rem :: Mod2 -> Mod2 -> Mod2 # degree :: Mod2 -> Natural #
Euclidean Integer # |
Instance details Defined in Data.Euclidean Methods quotRem :: Integer -> Integer -> (Integer, Integer) # quot :: Integer -> Integer -> Integer # rem :: Integer -> Integer -> Integer # degree :: Integer -> Natural #
Euclidean Natural # |
Instance details Defined in Data.Euclidean Methods quotRem :: Natural -> Natural -> (Natural, Natural) # quot :: Natural -> Natural -> Natural # rem :: Natural -> Natural -> Natural # degree :: Natural -> Natural #
Euclidean () # |
Instance details Defined in Data.Euclidean Methods quotRem :: () -> () -> ((), ()) # quot :: () -> () -> () # rem :: () -> () -> () # degree :: () -> Natural #
Euclidean Double # |
Instance details Defined in Data.Euclidean Methods quotRem :: Double -> Double -> (Double, Double) # quot :: Double -> Double -> Double # rem :: Double -> Double -> Double # degree :: Double -> Natural #
Euclidean Float # |
Instance details Defined in Data.Euclidean Methods quotRem :: Float -> Float -> (Float, Float) # quot :: Float -> Float -> Float # rem :: Float -> Float -> Float # degree :: Float -> Natural #
Euclidean Int # |
Instance details Defined in Data.Euclidean Methods quotRem :: Int -> Int -> (Int, Int) # quot :: Int -> Int -> Int # rem :: Int -> Int -> Int # degree :: Int -> Natural #
Euclidean Word # |
Instance details Defined in Data.Euclidean Methods quotRem :: Word -> Word -> (Word, Word) # quot :: Word -> Word -> Word # rem :: Word -> Word -> Word # degree :: Word -> Natural #
Field a => Euclidean (Complex a) # |
Instance details Defined in Data.Euclidean Methods quotRem :: Complex a -> Complex a -> (Complex a, Complex a) # quot :: Complex a -> Complex a -> Complex a # rem :: Complex a -> Complex a -> Complex a # degree :: Complex a -> Natural #
Integral a => Euclidean (Ratio a) # |
Instance details Defined in Data.Euclidean Methods quotRem :: Ratio a -> Ratio a -> (Ratio a, Ratio a) # quot :: Ratio a -> Ratio a -> Ratio a # rem :: Ratio a -> Ratio a -> Ratio a # degree :: Ratio a -> Natural #
Fractional a => Euclidean (WrappedFractional a) # |
Instance details Defined in Data.Euclidean Methods quotRem :: WrappedFractional a -> WrappedFractional a -> (WrappedFractional a, WrappedFractional a) # quot :: WrappedFractional a -> WrappedFractional a -> WrappedFractional a # rem :: WrappedFractional a -> WrappedFractional a -> WrappedFractional a # degree :: WrappedFractional a -> Natural #
Integral a => Euclidean (WrappedIntegral a) # |
Instance details Defined in Data.Euclidean Methods quotRem :: WrappedIntegral a -> WrappedIntegral a -> (WrappedIntegral a, WrappedIntegral a) # quot :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a # rem :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a # degree :: WrappedIntegral a -> Natural #

class (Euclidean a, Ring a) => Field a #

`Field` represents a field, a ring with a multiplicative inverse for any non-zero element.

#### Instances

Instances details

Field CDouble # |
Instance details Defined in Data.Euclidean
Field CFloat # |
Instance details Defined in Data.Euclidean
Field Mod2 # |
Instance details Defined in Data.Euclidean
Field () # |
Instance details Defined in Data.Euclidean
Field Double # |
Instance details Defined in Data.Euclidean
Field Float # |
Instance details Defined in Data.Euclidean
Field a => Field (Complex a) # |
Instance details Defined in Data.Euclidean
Integral a => Field (Ratio a) # |
Instance details Defined in Data.Euclidean
Fractional a => Field (WrappedFractional a) # |
Instance details Defined in Data.Euclidean

class Semiring a => GcdDomain a where #

`GcdDomain` represents a GCD domain. This is a domain, where GCD can be defined, but which does not necessarily allow a well-behaved division with remainder (as in `Euclidean` domains).

For example, there is no way to define `rem` over polynomials with integer coefficients such that remainder is always "smaller" than divisor. However, `gcd` is still definable, just not by means of Euclidean algorithm.

All methods of `GcdDomain` have default implementations in terms of `Euclidean`. So most of the time it is enough to write:

    instance GcdDomain Foo
    instance Euclidean Foo where
      quotRem = ...
      degree  = ...

Minimal complete definition

Nothing

Methods

divide :: a -> a -> Maybe a infixl 7 #

Division without remainder.

    \x y -> (x * y) `divide` y == Just x

    \x y -> maybe True (\z -> x == z * y) (x `divide` y)

default divide :: (Eq a, Euclidean a) => a -> a -> Maybe a #

gcd :: a -> a -> a #

Greatest common divisor. Must satisfy

    \x y -> isJust (x `divide` gcd x y) && isJust (y `divide` gcd x y)

    \x y z -> isJust (gcd (x * z) (y * z) `divide` z)

default gcd :: (Eq a, Euclidean a) => a -> a -> a #

lcm :: a -> a -> a #

Lowest common multiple. Must satisfy

    \x y -> isJust (lcm x y `divide` x) && isJust (lcm x y `divide` y)

    \x y z -> isNothing (z `divide` x) || isNothing (z `divide` y) || isJust (z `divide` lcm x y)

default lcm :: Eq a => a -> a -> a #

coprime :: a -> a -> Bool #

Test whether two arguments are coprime. Must match its default definition:

    \x y -> coprime x y == isJust (1 `divide` gcd x y)

default coprime :: a -> a -> Bool #

#### Instances

Instances details

GcdDomain CDouble # |
Instance details Defined in Data.Euclidean Methods divide :: CDouble -> CDouble -> Maybe CDouble # gcd :: CDouble -> CDouble -> CDouble # lcm :: CDouble -> CDouble -> CDouble # coprime :: CDouble -> CDouble -> Bool #
GcdDomain CFloat # |
Instance details Defined in Data.Euclidean Methods divide :: CFloat -> CFloat -> Maybe CFloat # gcd :: CFloat -> CFloat -> CFloat # lcm :: CFloat -> CFloat -> CFloat # coprime :: CFloat -> CFloat -> Bool #
GcdDomain Int16 # |
Instance details Defined in Data.Euclidean Methods divide :: Int16 -> Int16 -> Maybe Int16 # gcd :: Int16 -> Int16 -> Int16 # lcm :: Int16 -> Int16 -> Int16 # coprime :: Int16 -> Int16 -> Bool #
GcdDomain Int32 # |
Instance details Defined in Data.Euclidean Methods divide :: Int32 -> Int32 -> Maybe Int32 # gcd :: Int32 -> Int32 -> Int32 # lcm :: Int32 -> Int32 -> Int32 # coprime :: Int32 -> Int32 -> Bool #
GcdDomain Int64 # |
Instance details Defined in Data.Euclidean Methods divide :: Int64 -> Int64 -> Maybe Int64 # gcd :: Int64 -> Int64 -> Int64 # lcm :: Int64 -> Int64 -> Int64 # coprime :: Int64 -> Int64 -> Bool #
GcdDomain Int8 # |
Instance details Defined in Data.Euclidean Methods divide :: Int8 -> Int8 -> Maybe Int8 # gcd :: Int8 -> Int8 -> Int8 # lcm :: Int8 -> Int8 -> Int8 # coprime :: Int8 -> Int8 -> Bool #
GcdDomain Word16 # |
Instance details Defined in Data.Euclidean Methods divide :: Word16 -> Word16 -> Maybe Word16 # gcd :: Word16 -> Word16 -> Word16 # lcm :: Word16 -> Word16 -> Word16 # coprime :: Word16 -> Word16 -> Bool #
GcdDomain Word32 # |
Instance details Defined in Data.Euclidean Methods divide :: Word32 -> Word32 -> Maybe Word32 # gcd :: Word32 -> Word32 -> Word32 # lcm :: Word32 -> Word32 -> Word32 # coprime :: Word32 -> Word32 -> Bool #
GcdDomain Word64 # |
Instance details Defined in Data.Euclidean Methods divide :: Word64 -> Word64 -> Maybe Word64 # gcd :: Word64 -> Word64 -> Word64 # lcm :: Word64 -> Word64 -> Word64 # coprime :: Word64 -> Word64 -> Bool #
GcdDomain Word8 # |
Instance details Defined in Data.Euclidean Methods divide :: Word8 -> Word8 -> Maybe Word8 # gcd :: Word8 -> Word8 -> Word8 # lcm :: Word8 -> Word8 -> Word8 # coprime :: Word8 -> Word8 -> Bool #
GcdDomain Mod2 # |
Instance details Defined in Data.Euclidean Methods divide :: Mod2 -> Mod2 -> Maybe Mod2 # gcd :: Mod2 -> Mod2 -> Mod2 # lcm :: Mod2 -> Mod2 -> Mod2 # coprime :: Mod2 -> Mod2 -> Bool #
GcdDomain Integer # |
Instance details Defined in Data.Euclidean Methods divide :: Integer -> Integer -> Maybe Integer # gcd :: Integer -> Integer -> Integer # lcm :: Integer -> Integer -> Integer # coprime :: Integer -> Integer -> Bool #
GcdDomain Natural # |
Instance details Defined in Data.Euclidean Methods divide :: Natural -> Natural -> Maybe Natural # gcd :: Natural -> Natural -> Natural # lcm :: Natural -> Natural -> Natural # coprime :: Natural -> Natural -> Bool #
GcdDomain () # |
Instance details Defined in Data.Euclidean Methods divide :: () -> () -> Maybe () # gcd :: () -> () -> () # lcm :: () -> () -> () # coprime :: () -> () -> Bool #
GcdDomain Double # |
Instance details Defined in Data.Euclidean Methods divide :: Double -> Double -> Maybe Double # gcd :: Double -> Double -> Double # lcm :: Double -> Double -> Double # coprime :: Double -> Double -> Bool #
GcdDomain Float # |
Instance details Defined in Data.Euclidean Methods divide :: Float -> Float -> Maybe Float # gcd :: Float -> Float -> Float # lcm :: Float -> Float -> Float # coprime :: Float -> Float -> Bool #
GcdDomain Int # |
Instance details Defined in Data.Euclidean Methods divide :: Int -> Int -> Maybe Int # gcd :: Int -> Int -> Int # lcm :: Int -> Int -> Int # coprime :: Int -> Int -> Bool #
GcdDomain Word # |
Instance details Defined in Data.Euclidean Methods divide :: Word -> Word -> Maybe Word # gcd :: Word -> Word -> Word # lcm :: Word -> Word -> Word # coprime :: Word -> Word -> Bool #
Field a => GcdDomain (Complex a) # |
Instance details Defined in Data.Euclidean Methods divide :: Complex a -> Complex a -> Maybe (Complex a) # gcd :: Complex a -> Complex a -> Complex a # lcm :: Complex a -> Complex a -> Complex a # coprime :: Complex a -> Complex a -> Bool #
Integral a => GcdDomain (Ratio a) # |
Instance details Defined in Data.Euclidean Methods divide :: Ratio a -> Ratio a -> Maybe (Ratio a) # gcd :: Ratio a -> Ratio a -> Ratio a # lcm :: Ratio a -> Ratio a -> Ratio a # coprime :: Ratio a -> Ratio a -> Bool #
Fractional a => GcdDomain (WrappedFractional a) # |
Instance details Defined in Data.Euclidean Methods divide :: WrappedFractional a -> WrappedFractional a -> Maybe (WrappedFractional a) # gcd :: WrappedFractional a -> WrappedFractional a -> WrappedFractional a # lcm :: WrappedFractional a -> WrappedFractional a -> WrappedFractional a # coprime :: WrappedFractional a -> WrappedFractional a -> Bool #
Integral a => GcdDomain (WrappedIntegral a) # |
Instance details Defined in Data.Euclidean Methods divide :: WrappedIntegral a -> WrappedIntegral a -> Maybe (WrappedIntegral a) # gcd :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a # lcm :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a # coprime :: WrappedIntegral a -> WrappedIntegral a -> Bool #

newtype WrappedIntegral a #

Wrapper around `Integral` with `GcdDomain` and `Euclidean` instances.

Constructors

WrapIntegral |

Fields

- unwrapIntegral :: a

#### Instances

Instances details

Bits a => Bits (WrappedIntegral a) # |

Instance details

Defined in Data.Euclidean

Methods

(.&.) :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a #

(.|.) :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a #

xor :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a #

complement :: WrappedIntegral a -> WrappedIntegral a #

shift :: WrappedIntegral a -> Int -> WrappedIntegral a #

rotate :: WrappedIntegral a -> Int -> WrappedIntegral a #

zeroBits :: WrappedIntegral a #

bit :: Int -> WrappedIntegral a #

setBit :: WrappedIntegral a -> Int -> WrappedIntegral a #

clearBit :: WrappedIntegral a -> Int -> WrappedIntegral a #

complementBit :: WrappedIntegral a -> Int -> WrappedIntegral a #

testBit :: WrappedIntegral a -> Int -> Bool #

bitSizeMaybe :: WrappedIntegral a -> Maybe Int #

bitSize :: WrappedIntegral a -> Int #

isSigned :: WrappedIntegral a -> Bool #

shiftL :: WrappedIntegral a -> Int -> WrappedIntegral a #

unsafeShiftL :: WrappedIntegral a -> Int -> WrappedIntegral a #

shiftR :: WrappedIntegral a -> Int -> WrappedIntegral a #

unsafeShiftR :: WrappedIntegral a -> Int -> WrappedIntegral a #

rotateL :: WrappedIntegral a -> Int -> WrappedIntegral a #

rotateR :: WrappedIntegral a -> Int -> WrappedIntegral a #

popCount :: WrappedIntegral a -> Int #

Enum a => Enum (WrappedIntegral a) # |

Instance details

Defined in Data.Euclidean

Methods

succ :: WrappedIntegral a -> WrappedIntegral a #

pred :: WrappedIntegral a -> WrappedIntegral a #

toEnum :: Int -> WrappedIntegral a #

fromEnum :: WrappedIntegral a -> Int #

enumFrom :: WrappedIntegral a -> [WrappedIntegral a] #

enumFromThen :: WrappedIntegral a -> WrappedIntegral a -> [WrappedIntegral a] #

enumFromTo :: WrappedIntegral a -> WrappedIntegral a -> [WrappedIntegral a] #

enumFromThenTo :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a -> [WrappedIntegral a] #

Num a => Num (WrappedIntegral a) # |

Instance details

Defined in Data.Euclidean

Methods

(+) :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a #

(-) :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a #

(*) :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a #

negate :: WrappedIntegral a -> WrappedIntegral a #

abs :: WrappedIntegral a -> WrappedIntegral a #

signum :: WrappedIntegral a -> WrappedIntegral a #

fromInteger :: Integer -> WrappedIntegral a #

Integral a => Integral (WrappedIntegral a) # |

Instance details

Defined in Data.Euclidean

Methods

quot :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a #

rem :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a #

div :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a #

mod :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a #

quotRem :: WrappedIntegral a -> WrappedIntegral a -> (WrappedIntegral a, WrappedIntegral a) #

divMod :: WrappedIntegral a -> WrappedIntegral a -> (WrappedIntegral a, WrappedIntegral a) #

toInteger :: WrappedIntegral a -> Integer #

Real a => Real (WrappedIntegral a) # |
Instance details Defined in Data.Euclidean Methods toRational :: WrappedIntegral a -> Rational #
Show a => Show (WrappedIntegral a) # |
Instance details Defined in Data.Euclidean Methods showsPrec :: Int -> WrappedIntegral a -> ShowS # show :: WrappedIntegral a -> String # showList :: [WrappedIntegral a] -> ShowS #
Eq a => Eq (WrappedIntegral a) # |
Instance details Defined in Data.Euclidean Methods (==) :: WrappedIntegral a -> WrappedIntegral a -> Bool # (/=) :: WrappedIntegral a -> WrappedIntegral a -> Bool #
Ord a => Ord (WrappedIntegral a) # |

Instance details

Defined in Data.Euclidean

Methods

compare :: WrappedIntegral a -> WrappedIntegral a -> Ordering #

(<) :: WrappedIntegral a -> WrappedIntegral a -> Bool #

(<=) :: WrappedIntegral a -> WrappedIntegral a -> Bool #

(>) :: WrappedIntegral a -> WrappedIntegral a -> Bool #

(>=) :: WrappedIntegral a -> WrappedIntegral a -> Bool #

max :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a #

min :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a #

Integral a => Euclidean (WrappedIntegral a) # |
Instance details Defined in Data.Euclidean Methods quotRem :: WrappedIntegral a -> WrappedIntegral a -> (WrappedIntegral a, WrappedIntegral a) # quot :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a # rem :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a # degree :: WrappedIntegral a -> Natural #
Integral a => GcdDomain (WrappedIntegral a) # |
Instance details Defined in Data.Euclidean Methods divide :: WrappedIntegral a -> WrappedIntegral a -> Maybe (WrappedIntegral a) # gcd :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a # lcm :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a # coprime :: WrappedIntegral a -> WrappedIntegral a -> Bool #
Num a => Ring (WrappedIntegral a) # |
Instance details Defined in Data.Euclidean Methods negate :: WrappedIntegral a -> WrappedIntegral a #
Num a => Semiring (WrappedIntegral a) # |
Instance details Defined in Data.Euclidean Methods plus :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a # zero :: WrappedIntegral a # times :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a # one :: WrappedIntegral a # fromNatural :: Natural -> WrappedIntegral a #

newtype WrappedFractional a #

Wrapper around `Fractional` with trivial `GcdDomain` and `Euclidean` instances.

Constructors

WrapFractional |

Fields

- unwrapFractional :: a

#### Instances

Instances details

Num a => Num (WrappedFractional a) # |

Instance details

Defined in Data.Euclidean

Methods

(+) :: WrappedFractional a -> WrappedFractional a -> WrappedFractional a #

(-) :: WrappedFractional a -> WrappedFractional a -> WrappedFractional a #

(*) :: WrappedFractional a -> WrappedFractional a -> WrappedFractional a #

negate :: WrappedFractional a -> WrappedFractional a #

abs :: WrappedFractional a -> WrappedFractional a #

signum :: WrappedFractional a -> WrappedFractional a #

fromInteger :: Integer -> WrappedFractional a #

Fractional a => Fractional (WrappedFractional a) # |
Instance details Defined in Data.Euclidean Methods (/) :: WrappedFractional a -> WrappedFractional a -> WrappedFractional a # recip :: WrappedFractional a -> WrappedFractional a # fromRational :: Rational -> WrappedFractional a #
Show a => Show (WrappedFractional a) # |
Instance details Defined in Data.Euclidean Methods showsPrec :: Int -> WrappedFractional a -> ShowS # show :: WrappedFractional a -> String # showList :: [WrappedFractional a] -> ShowS #
Eq a => Eq (WrappedFractional a) # |
Instance details Defined in Data.Euclidean Methods (==) :: WrappedFractional a -> WrappedFractional a -> Bool # (/=) :: WrappedFractional a -> WrappedFractional a -> Bool #
Ord a => Ord (WrappedFractional a) # |

Instance details

Defined in Data.Euclidean

Methods

compare :: WrappedFractional a -> WrappedFractional a -> Ordering #

(<) :: WrappedFractional a -> WrappedFractional a -> Bool #

(<=) :: WrappedFractional a -> WrappedFractional a -> Bool #

(>) :: WrappedFractional a -> WrappedFractional a -> Bool #

(>=) :: WrappedFractional a -> WrappedFractional a -> Bool #

max :: WrappedFractional a -> WrappedFractional a -> WrappedFractional a #

min :: WrappedFractional a -> WrappedFractional a -> WrappedFractional a #

Fractional a => Euclidean (WrappedFractional a) # |
Instance details Defined in Data.Euclidean Methods quotRem :: WrappedFractional a -> WrappedFractional a -> (WrappedFractional a, WrappedFractional a) # quot :: WrappedFractional a -> WrappedFractional a -> WrappedFractional a # rem :: WrappedFractional a -> WrappedFractional a -> WrappedFractional a # degree :: WrappedFractional a -> Natural #
Fractional a => Field (WrappedFractional a) # |
Instance details Defined in Data.Euclidean
Fractional a => GcdDomain (WrappedFractional a) # |
Instance details Defined in Data.Euclidean Methods divide :: WrappedFractional a -> WrappedFractional a -> Maybe (WrappedFractional a) # gcd :: WrappedFractional a -> WrappedFractional a -> WrappedFractional a # lcm :: WrappedFractional a -> WrappedFractional a -> WrappedFractional a # coprime :: WrappedFractional a -> WrappedFractional a -> Bool #
Num a => Ring (WrappedFractional a) # |
Instance details Defined in Data.Euclidean Methods negate :: WrappedFractional a -> WrappedFractional a #
Num a => Semiring (WrappedFractional a) # |
Instance details Defined in Data.Euclidean Methods plus :: WrappedFractional a -> WrappedFractional a -> WrappedFractional a # zero :: WrappedFractional a # times :: WrappedFractional a -> WrappedFractional a -> WrappedFractional a # one :: WrappedFractional a # fromNatural :: Natural -> WrappedFractional a #

gcdExt :: (Eq a, Euclidean a, Ring a) => a -> a -> (a, a) #

Execute the extended Euclidean algorithm. For elements `a` and `b`, compute their greatest common divisor `g` and the coefficient `s` satisfying `as + bt = g` for some `t`.