semirings-0.7: two monoids as one, in holy haskimony
Copyright(C) 2021 Koz Ross
LicenseBSD3
MaintainerKoz Ross <koz.ross@retro-freedom.nz>
Stabilitystable
PortabilityGHC only
Safe HaskellTrustworthy
LanguageHaskell98

Data.Ring.Ordered

Description

An 'ordered ring' is a ring with a total order.

Mathematical pedantry note

Many (if not most) of the instances of the OrderedRing type class are not truly ordered rings in the mathematical sense, as the axioms imply that the underlying set is either a singleton or infinite. Thus, the additional properties of ordered rings do not, in general, hold.

We indicate those instances that are 'truly' or 'mathematically' ordered rings in their documentation.

Synopsis

Helper types

newtype Modular a Source #

A wrapper to indicate the type is being treated as a modular arithmetic system whose modulus is the type's cardinality.

While we cannot guarantee that infinite types won't be wrapped by this, we only provide instances of the relevant type classes for those types we are certain are finite.

Since: 0.7

Constructors

Modular 

Fields

Instances

Instances details
Data a => Data (Modular a) Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Modular a -> c (Modular a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Modular a) #

toConstr :: Modular a -> Constr #

dataTypeOf :: Modular a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Modular a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Modular a)) #

gmapT :: (forall b. Data b => b -> b) -> Modular a -> Modular a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Modular a -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Modular a -> r #

gmapQ :: (forall d. Data d => d -> u) -> Modular a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Modular a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Modular a -> m (Modular a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Modular a -> m (Modular a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Modular a -> m (Modular a) #

Bounded a => Bounded (Modular a) Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

Generic (Modular a) Source # 
Instance details

Defined in Data.Ring.Ordered

Associated Types

type Rep (Modular a) :: Type -> Type #

Methods

from :: Modular a -> Rep (Modular a) x #

to :: Rep (Modular a) x -> Modular a #

Read a => Read (Modular a) Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

Show a => Show (Modular a) Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

Methods

showsPrec :: Int -> Modular a -> ShowS #

show :: Modular a -> String #

showList :: [Modular a] -> ShowS #

Eq a => Eq (Modular a) Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

Methods

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

(/=) :: Modular a -> Modular a -> Bool #

Ord a => Ord (Modular a) Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

Methods

compare :: Modular a -> Modular a -> Ordering #

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

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

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

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

max :: Modular a -> Modular a -> Modular a #

min :: Modular a -> Modular a -> Modular a #

OrderedRing (Modular Word16) Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

OrderedRing (Modular Word32) Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

OrderedRing (Modular Word64) Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

OrderedRing (Modular Word8) Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

OrderedRing (Modular Word) Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

Ring (Modular Word16) Source # 
Instance details

Defined in Data.Ring.Ordered

Ring (Modular Word32) Source # 
Instance details

Defined in Data.Ring.Ordered

Ring (Modular Word64) Source # 
Instance details

Defined in Data.Ring.Ordered

Ring (Modular Word8) Source # 
Instance details

Defined in Data.Ring.Ordered

Ring (Modular Word) Source # 
Instance details

Defined in Data.Ring.Ordered

Semiring (Modular Word16) Source # 
Instance details

Defined in Data.Ring.Ordered

Semiring (Modular Word32) Source # 
Instance details

Defined in Data.Ring.Ordered

Semiring (Modular Word64) Source # 
Instance details

Defined in Data.Ring.Ordered

Semiring (Modular Word8) Source # 
Instance details

Defined in Data.Ring.Ordered

Semiring (Modular Word) Source # 
Instance details

Defined in Data.Ring.Ordered

type Rep (Modular a) Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

type Rep (Modular a) = D1 ('MetaData "Modular" "Data.Ring.Ordered" "semirings-0.7-IT1UKobn80nYNk4WFT2qF" 'True) (C1 ('MetaCons "Modular" 'PrefixI 'True) (S1 ('MetaSel ('Just "getModular") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Ordered ring type class

class (Ring a, Ord a) => OrderedRing a where Source #

The class of rings which also have a total order.

Instance should satisfy the following laws:

Since: 0.7

Methods

abs :: a -> a Source #

Compute the absolute value.

signum :: a -> a Source #

Determine the 'sign' of a value.

Instances

Instances details
OrderedRing Int16 Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

OrderedRing Int32 Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

OrderedRing Int64 Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

OrderedRing Int8 Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

Methods

abs :: Int8 -> Int8 Source #

signum :: Int8 -> Int8 Source #

OrderedRing Integer Source #

This instance is a 'true' or 'mathematical' ordered ring, as Integer is an infinite type.

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

OrderedRing () Source #

This instance is a 'true' or 'mathematical' ordered ring, as it is a singleton. We assume that () has a zero signum.

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

Methods

abs :: () -> () Source #

signum :: () -> () Source #

OrderedRing Int Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

Methods

abs :: Int -> Int Source #

signum :: Int -> Int Source #

OrderedRing a => OrderedRing (Identity a) Source #

Where a is a 'true' or 'mathematical' ordered ring, so is this.

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

OrderedRing a => OrderedRing (Down a) Source #

Where a is a 'true' or 'mathematical' ordered ring, so is this.

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

Methods

abs :: Down a -> Down a Source #

signum :: Down a -> Down a Source #

OrderedRing a => OrderedRing (Dual a) Source #

Where a is a 'true' or 'mathematical' ordered ring, so is this.

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

Methods

abs :: Dual a -> Dual a Source #

signum :: Dual a -> Dual a Source #

Integral a => OrderedRing (Ratio a) Source #

Where a ~ Integer, this instance is a 'true' or 'mathematical' ordered ring, as the resulting type is infinite.

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

Methods

abs :: Ratio a -> Ratio a Source #

signum :: Ratio a -> Ratio a Source #

OrderedRing (Modular Word16) Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

OrderedRing (Modular Word32) Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

OrderedRing (Modular Word64) Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

OrderedRing (Modular Word8) Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

OrderedRing (Modular Word) Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

HasResolution a => OrderedRing (Fixed a) Source #

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

Methods

abs :: Fixed a -> Fixed a Source #

signum :: Fixed a -> Fixed a Source #

OrderedRing a => OrderedRing (Const a b) Source #

Where a is a 'true' or 'mathematical' ordered ring, so is this.

Since: 0.7

Instance details

Defined in Data.Ring.Ordered

Methods

abs :: Const a b -> Const a b Source #

signum :: Const a b -> Const a b Source #