arithmoi-0.5.0.0: Efficient basic number-theoretic functions.

Copyright (c) 2016 Andrew Lelechenko MIT Andrew Lelechenko Provisional Non-portable (GHC extensions) None Haskell2010

Math.NumberTheory.UniqueFactorisation

Description

An abstract type class for unique factorisation domains.

Synopsis

# Documentation

type family Prime (f :: *) :: * Source #

Type of primes of a given unique factorisation domain. When the domain has exactly one unit, Prime t = t, but when units are multiple more restricted types (or at least newtypes) should be specified.

abs (unPrime n) == unPrime n must hold for all n of type Prime t

Instances

 type Prime Int Source # type Prime Int type Prime Integer Source # type Prime Integer type Prime Word Source # type Prime Word type Prime Natural Source # type Prime Natural Source #

class UniqueFactorisation a where Source #

The following invariant must hold for n /= 0:

abs n == abs (product (map (\(p, k) -> unPrime p ^ k) (factorise n)))

The result of factorise should not contain zero powers and should not change after multiplication of the argument by domain's unit.

Minimal complete definition

Methods

unPrime :: Prime a -> a Source #

factorise :: a -> [(Prime a, Word)] Source #

Instances

 Source # Methodsfactorise :: Int -> [(Prime Int, Word)] Source # Source # Methodsfactorise :: Integer -> [(Prime Integer, Word)] Source # Source # Methodsfactorise :: Word -> [(Prime Word, Word)] Source # Source # Methodsfactorise :: Natural -> [(Prime Natural, Word)] Source # Source # Methods