| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
Data.Semiring
Description
A class for semirings (types with two binary operations, one commutative and one associative, and two respective identities), with various general-purpose instances.
Synopsis
- class Semiring a where
- plus :: a -> a -> a
- zero :: a
- times :: a -> a -> a
- one :: a
- fromNatural :: Natural -> a
- (+) :: Semiring a => a -> a -> a
- (*) :: Semiring a => a -> a -> a
- (^) :: (Semiring a, Integral b) => a -> b -> a
- foldMapP :: (Foldable t, Semiring s) => (a -> s) -> t a -> s
- foldMapT :: (Foldable t, Semiring s) => (a -> s) -> t a -> s
- sum :: (Foldable t, Semiring a) => t a -> a
- product :: (Foldable t, Semiring a) => t a -> a
- sum' :: (Foldable t, Semiring a) => t a -> a
- product' :: (Foldable t, Semiring a) => t a -> a
- isZero :: (Eq a, Semiring a) => a -> Bool
- isOne :: (Eq a, Semiring a) => a -> Bool
- newtype Add a = Add {
- getAdd :: a
- newtype Mul a = Mul {
- getMul :: a
- newtype WrappedNum a = WrapNum {
- unwrapNum :: a
- newtype Mod2 = Mod2 {
- getMod2 :: Bool
- newtype IntSetOf a = IntSetOf {
- getIntSet :: IntSet
- newtype IntMapOf k v = IntMapOf {
- getIntMap :: IntMap v
- class Semiring a => Ring a where
- negate :: a -> a
- fromInteger :: Ring a => Integer -> a
- fromIntegral :: (Integral a, Ring b) => a -> b
- minus :: Ring a => a -> a -> a
- (-) :: Ring a => a -> a -> a
Semiring typeclass
class Semiring a where Source #
The class of semirings (types with two binary
operations and two respective identities). One
can think of a semiring as two monoids of the same
underlying type, with the first being commutative.
In the documentation, you will often see the first
monoid being referred to as additive, and the second
monoid being referred to as multiplicative, a typical
convention when talking about semirings.
For any type R with a Num
instance, the additive monoid is (R, +, 0)
and the multiplicative monoid is (R, *, 1).
For Bool, the additive monoid is (Bool, ||, False)
and the multiplicative monoid is (Bool, &&, True).
Instances should satisfy the following laws:
- additive left identity
zero+x = x- additive right identity
x+zero= x- additive associativity
x+(y+z) = (x+y)+z- additive commutativity
x+y = y+x- multiplicative left identity
one*x = x- multiplicative right identity
x*one= x- multiplicative associativity
x*(y*z) = (x*y)*z- left-distributivity of
*over+ x*(y+z) = (x*y)+(x*z)- right-distributivity of
*over+ (x+y)*z = (x*z)+(y*z)- annihilation
zero*x = x*zero=zero
Minimal complete definition
plus, times, (zero, one | fromNatural)
Methods
Arguments
| :: a | |
| -> a | |
| -> a | Commutative Operation |
Arguments
| :: a | Commutative Unit |
Arguments
| :: a | |
| -> a | |
| -> a | Associative Operation |
Arguments
| :: a | Associative Unit |
Arguments
| :: Natural | |
| -> a | Homomorphism of additive semigroups |
Instances
| Semiring CChar Source # | |
| Semiring CClock Source # | |
| Semiring CDouble Source # | |
| Semiring CFloat Source # | |
| Semiring CInt Source # | |
| Semiring CIntMax Source # | |
| Semiring CIntPtr Source # | |
| Semiring CLLong Source # | |
| Semiring CLong Source # | |
| Semiring CPtrdiff Source # | |
| Semiring CSChar Source # | |
| Semiring CSUSeconds Source # | |
| Semiring CShort Source # | |
| Semiring CSigAtomic Source # | |
| Semiring CSize Source # | |
| Semiring CTime Source # | |
| Semiring CUChar Source # | |
| Semiring CUInt Source # | |
| Semiring CUIntMax Source # | |
| Semiring CUIntPtr Source # | |
| Semiring CULLong Source # | |
| Semiring CULong Source # | |
| Semiring CUSeconds Source # | |
| Semiring CUShort Source # | |
| Semiring CWchar Source # | |
| Semiring IntPtr Source # | |
| Semiring WordPtr Source # | |
| Semiring Int16 Source # | |
| Semiring Int32 Source # | |
| Semiring Int64 Source # | |
| Semiring Int8 Source # | |
| Semiring CCc Source # | |
| Semiring CDev Source # | |
| Semiring CGid Source # | |
| Semiring CIno Source # | |
| Semiring CMode Source # | |
| Semiring CNlink Source # | |
| Semiring COff Source # | |
| Semiring CPid Source # | |
| Semiring CRLim Source # | |
| Semiring CSpeed Source # | |
| Semiring CSsize Source # | |
| Semiring CTcflag Source # | |
| Semiring CUid Source # | |
| Semiring Fd Source # | |
| Semiring Word16 Source # | |
| Semiring Word32 Source # | |
| Semiring Word64 Source # | |
| Semiring Word8 Source # | |
| Semiring Mod2 Source # | |
| Semiring Directed Source # | Since: 0.7 |
| Semiring Integer Source # | |
| Semiring Natural Source # | |
| Semiring () Source # | |
| Semiring Bool Source # | |
| Semiring Double Source # | |
| Semiring Float Source # | |
| Semiring Int Source # | |
| Semiring Word Source # | |
| Ring a => Semiring (Complex a) Source # | This instance can suffer due to floating point arithmetic. |
| Semiring a => Semiring (Equivalence a) Source # | |
| Semiring (Predicate a) Source # | |
| (Ord a, Monoid a) => Semiring (Set a) Source # | The multiplication laws are satisfied for
any underlying |
| Semiring a => Semiring (Identity a) Source # | |
| Semiring a => Semiring (Down a) Source # | |
| Semiring a => Semiring (Dual a) Source # | |
| Integral a => Semiring (Ratio a) Source # | |
| Semiring a => Semiring (IO a) Source # | |
| Num a => Semiring (WrappedFractional a) Source # | |
Defined in Data.Euclidean Methods plus :: WrappedFractional a -> WrappedFractional a -> WrappedFractional a Source # zero :: WrappedFractional a Source # times :: WrappedFractional a -> WrappedFractional a -> WrappedFractional a Source # one :: WrappedFractional a Source # fromNatural :: Natural -> WrappedFractional a Source # | |
| Num a => Semiring (WrappedIntegral a) Source # | |
Defined in Data.Euclidean Methods plus :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a Source # zero :: WrappedIntegral a Source # times :: WrappedIntegral a -> WrappedIntegral a -> WrappedIntegral a Source # one :: WrappedIntegral a Source # fromNatural :: Natural -> WrappedIntegral a Source # | |
| Semiring (Modular Word16) Source # | |
| Semiring (Modular Word32) Source # | |
| Semiring (Modular Word64) Source # | |
| Semiring (Modular Word8) Source # | |
| Semiring (Modular Word) Source # | |
| (Coercible Int a, Monoid a) => Semiring (IntSetOf a) Source # | |
| Num a => Semiring (WrappedNum a) Source # | |
Defined in Data.Semiring Methods plus :: WrappedNum a -> WrappedNum a -> WrappedNum a Source # zero :: WrappedNum a Source # times :: WrappedNum a -> WrappedNum a -> WrappedNum a Source # one :: WrappedNum a Source # fromNatural :: Natural -> WrappedNum a Source # | |
| (Generic a, GSemiring (Rep a)) => Semiring (GenericSemiring a) Source # | |
Defined in Data.Semiring.Generic Methods plus :: GenericSemiring a -> GenericSemiring a -> GenericSemiring a Source # zero :: GenericSemiring a Source # times :: GenericSemiring a -> GenericSemiring a -> GenericSemiring a Source # one :: GenericSemiring a Source # fromNatural :: Natural -> GenericSemiring a Source # | |
| (Eq a, Hashable a, Monoid a) => Semiring (HashSet a) Source # | The multiplication laws are satisfied for
any underlying |
| Semiring a => Semiring (Maybe a) Source # | |
| HasResolution a => Semiring (Fixed a) Source # | |
| Semiring a => Semiring (Op a b) Source # | |
| (Ord k, Monoid k, Semiring v) => Semiring (Map k v) Source # | The multiplication laws are satisfied for
any underlying |
| Semiring (Proxy a) Source # | |
| (Coercible Int k, Monoid k, Semiring v) => Semiring (IntMapOf k v) Source # | |
| (Ord a, Monoid a, Extremum e) => Semiring (Tropical e a) Source # | |
| (Eq k, Hashable k, Monoid k, Semiring v) => Semiring (HashMap k v) Source # | The multiplication laws are satisfied for
any underlying |
| (Semiring a, Semiring b) => Semiring (a, b) Source # | |
| Semiring b => Semiring (a -> b) Source # | |
| Semiring a => Semiring (Const a b) Source # | |
| (Semiring a, Applicative f) => Semiring (Ap f a) Source # | |
| (Semiring a, Semiring b, Semiring c) => Semiring (a, b, c) Source # | |
| (Semiring a, Semiring b, Semiring c, Semiring d) => Semiring (a, b, c, d) Source # | |
| (Semiring a, Semiring b, Semiring c, Semiring d, Semiring e) => Semiring (a, b, c, d, e) Source # | |
| (Semiring a, Semiring b, Semiring c, Semiring d, Semiring e, Semiring f) => Semiring (a, b, c, d, e, f) Source # | |
Defined in Data.Semiring | |
| (Semiring a, Semiring b, Semiring c, Semiring d, Semiring e, Semiring f, Semiring g) => Semiring (a, b, c, d, e, f, g) Source # | |
Defined in Data.Semiring Methods plus :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) Source # zero :: (a, b, c, d, e, f, g) Source # times :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) Source # one :: (a, b, c, d, e, f, g) Source # fromNatural :: Natural -> (a, b, c, d, e, f, g) Source # | |
(^) :: (Semiring a, Integral b) => a -> b -> a infixr 8 Source #
Raise a number to a non-negative integral power.
If the power is negative, this will call error.
foldMapP :: (Foldable t, Semiring s) => (a -> s) -> t a -> s Source #
Map each element of the structure to a semiring, and combine the results
using plus.
foldMapT :: (Foldable t, Semiring s) => (a -> s) -> t a -> s Source #
Map each element of the structure to a semiring, and combine the results
using times.
Types
Instances
| Functor Add Source # | |||||
| Foldable Add Source # | |||||
Defined in Data.Semiring Methods fold :: Monoid m => Add m -> m foldMap :: Monoid m => (a -> m) -> Add a -> m foldMap' :: Monoid m => (a -> m) -> Add a -> m foldr :: (a -> b -> b) -> b -> Add a -> b foldr' :: (a -> b -> b) -> b -> Add a -> b foldl :: (b -> a -> b) -> b -> Add a -> b foldl' :: (b -> a -> b) -> b -> Add a -> b foldr1 :: (a -> a -> a) -> Add a -> a foldl1 :: (a -> a -> a) -> Add a -> a elem :: Eq a => a -> Add a -> Bool maximum :: Ord a => Add a -> a | |||||
| Traversable Add Source # | |||||
| Generic1 Add Source # | |||||
Defined in Data.Semiring Associated Types
| |||||
| Semiring a => Monoid (Add a) Source # | |||||
| Semiring a => Semigroup (Add a) Source # | |||||
| Bounded a => Bounded (Add a) Source # | |||||
Defined in Data.Semiring | |||||
| Enum a => Enum (Add a) Source # | |||||
| Storable a => Storable (Add a) Source # | |||||
Defined in Data.Semiring Methods peekElemOff :: Ptr (Add a) -> Int -> IO (Add a) pokeElemOff :: Ptr (Add a) -> Int -> Add a -> IO () peekByteOff :: Ptr b -> Int -> IO (Add a) pokeByteOff :: Ptr b -> Int -> Add a -> IO () | |||||
| Generic (Add a) Source # | |||||
Defined in Data.Semiring Associated Types
| |||||
| Num a => Num (Add a) Source # | |||||
| Read a => Read (Add a) Source # | |||||
Defined in Data.Semiring | |||||
| Fractional a => Fractional (Add a) Source # | |||||
Defined in Data.Semiring | |||||
| Real a => Real (Add a) Source # | |||||
Defined in Data.Semiring Methods toRational :: Add a -> Rational | |||||
| RealFrac a => RealFrac (Add a) Source # | |||||
| Show a => Show (Add a) Source # | |||||
| Eq a => Eq (Add a) Source # | |||||
| Ord a => Ord (Add a) Source # | |||||
| type Rep1 Add Source # | |||||
Defined in Data.Semiring type Rep1 Add = D1 ('MetaData "Add" "Data.Semiring" "semirings-0.7-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "Add" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAdd") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1)) | |||||
| type Rep (Add a) Source # | |||||
Defined in Data.Semiring type Rep (Add a) = D1 ('MetaData "Add" "Data.Semiring" "semirings-0.7-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "Add" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAdd") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) | |||||
Instances
| Functor Mul Source # | |||||
| Foldable Mul Source # | |||||
Defined in Data.Semiring Methods fold :: Monoid m => Mul m -> m foldMap :: Monoid m => (a -> m) -> Mul a -> m foldMap' :: Monoid m => (a -> m) -> Mul a -> m foldr :: (a -> b -> b) -> b -> Mul a -> b foldr' :: (a -> b -> b) -> b -> Mul a -> b foldl :: (b -> a -> b) -> b -> Mul a -> b foldl' :: (b -> a -> b) -> b -> Mul a -> b foldr1 :: (a -> a -> a) -> Mul a -> a foldl1 :: (a -> a -> a) -> Mul a -> a elem :: Eq a => a -> Mul a -> Bool maximum :: Ord a => Mul a -> a | |||||
| Traversable Mul Source # | |||||
| Generic1 Mul Source # | |||||
Defined in Data.Semiring Associated Types
| |||||
| Semiring a => Monoid (Mul a) Source # | |||||
| Semiring a => Semigroup (Mul a) Source # | |||||
| Bounded a => Bounded (Mul a) Source # | |||||
Defined in Data.Semiring | |||||
| Enum a => Enum (Mul a) Source # | |||||
| Storable a => Storable (Mul a) Source # | |||||
Defined in Data.Semiring Methods peekElemOff :: Ptr (Mul a) -> Int -> IO (Mul a) pokeElemOff :: Ptr (Mul a) -> Int -> Mul a -> IO () peekByteOff :: Ptr b -> Int -> IO (Mul a) pokeByteOff :: Ptr b -> Int -> Mul a -> IO () | |||||
| Generic (Mul a) Source # | |||||
Defined in Data.Semiring Associated Types
| |||||
| Num a => Num (Mul a) Source # | |||||
| Read a => Read (Mul a) Source # | |||||
Defined in Data.Semiring | |||||
| Fractional a => Fractional (Mul a) Source # | |||||
Defined in Data.Semiring | |||||
| Real a => Real (Mul a) Source # | |||||
Defined in Data.Semiring Methods toRational :: Mul a -> Rational | |||||
| RealFrac a => RealFrac (Mul a) Source # | |||||
| Show a => Show (Mul a) Source # | |||||
| Eq a => Eq (Mul a) Source # | |||||
| Ord a => Ord (Mul a) Source # | |||||
| type Rep1 Mul Source # | |||||
Defined in Data.Semiring type Rep1 Mul = D1 ('MetaData "Mul" "Data.Semiring" "semirings-0.7-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "Mul" 'PrefixI 'True) (S1 ('MetaSel ('Just "getMul") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1)) | |||||
| type Rep (Mul a) Source # | |||||
Defined in Data.Semiring type Rep (Mul a) = D1 ('MetaData "Mul" "Data.Semiring" "semirings-0.7-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "Mul" 'PrefixI 'True) (S1 ('MetaSel ('Just "getMul") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) | |||||
newtype WrappedNum a Source #
Provide Semiring and Ring for an arbitrary Num. It is useful with GHC 8.6+'s DerivingVia extension.
Instances
| Functor WrappedNum Source # | |||||
Defined in Data.Semiring | |||||
| Foldable WrappedNum Source # | |||||
Defined in Data.Semiring Methods fold :: Monoid m => WrappedNum m -> m foldMap :: Monoid m => (a -> m) -> WrappedNum a -> m foldMap' :: Monoid m => (a -> m) -> WrappedNum a -> m foldr :: (a -> b -> b) -> b -> WrappedNum a -> b foldr' :: (a -> b -> b) -> b -> WrappedNum a -> b foldl :: (b -> a -> b) -> b -> WrappedNum a -> b foldl' :: (b -> a -> b) -> b -> WrappedNum a -> b foldr1 :: (a -> a -> a) -> WrappedNum a -> a foldl1 :: (a -> a -> a) -> WrappedNum a -> a toList :: WrappedNum a -> [a] null :: WrappedNum a -> Bool length :: WrappedNum a -> Int elem :: Eq a => a -> WrappedNum a -> Bool maximum :: Ord a => WrappedNum a -> a minimum :: Ord a => WrappedNum a -> a sum :: Num a => WrappedNum a -> a product :: Num a => WrappedNum a -> a | |||||
| Traversable WrappedNum Source # | |||||
Defined in Data.Semiring Methods traverse :: Applicative f => (a -> f b) -> WrappedNum a -> f (WrappedNum b) sequenceA :: Applicative f => WrappedNum (f a) -> f (WrappedNum a) mapM :: Monad m => (a -> m b) -> WrappedNum a -> m (WrappedNum b) sequence :: Monad m => WrappedNum (m a) -> m (WrappedNum a) | |||||
| Generic1 WrappedNum Source # | |||||
Defined in Data.Semiring Associated Types
| |||||
| Bits a => Bits (WrappedNum a) Source # | |||||
Defined in Data.Semiring Methods (.&.) :: WrappedNum a -> WrappedNum a -> WrappedNum a (.|.) :: WrappedNum a -> WrappedNum a -> WrappedNum a xor :: WrappedNum a -> WrappedNum a -> WrappedNum a complement :: WrappedNum a -> WrappedNum a shift :: WrappedNum a -> Int -> WrappedNum a rotate :: WrappedNum a -> Int -> WrappedNum a zeroBits :: WrappedNum a bit :: Int -> WrappedNum a setBit :: WrappedNum a -> Int -> WrappedNum a clearBit :: WrappedNum a -> Int -> WrappedNum a complementBit :: WrappedNum a -> Int -> WrappedNum a testBit :: WrappedNum a -> Int -> Bool bitSizeMaybe :: WrappedNum a -> Maybe Int bitSize :: WrappedNum a -> Int isSigned :: WrappedNum a -> Bool shiftL :: WrappedNum a -> Int -> WrappedNum a unsafeShiftL :: WrappedNum a -> Int -> WrappedNum a shiftR :: WrappedNum a -> Int -> WrappedNum a unsafeShiftR :: WrappedNum a -> Int -> WrappedNum a rotateL :: WrappedNum a -> Int -> WrappedNum a rotateR :: WrappedNum a -> Int -> WrappedNum a popCount :: WrappedNum a -> Int | |||||
| Bounded a => Bounded (WrappedNum a) Source # | |||||
Defined in Data.Semiring | |||||
| Enum a => Enum (WrappedNum a) Source # | |||||
Defined in Data.Semiring Methods succ :: WrappedNum a -> WrappedNum a pred :: WrappedNum a -> WrappedNum a toEnum :: Int -> WrappedNum a fromEnum :: WrappedNum a -> Int enumFrom :: WrappedNum a -> [WrappedNum a] enumFromThen :: WrappedNum a -> WrappedNum a -> [WrappedNum a] enumFromTo :: WrappedNum a -> WrappedNum a -> [WrappedNum a] enumFromThenTo :: WrappedNum a -> WrappedNum a -> WrappedNum a -> [WrappedNum a] | |||||
| Storable a => Storable (WrappedNum a) Source # | |||||
Defined in Data.Semiring Methods sizeOf :: WrappedNum a -> Int alignment :: WrappedNum a -> Int peekElemOff :: Ptr (WrappedNum a) -> Int -> IO (WrappedNum a) pokeElemOff :: Ptr (WrappedNum a) -> Int -> WrappedNum a -> IO () peekByteOff :: Ptr b -> Int -> IO (WrappedNum a) pokeByteOff :: Ptr b -> Int -> WrappedNum a -> IO () peek :: Ptr (WrappedNum a) -> IO (WrappedNum a) poke :: Ptr (WrappedNum a) -> WrappedNum a -> IO () | |||||
| Generic (WrappedNum a) Source # | |||||
Defined in Data.Semiring Associated Types
| |||||
| Num a => Num (WrappedNum a) Source # | |||||
Defined in Data.Semiring Methods (+) :: WrappedNum a -> WrappedNum a -> WrappedNum a (-) :: WrappedNum a -> WrappedNum a -> WrappedNum a (*) :: WrappedNum a -> WrappedNum a -> WrappedNum a negate :: WrappedNum a -> WrappedNum a abs :: WrappedNum a -> WrappedNum a signum :: WrappedNum a -> WrappedNum a fromInteger :: Integer -> WrappedNum a | |||||
| Read a => Read (WrappedNum a) Source # | |||||
Defined in Data.Semiring Methods readsPrec :: Int -> ReadS (WrappedNum a) readList :: ReadS [WrappedNum a] readPrec :: ReadPrec (WrappedNum a) readListPrec :: ReadPrec [WrappedNum a] | |||||
| Fractional a => Fractional (WrappedNum a) Source # | |||||
Defined in Data.Semiring Methods (/) :: WrappedNum a -> WrappedNum a -> WrappedNum a recip :: WrappedNum a -> WrappedNum a fromRational :: Rational -> WrappedNum a | |||||
| Real a => Real (WrappedNum a) Source # | |||||
Defined in Data.Semiring Methods toRational :: WrappedNum a -> Rational | |||||
| RealFrac a => RealFrac (WrappedNum a) Source # | |||||
Defined in Data.Semiring Methods properFraction :: Integral b => WrappedNum a -> (b, WrappedNum a) truncate :: Integral b => WrappedNum a -> b round :: Integral b => WrappedNum a -> b ceiling :: Integral b => WrappedNum a -> b floor :: Integral b => WrappedNum a -> b | |||||
| Show a => Show (WrappedNum a) Source # | |||||
Defined in Data.Semiring Methods showsPrec :: Int -> WrappedNum a -> ShowS show :: WrappedNum a -> String showList :: [WrappedNum a] -> ShowS | |||||
| Eq a => Eq (WrappedNum a) Source # | |||||
Defined in Data.Semiring | |||||
| Ord a => Ord (WrappedNum a) Source # | |||||
Defined in Data.Semiring Methods compare :: WrappedNum a -> WrappedNum a -> Ordering (<) :: WrappedNum a -> WrappedNum a -> Bool (<=) :: WrappedNum a -> WrappedNum a -> Bool (>) :: WrappedNum a -> WrappedNum a -> Bool (>=) :: WrappedNum a -> WrappedNum a -> Bool max :: WrappedNum a -> WrappedNum a -> WrappedNum a min :: WrappedNum a -> WrappedNum a -> WrappedNum a | |||||
| Num a => Ring (WrappedNum a) Source # | |||||
Defined in Data.Semiring Methods negate :: WrappedNum a -> WrappedNum a Source # | |||||
| Num a => Semiring (WrappedNum a) Source # | |||||
Defined in Data.Semiring Methods plus :: WrappedNum a -> WrappedNum a -> WrappedNum a Source # zero :: WrappedNum a Source # times :: WrappedNum a -> WrappedNum a -> WrappedNum a Source # one :: WrappedNum a Source # fromNatural :: Natural -> WrappedNum a Source # | |||||
| type Rep1 WrappedNum Source # | |||||
Defined in Data.Semiring type Rep1 WrappedNum = D1 ('MetaData "WrappedNum" "Data.Semiring" "semirings-0.7-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "WrapNum" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapNum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1)) | |||||
| type Rep (WrappedNum a) Source # | |||||
Defined in Data.Semiring type Rep (WrappedNum a) = D1 ('MetaData "WrappedNum" "Data.Semiring" "semirings-0.7-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "WrapNum" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapNum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) | |||||
Mod2 represents the integers mod 2.
It is useful in the computing of Zhegalkin polynomials.
Instances
| Bounded Mod2 Source # | |||||
Defined in Data.Semiring | |||||
| Enum Mod2 Source # | |||||
| Generic Mod2 Source # | |||||
Defined in Data.Semiring Associated Types
| |||||
| Read Mod2 Source # | |||||
Defined in Data.Semiring | |||||
| Show Mod2 Source # | |||||
| Eq Mod2 Source # | |||||
| Ord Mod2 Source # | |||||
| Euclidean Mod2 Source # | |||||
| Field Mod2 Source # | |||||
Defined in Data.Euclidean | |||||
| GcdDomain Mod2 Source # | |||||
| Ring Mod2 Source # | |||||
| Semiring Mod2 Source # | |||||
| Star Mod2 Source # | |||||
| type Rep Mod2 Source # | |||||
Defined in Data.Semiring type Rep Mod2 = D1 ('MetaData "Mod2" "Data.Semiring" "semirings-0.7-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "Mod2" 'PrefixI 'True) (S1 ('MetaSel ('Just "getMod2") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool))) | |||||
Wrapper to mimic Set (Sum Int),
Set (Product Int), etc.,
while having a more efficient underlying representation.
Instances
| Generic1 IntSetOf Source # | |||||
Defined in Data.Semiring Associated Types
| |||||
| Monoid (IntSetOf a) Source # | |||||
| Semigroup (IntSetOf a) Source # | |||||
| Generic (IntSetOf a) Source # | |||||
Defined in Data.Semiring Associated Types
| |||||
| Read (IntSetOf a) Source # | |||||
Defined in Data.Semiring | |||||
| Show (IntSetOf a) Source # | |||||
| Eq (IntSetOf a) Source # | |||||
| Ord (IntSetOf a) Source # | |||||
| (Coercible Int a, Monoid a) => Semiring (IntSetOf a) Source # | |||||
| type Rep1 IntSetOf Source # | |||||
Defined in Data.Semiring type Rep1 IntSetOf = D1 ('MetaData "IntSetOf" "Data.Semiring" "semirings-0.7-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "IntSetOf" 'PrefixI 'True) (S1 ('MetaSel ('Just "getIntSet") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IntSet))) | |||||
| type Rep (IntSetOf a) Source # | |||||
Defined in Data.Semiring type Rep (IntSetOf a) = D1 ('MetaData "IntSetOf" "Data.Semiring" "semirings-0.7-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "IntSetOf" 'PrefixI 'True) (S1 ('MetaSel ('Just "getIntSet") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IntSet))) | |||||
Wrapper to mimic Map (Sum Int) v,
Map (Product Int) v, etc.,
while having a more efficient underlying representation.
Instances
| Generic1 (IntMapOf k :: Type -> Type) Source # | |||||
Defined in Data.Semiring Associated Types
| |||||
| Monoid (IntMapOf k v) Source # | |||||
| Semigroup (IntMapOf k v) Source # | |||||
| Generic (IntMapOf k v) Source # | |||||
Defined in Data.Semiring Associated Types
| |||||
| Read v => Read (IntMapOf k v) Source # | |||||
Defined in Data.Semiring | |||||
| Show v => Show (IntMapOf k v) Source # | |||||
| Eq v => Eq (IntMapOf k v) Source # | |||||
| Ord v => Ord (IntMapOf k v) Source # | |||||
Defined in Data.Semiring | |||||
| (Coercible Int k, Monoid k, Semiring v) => Semiring (IntMapOf k v) Source # | |||||
| type Rep1 (IntMapOf k :: Type -> Type) Source # | |||||
Defined in Data.Semiring type Rep1 (IntMapOf k :: Type -> Type) = D1 ('MetaData "IntMapOf" "Data.Semiring" "semirings-0.7-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "IntMapOf" 'PrefixI 'True) (S1 ('MetaSel ('Just "getIntMap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 IntMap))) | |||||
| type Rep (IntMapOf k v) Source # | |||||
Defined in Data.Semiring type Rep (IntMapOf k v) = D1 ('MetaData "IntMapOf" "Data.Semiring" "semirings-0.7-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "IntMapOf" 'PrefixI 'True) (S1 ('MetaSel ('Just "getIntMap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (IntMap v)))) | |||||
Ring typeclass
class Semiring a => Ring a where Source #
Instances
fromInteger :: Ring a => Integer -> a Source #
fromIntegral :: (Integral a, Ring b) => a -> b Source #
Convert from integral to ring.