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

Safe Haskell | None
Language | Haskell98

Data.Semiring

Contents

- Semiring typeclass
- Types
- Ring typeclass

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 #

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

plus infixl 6 #

Arguments

:: a |
-> a |
-> a | Commutative Operation

zero #

Arguments

:: a | Commutative Unit

times infixl 7 #

Arguments

:: a |
-> a |
-> a | Associative Operation

one #

Arguments

:: a | Associative Unit

fromNatural #

Arguments

:: Natural |
-> a | Homomorphism of additive semigroups

#### Instances

Instances details

Semiring CChar # |
Instance details Defined in Data.Semiring Methods plus :: CChar -> CChar -> CChar # zero :: CChar # times :: CChar -> CChar -> CChar # one :: CChar # fromNatural :: Natural -> CChar #
Semiring CClock # |
Instance details Defined in Data.Semiring Methods plus :: CClock -> CClock -> CClock # zero :: CClock # times :: CClock -> CClock -> CClock # one :: CClock # fromNatural :: Natural -> CClock #
Semiring CDouble # |
Instance details Defined in Data.Semiring Methods plus :: CDouble -> CDouble -> CDouble # zero :: CDouble # times :: CDouble -> CDouble -> CDouble # one :: CDouble # fromNatural :: Natural -> CDouble #
Semiring CFloat # |
Instance details Defined in Data.Semiring Methods plus :: CFloat -> CFloat -> CFloat # zero :: CFloat # times :: CFloat -> CFloat -> CFloat # one :: CFloat # fromNatural :: Natural -> CFloat #
Semiring CInt # |
Instance details Defined in Data.Semiring Methods plus :: CInt -> CInt -> CInt # zero :: CInt # times :: CInt -> CInt -> CInt # one :: CInt # fromNatural :: Natural -> CInt #
Semiring CIntMax # |
Instance details Defined in Data.Semiring Methods plus :: CIntMax -> CIntMax -> CIntMax # zero :: CIntMax # times :: CIntMax -> CIntMax -> CIntMax # one :: CIntMax # fromNatural :: Natural -> CIntMax #
Semiring CIntPtr # |
Instance details Defined in Data.Semiring Methods plus :: CIntPtr -> CIntPtr -> CIntPtr # zero :: CIntPtr # times :: CIntPtr -> CIntPtr -> CIntPtr # one :: CIntPtr # fromNatural :: Natural -> CIntPtr #
Semiring CLLong # |
Instance details Defined in Data.Semiring Methods plus :: CLLong -> CLLong -> CLLong # zero :: CLLong # times :: CLLong -> CLLong -> CLLong # one :: CLLong # fromNatural :: Natural -> CLLong #
Semiring CLong # |
Instance details Defined in Data.Semiring Methods plus :: CLong -> CLong -> CLong # zero :: CLong # times :: CLong -> CLong -> CLong # one :: CLong # fromNatural :: Natural -> CLong #
Semiring CPtrdiff # |
Instance details Defined in Data.Semiring Methods plus :: CPtrdiff -> CPtrdiff -> CPtrdiff # zero :: CPtrdiff # times :: CPtrdiff -> CPtrdiff -> CPtrdiff # one :: CPtrdiff # fromNatural :: Natural -> CPtrdiff #
Semiring CSChar # |
Instance details Defined in Data.Semiring Methods plus :: CSChar -> CSChar -> CSChar # zero :: CSChar # times :: CSChar -> CSChar -> CSChar # one :: CSChar # fromNatural :: Natural -> CSChar #
Semiring CSUSeconds # |
Instance details Defined in Data.Semiring Methods plus :: CSUSeconds -> CSUSeconds -> CSUSeconds # zero :: CSUSeconds # times :: CSUSeconds -> CSUSeconds -> CSUSeconds # one :: CSUSeconds # fromNatural :: Natural -> CSUSeconds #
Semiring CShort # |
Instance details Defined in Data.Semiring Methods plus :: CShort -> CShort -> CShort # zero :: CShort # times :: CShort -> CShort -> CShort # one :: CShort # fromNatural :: Natural -> CShort #
Semiring CSigAtomic # |
Instance details Defined in Data.Semiring Methods plus :: CSigAtomic -> CSigAtomic -> CSigAtomic # zero :: CSigAtomic # times :: CSigAtomic -> CSigAtomic -> CSigAtomic # one :: CSigAtomic # fromNatural :: Natural -> CSigAtomic #
Semiring CSize # |
Instance details Defined in Data.Semiring Methods plus :: CSize -> CSize -> CSize # zero :: CSize # times :: CSize -> CSize -> CSize # one :: CSize # fromNatural :: Natural -> CSize #
Semiring CTime # |
Instance details Defined in Data.Semiring Methods plus :: CTime -> CTime -> CTime # zero :: CTime # times :: CTime -> CTime -> CTime # one :: CTime # fromNatural :: Natural -> CTime #
Semiring CUChar # |
Instance details Defined in Data.Semiring Methods plus :: CUChar -> CUChar -> CUChar # zero :: CUChar # times :: CUChar -> CUChar -> CUChar # one :: CUChar # fromNatural :: Natural -> CUChar #
Semiring CUInt # |
Instance details Defined in Data.Semiring Methods plus :: CUInt -> CUInt -> CUInt # zero :: CUInt # times :: CUInt -> CUInt -> CUInt # one :: CUInt # fromNatural :: Natural -> CUInt #
Semiring CUIntMax # |
Instance details Defined in Data.Semiring Methods plus :: CUIntMax -> CUIntMax -> CUIntMax # zero :: CUIntMax # times :: CUIntMax -> CUIntMax -> CUIntMax # one :: CUIntMax # fromNatural :: Natural -> CUIntMax #
Semiring CUIntPtr # |
Instance details Defined in Data.Semiring Methods plus :: CUIntPtr -> CUIntPtr -> CUIntPtr # zero :: CUIntPtr # times :: CUIntPtr -> CUIntPtr -> CUIntPtr # one :: CUIntPtr # fromNatural :: Natural -> CUIntPtr #
Semiring CULLong # |
Instance details Defined in Data.Semiring Methods plus :: CULLong -> CULLong -> CULLong # zero :: CULLong # times :: CULLong -> CULLong -> CULLong # one :: CULLong # fromNatural :: Natural -> CULLong #
Semiring CULong # |
Instance details Defined in Data.Semiring Methods plus :: CULong -> CULong -> CULong # zero :: CULong # times :: CULong -> CULong -> CULong # one :: CULong # fromNatural :: Natural -> CULong #
Semiring CUSeconds # |
Instance details Defined in Data.Semiring Methods plus :: CUSeconds -> CUSeconds -> CUSeconds # zero :: CUSeconds # times :: CUSeconds -> CUSeconds -> CUSeconds # one :: CUSeconds # fromNatural :: Natural -> CUSeconds #
Semiring CUShort # |
Instance details Defined in Data.Semiring Methods plus :: CUShort -> CUShort -> CUShort # zero :: CUShort # times :: CUShort -> CUShort -> CUShort # one :: CUShort # fromNatural :: Natural -> CUShort #
Semiring CWchar # |
Instance details Defined in Data.Semiring Methods plus :: CWchar -> CWchar -> CWchar # zero :: CWchar # times :: CWchar -> CWchar -> CWchar # one :: CWchar # fromNatural :: Natural -> CWchar #
Semiring IntPtr # |
Instance details Defined in Data.Semiring Methods plus :: IntPtr -> IntPtr -> IntPtr # zero :: IntPtr # times :: IntPtr -> IntPtr -> IntPtr # one :: IntPtr # fromNatural :: Natural -> IntPtr #
Semiring WordPtr # |
Instance details Defined in Data.Semiring Methods plus :: WordPtr -> WordPtr -> WordPtr # zero :: WordPtr # times :: WordPtr -> WordPtr -> WordPtr # one :: WordPtr # fromNatural :: Natural -> WordPtr #
Semiring Int16 # |
Instance details Defined in Data.Semiring Methods plus :: Int16 -> Int16 -> Int16 # zero :: Int16 # times :: Int16 -> Int16 -> Int16 # one :: Int16 # fromNatural :: Natural -> Int16 #
Semiring Int32 # |
Instance details Defined in Data.Semiring Methods plus :: Int32 -> Int32 -> Int32 # zero :: Int32 # times :: Int32 -> Int32 -> Int32 # one :: Int32 # fromNatural :: Natural -> Int32 #
Semiring Int64 # |
Instance details Defined in Data.Semiring Methods plus :: Int64 -> Int64 -> Int64 # zero :: Int64 # times :: Int64 -> Int64 -> Int64 # one :: Int64 # fromNatural :: Natural -> Int64 #
Semiring Int8 # |
Instance details Defined in Data.Semiring Methods plus :: Int8 -> Int8 -> Int8 # zero :: Int8 # times :: Int8 -> Int8 -> Int8 # one :: Int8 # fromNatural :: Natural -> Int8 #
Semiring CCc # |
Instance details Defined in Data.Semiring Methods plus :: CCc -> CCc -> CCc # zero :: CCc # times :: CCc -> CCc -> CCc # one :: CCc # fromNatural :: Natural -> CCc #
Semiring CDev # |
Instance details Defined in Data.Semiring Methods plus :: CDev -> CDev -> CDev # zero :: CDev # times :: CDev -> CDev -> CDev # one :: CDev # fromNatural :: Natural -> CDev #
Semiring CGid # |
Instance details Defined in Data.Semiring Methods plus :: CGid -> CGid -> CGid # zero :: CGid # times :: CGid -> CGid -> CGid # one :: CGid # fromNatural :: Natural -> CGid #
Semiring CIno # |
Instance details Defined in Data.Semiring Methods plus :: CIno -> CIno -> CIno # zero :: CIno # times :: CIno -> CIno -> CIno # one :: CIno # fromNatural :: Natural -> CIno #
Semiring CMode # |
Instance details Defined in Data.Semiring Methods plus :: CMode -> CMode -> CMode # zero :: CMode # times :: CMode -> CMode -> CMode # one :: CMode # fromNatural :: Natural -> CMode #
Semiring CNlink # |
Instance details Defined in Data.Semiring Methods plus :: CNlink -> CNlink -> CNlink # zero :: CNlink # times :: CNlink -> CNlink -> CNlink # one :: CNlink # fromNatural :: Natural -> CNlink #
Semiring COff # |
Instance details Defined in Data.Semiring Methods plus :: COff -> COff -> COff # zero :: COff # times :: COff -> COff -> COff # one :: COff # fromNatural :: Natural -> COff #
Semiring CPid # |
Instance details Defined in Data.Semiring Methods plus :: CPid -> CPid -> CPid # zero :: CPid # times :: CPid -> CPid -> CPid # one :: CPid # fromNatural :: Natural -> CPid #
Semiring CRLim # |
Instance details Defined in Data.Semiring Methods plus :: CRLim -> CRLim -> CRLim # zero :: CRLim # times :: CRLim -> CRLim -> CRLim # one :: CRLim # fromNatural :: Natural -> CRLim #
Semiring CSpeed # |
Instance details Defined in Data.Semiring Methods plus :: CSpeed -> CSpeed -> CSpeed # zero :: CSpeed # times :: CSpeed -> CSpeed -> CSpeed # one :: CSpeed # fromNatural :: Natural -> CSpeed #
Semiring CSsize # |
Instance details Defined in Data.Semiring Methods plus :: CSsize -> CSsize -> CSsize # zero :: CSsize # times :: CSsize -> CSsize -> CSsize # one :: CSsize # fromNatural :: Natural -> CSsize #
Semiring CTcflag # |
Instance details Defined in Data.Semiring Methods plus :: CTcflag -> CTcflag -> CTcflag # zero :: CTcflag # times :: CTcflag -> CTcflag -> CTcflag # one :: CTcflag # fromNatural :: Natural -> CTcflag #
Semiring CUid # |
Instance details Defined in Data.Semiring Methods plus :: CUid -> CUid -> CUid # zero :: CUid # times :: CUid -> CUid -> CUid # one :: CUid # fromNatural :: Natural -> CUid #
Semiring Fd # |
Instance details Defined in Data.Semiring Methods plus :: Fd -> Fd -> Fd # zero :: Fd # times :: Fd -> Fd -> Fd # one :: Fd # fromNatural :: Natural -> Fd #
Semiring Word16 # |
Instance details Defined in Data.Semiring Methods plus :: Word16 -> Word16 -> Word16 # zero :: Word16 # times :: Word16 -> Word16 -> Word16 # one :: Word16 # fromNatural :: Natural -> Word16 #
Semiring Word32 # |
Instance details Defined in Data.Semiring Methods plus :: Word32 -> Word32 -> Word32 # zero :: Word32 # times :: Word32 -> Word32 -> Word32 # one :: Word32 # fromNatural :: Natural -> Word32 #
Semiring Word64 # |
Instance details Defined in Data.Semiring Methods plus :: Word64 -> Word64 -> Word64 # zero :: Word64 # times :: Word64 -> Word64 -> Word64 # one :: Word64 # fromNatural :: Natural -> Word64 #
Semiring Word8 # |
Instance details Defined in Data.Semiring Methods plus :: Word8 -> Word8 -> Word8 # zero :: Word8 # times :: Word8 -> Word8 -> Word8 # one :: Word8 # fromNatural :: Natural -> Word8 #
Semiring Mod2 # |
Instance details Defined in Data.Semiring Methods plus :: Mod2 -> Mod2 -> Mod2 # zero :: Mod2 # times :: Mod2 -> Mod2 -> Mod2 # one :: Mod2 # fromNatural :: Natural -> Mod2 #
Semiring Directed # | Since: 0.7
Instance details Defined in Data.Semiring.Directed Methods plus :: Directed -> Directed -> Directed # zero :: Directed # times :: Directed -> Directed -> Directed # one :: Directed # fromNatural :: Natural -> Directed #
Semiring Integer # |
Instance details Defined in Data.Semiring Methods plus :: Integer -> Integer -> Integer # zero :: Integer # times :: Integer -> Integer -> Integer # one :: Integer # fromNatural :: Natural -> Integer #
Semiring Natural # |
Instance details Defined in Data.Semiring Methods plus :: Natural -> Natural -> Natural # zero :: Natural # times :: Natural -> Natural -> Natural # one :: Natural # fromNatural :: Natural -> Natural #
Semiring () # |
Instance details Defined in Data.Semiring Methods plus :: () -> () -> () # zero :: () # times :: () -> () -> () # one :: () # fromNatural :: Natural -> () #
Semiring Bool # |
Instance details Defined in Data.Semiring Methods plus :: Bool -> Bool -> Bool # zero :: Bool # times :: Bool -> Bool -> Bool # one :: Bool # fromNatural :: Natural -> Bool #
Semiring Double # |
Instance details Defined in Data.Semiring Methods plus :: Double -> Double -> Double # zero :: Double # times :: Double -> Double -> Double # one :: Double # fromNatural :: Natural -> Double #
Semiring Float # |
Instance details Defined in Data.Semiring Methods plus :: Float -> Float -> Float # zero :: Float # times :: Float -> Float -> Float # one :: Float # fromNatural :: Natural -> Float #
Semiring Int # |
Instance details Defined in Data.Semiring Methods plus :: Int -> Int -> Int # zero :: Int # times :: Int -> Int -> Int # one :: Int # fromNatural :: Natural -> Int #
Semiring Word # |
Instance details Defined in Data.Semiring Methods plus :: Word -> Word -> Word # zero :: Word # times :: Word -> Word -> Word # one :: Word # fromNatural :: Natural -> Word #
Ring a => Semiring (Complex a) # | This instance can suffer due to floating point arithmetic.
Instance details Defined in Data.Semiring Methods plus :: Complex a -> Complex a -> Complex a # zero :: Complex a # times :: Complex a -> Complex a -> Complex a # one :: Complex a # fromNatural :: Natural -> Complex a #
Semiring a => Semiring (Equivalence a) # |
Instance details Defined in Data.Semiring Methods plus :: Equivalence a -> Equivalence a -> Equivalence a # zero :: Equivalence a # times :: Equivalence a -> Equivalence a -> Equivalence a # one :: Equivalence a # fromNatural :: Natural -> Equivalence a #
Semiring (Predicate a) # |
Instance details Defined in Data.Semiring Methods plus :: Predicate a -> Predicate a -> Predicate a # zero :: Predicate a # times :: Predicate a -> Predicate a -> Predicate a # one :: Predicate a # fromNatural :: Natural -> Predicate a #
(Ord a, Monoid a) => Semiring (Set a) # | The multiplication laws are satisfied for any underlying `Monoid`, so we require a `Monoid` constraint instead of a `Semiring` constraint since `times` can use the context of either.
Instance details Defined in Data.Semiring Methods plus :: Set a -> Set a -> Set a # zero :: Set a # times :: Set a -> Set a -> Set a # one :: Set a # fromNatural :: Natural -> Set a #
Semiring a => Semiring (Identity a) # |
Instance details Defined in Data.Semiring Methods plus :: Identity a -> Identity a -> Identity a # zero :: Identity a # times :: Identity a -> Identity a -> Identity a # one :: Identity a # fromNatural :: Natural -> Identity a #
Semiring a => Semiring (Down a) # |
Instance details Defined in Data.Semiring Methods plus :: Down a -> Down a -> Down a # zero :: Down a # times :: Down a -> Down a -> Down a # one :: Down a # fromNatural :: Natural -> Down a #
Semiring a => Semiring (Dual a) # |
Instance details Defined in Data.Semiring Methods plus :: Dual a -> Dual a -> Dual a # zero :: Dual a # times :: Dual a -> Dual a -> Dual a # one :: Dual a # fromNatural :: Natural -> Dual a #
Integral a => Semiring (Ratio a) # |
Instance details Defined in Data.Semiring Methods plus :: Ratio a -> Ratio a -> Ratio a # zero :: Ratio a # times :: Ratio a -> Ratio a -> Ratio a # one :: Ratio a # fromNatural :: Natural -> Ratio a #
Semiring a => Semiring (IO a) # |
Instance details Defined in Data.Semiring Methods plus :: IO a -> IO a -> IO a # zero :: IO a # times :: IO a -> IO a -> IO a # one :: IO a # fromNatural :: Natural -> IO 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 #
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 #
Semiring (Modular Word16) # |
Instance details Defined in Data.Ring.Ordered Methods plus :: Modular Word16 -> Modular Word16 -> Modular Word16 # zero :: Modular Word16 # times :: Modular Word16 -> Modular Word16 -> Modular Word16 # one :: Modular Word16 # fromNatural :: Natural -> Modular Word16 #
Semiring (Modular Word32) # |
Instance details Defined in Data.Ring.Ordered Methods plus :: Modular Word32 -> Modular Word32 -> Modular Word32 # zero :: Modular Word32 # times :: Modular Word32 -> Modular Word32 -> Modular Word32 # one :: Modular Word32 # fromNatural :: Natural -> Modular Word32 #
Semiring (Modular Word64) # |
Instance details Defined in Data.Ring.Ordered Methods plus :: Modular Word64 -> Modular Word64 -> Modular Word64 # zero :: Modular Word64 # times :: Modular Word64 -> Modular Word64 -> Modular Word64 # one :: Modular Word64 # fromNatural :: Natural -> Modular Word64 #
Semiring (Modular Word8) # |
Instance details Defined in Data.Ring.Ordered Methods plus :: Modular Word8 -> Modular Word8 -> Modular Word8 # zero :: Modular Word8 # times :: Modular Word8 -> Modular Word8 -> Modular Word8 # one :: Modular Word8 # fromNatural :: Natural -> Modular Word8 #
Semiring (Modular Word) # |
Instance details Defined in Data.Ring.Ordered Methods plus :: Modular Word -> Modular Word -> Modular Word # zero :: Modular Word # times :: Modular Word -> Modular Word -> Modular Word # one :: Modular Word # fromNatural :: Natural -> Modular Word #
(Coercible Int a, Monoid a) => Semiring (IntSetOf a) # |
Instance details Defined in Data.Semiring Methods plus :: IntSetOf a -> IntSetOf a -> IntSetOf a # zero :: IntSetOf a # times :: IntSetOf a -> IntSetOf a -> IntSetOf a # one :: IntSetOf a # fromNatural :: Natural -> IntSetOf a #
Num a => Semiring (WrappedNum a) # |
Instance details Defined in Data.Semiring Methods plus :: WrappedNum a -> WrappedNum a -> WrappedNum a # zero :: WrappedNum a # times :: WrappedNum a -> WrappedNum a -> WrappedNum a # one :: WrappedNum a # fromNatural :: Natural -> WrappedNum a #
(Generic a, GSemiring (Rep a)) => Semiring (GenericSemiring a) # |
Instance details Defined in Data.Semiring.Generic Methods plus :: GenericSemiring a -> GenericSemiring a -> GenericSemiring a # zero :: GenericSemiring a # times :: GenericSemiring a -> GenericSemiring a -> GenericSemiring a # one :: GenericSemiring a # fromNatural :: Natural -> GenericSemiring a #
(Eq a, Hashable a, Monoid a) => Semiring (HashSet a) # | The multiplication laws are satisfied for any underlying `Monoid`, so we require a `Monoid` constraint instead of a `Semiring` constraint since `times` can use the context of either.
Instance details Defined in Data.Semiring Methods plus :: HashSet a -> HashSet a -> HashSet a # zero :: HashSet a # times :: HashSet a -> HashSet a -> HashSet a # one :: HashSet a # fromNatural :: Natural -> HashSet a #
Semiring a => Semiring (Maybe a) # |
Instance details Defined in Data.Semiring Methods plus :: Maybe a -> Maybe a -> Maybe a # zero :: Maybe a # times :: Maybe a -> Maybe a -> Maybe a # one :: Maybe a # fromNatural :: Natural -> Maybe a #
HasResolution a => Semiring (Fixed a) # |
Instance details Defined in Data.Semiring Methods plus :: Fixed a -> Fixed a -> Fixed a # zero :: Fixed a # times :: Fixed a -> Fixed a -> Fixed a # one :: Fixed a # fromNatural :: Natural -> Fixed a #
Semiring a => Semiring (Op a b) # |
Instance details Defined in Data.Semiring Methods plus :: Op a b -> Op a b -> Op a b # zero :: Op a b # times :: Op a b -> Op a b -> Op a b # one :: Op a b # fromNatural :: Natural -> Op a b #
(Ord k, Monoid k, Semiring v) => Semiring (Map k v) # | The multiplication laws are satisfied for any underlying `Monoid` as the key type, so we require a `Monoid` constraint instead of a `Semiring` constraint since `times` can use the context of either.
Instance details Defined in Data.Semiring Methods plus :: Map k v -> Map k v -> Map k v # zero :: Map k v # times :: Map k v -> Map k v -> Map k v # one :: Map k v # fromNatural :: Natural -> Map k v #
Semiring (Proxy a) # |
Instance details Defined in Data.Semiring Methods plus :: Proxy a -> Proxy a -> Proxy a # zero :: Proxy a # times :: Proxy a -> Proxy a -> Proxy a # one :: Proxy a # fromNatural :: Natural -> Proxy a #
(Coercible Int k, Monoid k, Semiring v) => Semiring (IntMapOf k v) # |
Instance details Defined in Data.Semiring Methods plus :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v # zero :: IntMapOf k v # times :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v # one :: IntMapOf k v # fromNatural :: Natural -> IntMapOf k v #
(Ord a, Monoid a, Extremum e) => Semiring (Tropical e a) # |
Instance details Defined in Data.Semiring.Tropical Methods plus :: Tropical e a -> Tropical e a -> Tropical e a # zero :: Tropical e a # times :: Tropical e a -> Tropical e a -> Tropical e a # one :: Tropical e a # fromNatural :: Natural -> Tropical e a #
(Eq k, Hashable k, Monoid k, Semiring v) => Semiring (HashMap k v) # | The multiplication laws are satisfied for any underlying `Monoid` as the key type, so we require a `Monoid` constraint instead of a `Semiring` constraint since `times` can use the context of either.
Instance details Defined in Data.Semiring Methods plus :: HashMap k v -> HashMap k v -> HashMap k v # zero :: HashMap k v # times :: HashMap k v -> HashMap k v -> HashMap k v # one :: HashMap k v # fromNatural :: Natural -> HashMap k v #
(Semiring a, Semiring b) => Semiring (a, b) # |
Instance details Defined in Data.Semiring Methods plus :: (a, b) -> (a, b) -> (a, b) # zero :: (a, b) # times :: (a, b) -> (a, b) -> (a, b) # one :: (a, b) # fromNatural :: Natural -> (a, b) #
Semiring b => Semiring (a -> b) # |
Instance details Defined in Data.Semiring Methods plus :: (a -> b) -> (a -> b) -> a -> b # zero :: a -> b # times :: (a -> b) -> (a -> b) -> a -> b # one :: a -> b # fromNatural :: Natural -> a -> b #
Semiring a => Semiring (Const a b) # |
Instance details Defined in Data.Semiring Methods plus :: Const a b -> Const a b -> Const a b # zero :: Const a b # times :: Const a b -> Const a b -> Const a b # one :: Const a b # fromNatural :: Natural -> Const a b #
(Semiring a, Applicative f) => Semiring (Ap f a) # |
Instance details Defined in Data.Semiring Methods plus :: Ap f a -> Ap f a -> Ap f a # zero :: Ap f a # times :: Ap f a -> Ap f a -> Ap f a # one :: Ap f a # fromNatural :: Natural -> Ap f a #
(Semiring a, Semiring b, Semiring c) => Semiring (a, b, c) # |
Instance details Defined in Data.Semiring Methods plus :: (a, b, c) -> (a, b, c) -> (a, b, c) # zero :: (a, b, c) # times :: (a, b, c) -> (a, b, c) -> (a, b, c) # one :: (a, b, c) # fromNatural :: Natural -> (a, b, c) #
(Semiring a, Semiring b, Semiring c, Semiring d) => Semiring (a, b, c, d) # |
Instance details Defined in Data.Semiring Methods plus :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) # zero :: (a, b, c, d) # times :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) # one :: (a, b, c, d) # fromNatural :: Natural -> (a, b, c, d) #
(Semiring a, Semiring b, Semiring c, Semiring d, Semiring e) => Semiring (a, b, c, d, e) # |
Instance details Defined in Data.Semiring Methods plus :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) # zero :: (a, b, c, d, e) # times :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) # one :: (a, b, c, d, e) # fromNatural :: Natural -> (a, b, c, d, e) #
(Semiring a, Semiring b, Semiring c, Semiring d, Semiring e, Semiring f) => Semiring (a, b, c, d, e, f) # |
Instance details Defined in Data.Semiring Methods plus :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) # zero :: (a, b, c, d, e, f) # times :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) # one :: (a, b, c, d, e, f) # fromNatural :: Natural -> (a, b, c, d, e, f) #
(Semiring a, Semiring b, Semiring c, Semiring d, Semiring e, Semiring f, Semiring g) => Semiring (a, b, c, d, e, f, g) # |
Instance details 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) # zero :: (a, b, c, d, e, f, g) # times :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) # one :: (a, b, c, d, e, f, g) # fromNatural :: Natural -> (a, b, c, d, e, f, g) #

(+) :: Semiring a => a -> a -> a infixl 6 #

Infix shorthand for `plus`.

(*) :: Semiring a => a -> a -> a infixl 7 #

Infix shorthand for `times`.

(^) :: (Semiring a, Integral b) => a -> b -> a infixr 8 #

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 #

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 #

Map each element of the structure to a semiring, and combine the results using `times`.

sum :: (Foldable t, Semiring a) => t a -> a #

The `sum` function computes the additive sum of the elements in a structure. This function is lazy. For a strict version, see `sum'`.

product :: (Foldable t, Semiring a) => t a -> a #

The `product` function computes the product of the elements in a structure. This function is lazy. for a strict version, see `product'`.

sum' :: (Foldable t, Semiring a) => t a -> a #

The `sum'` function computes the additive sum of the elements in a structure. This function is strict. For a lazy version, see `sum`.

product' :: (Foldable t, Semiring a) => t a -> a #

The `product'` function computes the additive sum of the elements in a structure. This function is strict. For a lazy version, see `product`.

isZero :: (Eq a, Semiring a) => a -> Bool #

Is the value `zero`?

isOne :: (Eq a, Semiring a) => a -> Bool #

Is the value `one`?

# Types

newtype Add a #

Monoid under `plus`. Analogous to `Sum`, but uses the `Semiring` constraint rather than `Num`.

Constructors

Add |

Fields

- getAdd :: a

#### Instances

Instances details

Functor Add # |
Instance details Defined in Data.Semiring Methods fmap :: (a -> b) -> Add a -> Add b # (<$) :: a -> Add b -> Add a #
Foldable Add # |

Instance details

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 #

toList :: Add a -> [a] #

null :: Add a -> Bool #

length :: Add a -> Int #

elem :: Eq a => a -> Add a -> Bool #

maximum :: Ord a => Add a -> a #

minimum :: Ord a => Add a -> a #

sum :: Num a => Add a -> a #

product :: Num a => Add a -> a #

Traversable Add # |
Instance details Defined in Data.Semiring Methods traverse :: Applicative f => (a -> f b) -> Add a -> f (Add b) # sequenceA :: Applicative f => Add (f a) -> f (Add a) # mapM :: Monad m => (a -> m b) -> Add a -> m (Add b) # sequence :: Monad m => Add (m a) -> m (Add a) #
Generic1 Add # |

Instance details

Defined in Data.Semiring

Associated Types

type Rep1 Add |
Instance details Defined in Data.Semiring type Rep1 Add = D1 ('MetaData "Add" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "Add" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAdd") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))

Methods

from1 :: Add a -> Rep1 Add a #

to1 :: Rep1 Add a -> Add a #

Semiring a => Monoid (Add a) # |
Instance details Defined in Data.Semiring Methods mempty :: Add a # mappend :: Add a -> Add a -> Add a # mconcat :: [Add a] -> Add a #
Semiring a => Semigroup (Add a) # |
Instance details Defined in Data.Semiring Methods (<>) :: Add a -> Add a -> Add a # sconcat :: NonEmpty (Add a) -> Add a # stimes :: Integral b => b -> Add a -> Add a #
Bounded a => Bounded (Add a) # |
Instance details Defined in Data.Semiring Methods minBound :: Add a # maxBound :: Add a #
Enum a => Enum (Add a) # |
Instance details Defined in Data.Semiring Methods succ :: Add a -> Add a # pred :: Add a -> Add a # toEnum :: Int -> Add a # fromEnum :: Add a -> Int # enumFrom :: Add a -> [Add a] # enumFromThen :: Add a -> Add a -> [Add a] # enumFromTo :: Add a -> Add a -> [Add a] # enumFromThenTo :: Add a -> Add a -> Add a -> [Add a] #
Storable a => Storable (Add a) # |
Instance details Defined in Data.Semiring Methods sizeOf :: Add a -> Int # alignment :: Add a -> Int # 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 () # peek :: Ptr (Add a) -> IO (Add a) # poke :: Ptr (Add a) -> Add a -> IO () #
Generic (Add a) # |

Instance details

Defined in Data.Semiring

Associated Types

type Rep (Add a) |
Instance details Defined in Data.Semiring type Rep (Add a) = D1 ('MetaData "Add" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "Add" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAdd") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Methods

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

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

Num a => Num (Add a) # |
Instance details Defined in Data.Semiring Methods (+) :: Add a -> Add a -> Add a # (-) :: Add a -> Add a -> Add a # (*) :: Add a -> Add a -> Add a # negate :: Add a -> Add a # abs :: Add a -> Add a # signum :: Add a -> Add a # fromInteger :: Integer -> Add a #
Read a => Read (Add a) # |
Instance details Defined in Data.Semiring Methods readsPrec :: Int -> ReadS (Add a) # readList :: ReadS [Add a] # readPrec :: ReadPrec (Add a) # readListPrec :: ReadPrec [Add a] #
Fractional a => Fractional (Add a) # |
Instance details Defined in Data.Semiring Methods (/) :: Add a -> Add a -> Add a # recip :: Add a -> Add a # fromRational :: Rational -> Add a #
Real a => Real (Add a) # |
Instance details Defined in Data.Semiring Methods toRational :: Add a -> Rational #
RealFrac a => RealFrac (Add a) # |
Instance details Defined in Data.Semiring Methods properFraction :: Integral b => Add a -> (b, Add a) # truncate :: Integral b => Add a -> b # round :: Integral b => Add a -> b # ceiling :: Integral b => Add a -> b # floor :: Integral b => Add a -> b #
Show a => Show (Add a) # |
Instance details Defined in Data.Semiring Methods showsPrec :: Int -> Add a -> ShowS # show :: Add a -> String # showList :: [Add a] -> ShowS #
Eq a => Eq (Add a) # |
Instance details Defined in Data.Semiring Methods (==) :: Add a -> Add a -> Bool # (/=) :: Add a -> Add a -> Bool #
Ord a => Ord (Add a) # |
Instance details Defined in Data.Semiring Methods compare :: Add a -> Add a -> Ordering # (<) :: Add a -> Add a -> Bool # (<=) :: Add a -> Add a -> Bool # (>) :: Add a -> Add a -> Bool # (>=) :: Add a -> Add a -> Bool # max :: Add a -> Add a -> Add a # min :: Add a -> Add a -> Add a #
type Rep1 Add # |
Instance details Defined in Data.Semiring type Rep1 Add = D1 ('MetaData "Add" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "Add" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAdd") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
type Rep (Add a) # |
Instance details Defined in Data.Semiring type Rep (Add a) = D1 ('MetaData "Add" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "Add" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAdd") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

newtype Mul a #

Monoid under `times`. Analogous to `Product`, but uses the `Semiring` constraint rather than `Num`.

Constructors

Mul |

Fields

- getMul :: a

#### Instances

Instances details

Functor Mul # |
Instance details Defined in Data.Semiring Methods fmap :: (a -> b) -> Mul a -> Mul b # (<$) :: a -> Mul b -> Mul a #
Foldable Mul # |

Instance details

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 #

toList :: Mul a -> [a] #

null :: Mul a -> Bool #

length :: Mul a -> Int #

elem :: Eq a => a -> Mul a -> Bool #

maximum :: Ord a => Mul a -> a #

minimum :: Ord a => Mul a -> a #

sum :: Num a => Mul a -> a #

product :: Num a => Mul a -> a #

Traversable Mul # |
Instance details Defined in Data.Semiring Methods traverse :: Applicative f => (a -> f b) -> Mul a -> f (Mul b) # sequenceA :: Applicative f => Mul (f a) -> f (Mul a) # mapM :: Monad m => (a -> m b) -> Mul a -> m (Mul b) # sequence :: Monad m => Mul (m a) -> m (Mul a) #
Generic1 Mul # |

Instance details

Defined in Data.Semiring

Associated Types

type Rep1 Mul |
Instance details Defined in Data.Semiring type Rep1 Mul = D1 ('MetaData "Mul" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "Mul" 'PrefixI 'True) (S1 ('MetaSel ('Just "getMul") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))

Methods

from1 :: Mul a -> Rep1 Mul a #

to1 :: Rep1 Mul a -> Mul a #

Semiring a => Monoid (Mul a) # |
Instance details Defined in Data.Semiring Methods mempty :: Mul a # mappend :: Mul a -> Mul a -> Mul a # mconcat :: [Mul a] -> Mul a #
Semiring a => Semigroup (Mul a) # |
Instance details Defined in Data.Semiring Methods (<>) :: Mul a -> Mul a -> Mul a # sconcat :: NonEmpty (Mul a) -> Mul a # stimes :: Integral b => b -> Mul a -> Mul a #
Bounded a => Bounded (Mul a) # |
Instance details Defined in Data.Semiring Methods minBound :: Mul a # maxBound :: Mul a #
Enum a => Enum (Mul a) # |
Instance details Defined in Data.Semiring Methods succ :: Mul a -> Mul a # pred :: Mul a -> Mul a # toEnum :: Int -> Mul a # fromEnum :: Mul a -> Int # enumFrom :: Mul a -> [Mul a] # enumFromThen :: Mul a -> Mul a -> [Mul a] # enumFromTo :: Mul a -> Mul a -> [Mul a] # enumFromThenTo :: Mul a -> Mul a -> Mul a -> [Mul a] #
Storable a => Storable (Mul a) # |
Instance details Defined in Data.Semiring Methods sizeOf :: Mul a -> Int # alignment :: Mul a -> Int # 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 () # peek :: Ptr (Mul a) -> IO (Mul a) # poke :: Ptr (Mul a) -> Mul a -> IO () #
Generic (Mul a) # |

Instance details

Defined in Data.Semiring

Associated Types

type Rep (Mul a) |
Instance details Defined in Data.Semiring type Rep (Mul a) = D1 ('MetaData "Mul" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "Mul" 'PrefixI 'True) (S1 ('MetaSel ('Just "getMul") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Methods

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

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

Num a => Num (Mul a) # |
Instance details Defined in Data.Semiring Methods (+) :: Mul a -> Mul a -> Mul a # (-) :: Mul a -> Mul a -> Mul a # (*) :: Mul a -> Mul a -> Mul a # negate :: Mul a -> Mul a # abs :: Mul a -> Mul a # signum :: Mul a -> Mul a # fromInteger :: Integer -> Mul a #
Read a => Read (Mul a) # |
Instance details Defined in Data.Semiring Methods readsPrec :: Int -> ReadS (Mul a) # readList :: ReadS [Mul a] # readPrec :: ReadPrec (Mul a) # readListPrec :: ReadPrec [Mul a] #
Fractional a => Fractional (Mul a) # |
Instance details Defined in Data.Semiring Methods (/) :: Mul a -> Mul a -> Mul a # recip :: Mul a -> Mul a # fromRational :: Rational -> Mul a #
Real a => Real (Mul a) # |
Instance details Defined in Data.Semiring Methods toRational :: Mul a -> Rational #
RealFrac a => RealFrac (Mul a) # |
Instance details Defined in Data.Semiring Methods properFraction :: Integral b => Mul a -> (b, Mul a) # truncate :: Integral b => Mul a -> b # round :: Integral b => Mul a -> b # ceiling :: Integral b => Mul a -> b # floor :: Integral b => Mul a -> b #
Show a => Show (Mul a) # |
Instance details Defined in Data.Semiring Methods showsPrec :: Int -> Mul a -> ShowS # show :: Mul a -> String # showList :: [Mul a] -> ShowS #
Eq a => Eq (Mul a) # |
Instance details Defined in Data.Semiring Methods (==) :: Mul a -> Mul a -> Bool # (/=) :: Mul a -> Mul a -> Bool #
Ord a => Ord (Mul a) # |
Instance details Defined in Data.Semiring Methods compare :: Mul a -> Mul a -> Ordering # (<) :: Mul a -> Mul a -> Bool # (<=) :: Mul a -> Mul a -> Bool # (>) :: Mul a -> Mul a -> Bool # (>=) :: Mul a -> Mul a -> Bool # max :: Mul a -> Mul a -> Mul a # min :: Mul a -> Mul a -> Mul a #
type Rep1 Mul # |
Instance details Defined in Data.Semiring type Rep1 Mul = D1 ('MetaData "Mul" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "Mul" 'PrefixI 'True) (S1 ('MetaSel ('Just "getMul") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
type Rep (Mul a) # |
Instance details Defined in Data.Semiring type Rep (Mul a) = D1 ('MetaData "Mul" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "Mul" 'PrefixI 'True) (S1 ('MetaSel ('Just "getMul") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

newtype WrappedNum a #

Provide Semiring and Ring for an arbitrary `Num`. It is useful with GHC 8.6+'s DerivingVia extension.

Constructors

WrapNum |

Fields

- unwrapNum :: a

#### Instances

Instances details

Functor WrappedNum # |
Instance details Defined in Data.Semiring Methods fmap :: (a -> b) -> WrappedNum a -> WrappedNum b # (<$) :: a -> WrappedNum b -> WrappedNum a #
Foldable WrappedNum # |

Instance details

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 # |
Instance details 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 # |

Instance details

Defined in Data.Semiring

Associated Types

type Rep1 WrappedNum |
Instance details Defined in Data.Semiring type Rep1 WrappedNum = D1 ('MetaData "WrappedNum" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "WrapNum" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapNum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))

Methods

from1 :: WrappedNum a -> Rep1 WrappedNum a #

to1 :: Rep1 WrappedNum a -> WrappedNum a #

Bits a => Bits (WrappedNum a) # |

Instance details

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) # |
Instance details Defined in Data.Semiring Methods minBound :: WrappedNum a # maxBound :: WrappedNum a #
Enum a => Enum (WrappedNum a) # |

Instance details

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) # |

Instance details

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) # |

Instance details

Defined in Data.Semiring

Associated Types

type Rep (WrappedNum a) |
Instance details Defined in Data.Semiring type Rep (WrappedNum a) = D1 ('MetaData "WrappedNum" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "WrapNum" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapNum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Methods

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

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

Num a => Num (WrappedNum a) # |
Instance details 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) # |
Instance details 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) # |
Instance details 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) # |
Instance details Defined in Data.Semiring Methods toRational :: WrappedNum a -> Rational #
RealFrac a => RealFrac (WrappedNum a) # |
Instance details 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) # |
Instance details Defined in Data.Semiring Methods showsPrec :: Int -> WrappedNum a -> ShowS # show :: WrappedNum a -> String # showList :: [WrappedNum a] -> ShowS #
Eq a => Eq (WrappedNum a) # |
Instance details Defined in Data.Semiring Methods (==) :: WrappedNum a -> WrappedNum a -> Bool # (/=) :: WrappedNum a -> WrappedNum a -> Bool #
Ord a => Ord (WrappedNum a) # |
Instance details 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) # |
Instance details Defined in Data.Semiring Methods negate :: WrappedNum a -> WrappedNum a #
Num a => Semiring (WrappedNum a) # |
Instance details Defined in Data.Semiring Methods plus :: WrappedNum a -> WrappedNum a -> WrappedNum a # zero :: WrappedNum a # times :: WrappedNum a -> WrappedNum a -> WrappedNum a # one :: WrappedNum a # fromNatural :: Natural -> WrappedNum a #
type Rep1 WrappedNum # |
Instance details Defined in Data.Semiring type Rep1 WrappedNum = D1 ('MetaData "WrappedNum" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "WrapNum" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapNum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
type Rep (WrappedNum a) # |
Instance details Defined in Data.Semiring type Rep (WrappedNum a) = D1 ('MetaData "WrappedNum" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "WrapNum" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapNum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

newtype Mod2 #

`Mod2` represents the integers mod 2.

It is useful in the computing of Zhegalkin polynomials.

Constructors

Mod2 |

Fields

- getMod2 :: Bool

#### Instances

Instances details

Bounded Mod2 # |
Instance details Defined in Data.Semiring Methods minBound :: Mod2 # maxBound :: Mod2 #
Enum Mod2 # |
Instance details Defined in Data.Semiring Methods succ :: Mod2 -> Mod2 # pred :: Mod2 -> Mod2 # toEnum :: Int -> Mod2 # fromEnum :: Mod2 -> Int # enumFrom :: Mod2 -> [Mod2] # enumFromThen :: Mod2 -> Mod2 -> [Mod2] # enumFromTo :: Mod2 -> Mod2 -> [Mod2] # enumFromThenTo :: Mod2 -> Mod2 -> Mod2 -> [Mod2] #
Generic Mod2 # |

Instance details

Defined in Data.Semiring

Associated Types

type Rep Mod2 |
Instance details Defined in Data.Semiring type Rep Mod2 = D1 ('MetaData "Mod2" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "Mod2" 'PrefixI 'True) (S1 ('MetaSel ('Just "getMod2") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))

Methods

from :: Mod2 -> Rep Mod2 x #

to :: Rep Mod2 x -> Mod2 #

Read Mod2 # |
Instance details Defined in Data.Semiring Methods readsPrec :: Int -> ReadS Mod2 # readList :: ReadS [Mod2] # readPrec :: ReadPrec Mod2 # readListPrec :: ReadPrec [Mod2] #
Show Mod2 # |
Instance details Defined in Data.Semiring Methods showsPrec :: Int -> Mod2 -> ShowS # show :: Mod2 -> String # showList :: [Mod2] -> ShowS #
Eq Mod2 # |
Instance details Defined in Data.Semiring Methods (==) :: Mod2 -> Mod2 -> Bool # (/=) :: Mod2 -> Mod2 -> Bool #
Ord Mod2 # |
Instance details Defined in Data.Semiring Methods compare :: Mod2 -> Mod2 -> Ordering # (<) :: Mod2 -> Mod2 -> Bool # (<=) :: Mod2 -> Mod2 -> Bool # (>) :: Mod2 -> Mod2 -> Bool # (>=) :: Mod2 -> Mod2 -> Bool # max :: Mod2 -> Mod2 -> Mod2 # min :: Mod2 -> Mod2 -> Mod2 #
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 #
Field Mod2 # |
Instance details Defined in Data.Euclidean
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 #
Ring Mod2 # |
Instance details Defined in Data.Semiring Methods negate :: Mod2 -> Mod2 #
Semiring Mod2 # |
Instance details Defined in Data.Semiring Methods plus :: Mod2 -> Mod2 -> Mod2 # zero :: Mod2 # times :: Mod2 -> Mod2 -> Mod2 # one :: Mod2 # fromNatural :: Natural -> Mod2 #
Star Mod2 # |
Instance details Defined in Data.Star Methods star :: Mod2 -> Mod2 # aplus :: Mod2 -> Mod2 #
type Rep Mod2 # |
Instance details Defined in Data.Semiring type Rep Mod2 = D1 ('MetaData "Mod2" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "Mod2" 'PrefixI 'True) (S1 ('MetaSel ('Just "getMod2") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))

newtype IntSetOf a #

Wrapper to mimic `Set` (`Sum` `Int`), `Set` (`Product` `Int`), etc., while having a more efficient underlying representation.

Constructors

IntSetOf |

Fields

- getIntSet :: IntSet

#### Instances

Instances details

Generic1 IntSetOf # |

Instance details

Defined in Data.Semiring

Associated Types

type Rep1 IntSetOf |
Instance details Defined in Data.Semiring type Rep1 IntSetOf = D1 ('MetaData "IntSetOf" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "IntSetOf" 'PrefixI 'True) (S1 ('MetaSel ('Just "getIntSet") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IntSet)))

Methods

from1 :: IntSetOf a -> Rep1 IntSetOf a #

to1 :: Rep1 IntSetOf a -> IntSetOf a #

Monoid (IntSetOf a) # |
Instance details Defined in Data.Semiring Methods mempty :: IntSetOf a # mappend :: IntSetOf a -> IntSetOf a -> IntSetOf a # mconcat :: [IntSetOf a] -> IntSetOf a #
Semigroup (IntSetOf a) # |
Instance details Defined in Data.Semiring Methods (<>) :: IntSetOf a -> IntSetOf a -> IntSetOf a # sconcat :: NonEmpty (IntSetOf a) -> IntSetOf a # stimes :: Integral b => b -> IntSetOf a -> IntSetOf a #
Generic (IntSetOf a) # |

Instance details

Defined in Data.Semiring

Associated Types

type Rep (IntSetOf a) |
Instance details Defined in Data.Semiring type Rep (IntSetOf a) = D1 ('MetaData "IntSetOf" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "IntSetOf" 'PrefixI 'True) (S1 ('MetaSel ('Just "getIntSet") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IntSet)))

Methods

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

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

Read (IntSetOf a) # |
Instance details Defined in Data.Semiring Methods readsPrec :: Int -> ReadS (IntSetOf a) # readList :: ReadS [IntSetOf a] # readPrec :: ReadPrec (IntSetOf a) # readListPrec :: ReadPrec [IntSetOf a] #
Show (IntSetOf a) # |
Instance details Defined in Data.Semiring Methods showsPrec :: Int -> IntSetOf a -> ShowS # show :: IntSetOf a -> String # showList :: [IntSetOf a] -> ShowS #
Eq (IntSetOf a) # |
Instance details Defined in Data.Semiring Methods (==) :: IntSetOf a -> IntSetOf a -> Bool # (/=) :: IntSetOf a -> IntSetOf a -> Bool #
Ord (IntSetOf a) # |
Instance details Defined in Data.Semiring Methods compare :: IntSetOf a -> IntSetOf a -> Ordering # (<) :: IntSetOf a -> IntSetOf a -> Bool # (<=) :: IntSetOf a -> IntSetOf a -> Bool # (>) :: IntSetOf a -> IntSetOf a -> Bool # (>=) :: IntSetOf a -> IntSetOf a -> Bool # max :: IntSetOf a -> IntSetOf a -> IntSetOf a # min :: IntSetOf a -> IntSetOf a -> IntSetOf a #
(Coercible Int a, Monoid a) => Semiring (IntSetOf a) # |
Instance details Defined in Data.Semiring Methods plus :: IntSetOf a -> IntSetOf a -> IntSetOf a # zero :: IntSetOf a # times :: IntSetOf a -> IntSetOf a -> IntSetOf a # one :: IntSetOf a # fromNatural :: Natural -> IntSetOf a #
type Rep1 IntSetOf # |
Instance details Defined in Data.Semiring type Rep1 IntSetOf = D1 ('MetaData "IntSetOf" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "IntSetOf" 'PrefixI 'True) (S1 ('MetaSel ('Just "getIntSet") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IntSet)))
type Rep (IntSetOf a) # |
Instance details Defined in Data.Semiring type Rep (IntSetOf a) = D1 ('MetaData "IntSetOf" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "IntSetOf" 'PrefixI 'True) (S1 ('MetaSel ('Just "getIntSet") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IntSet)))

newtype IntMapOf k v #

Wrapper to mimic `Map` (`Sum` `Int`) v, `Map` (`Product` `Int`) v, etc., while having a more efficient underlying representation.

Constructors

IntMapOf |

Fields

- getIntMap :: IntMap v

#### Instances

Instances details

Generic1 (IntMapOf k :: Type -> Type) # |

Instance details

Defined in Data.Semiring

Associated Types

type Rep1 (IntMapOf k :: Type -> Type) |
Instance details Defined in Data.Semiring type Rep1 (IntMapOf k :: Type -> Type) = D1 ('MetaData "IntMapOf" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "IntMapOf" 'PrefixI 'True) (S1 ('MetaSel ('Just "getIntMap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 IntMap)))

Methods

from1 :: IntMapOf k a -> Rep1 (IntMapOf k) a #

to1 :: Rep1 (IntMapOf k) a -> IntMapOf k a #

Monoid (IntMapOf k v) # |
Instance details Defined in Data.Semiring Methods mempty :: IntMapOf k v # mappend :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v # mconcat :: [IntMapOf k v] -> IntMapOf k v #
Semigroup (IntMapOf k v) # |
Instance details Defined in Data.Semiring Methods (<>) :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v # sconcat :: NonEmpty (IntMapOf k v) -> IntMapOf k v # stimes :: Integral b => b -> IntMapOf k v -> IntMapOf k v #
Generic (IntMapOf k v) # |

Instance details

Defined in Data.Semiring

Associated Types

type Rep (IntMapOf k v) |
Instance details Defined in Data.Semiring type Rep (IntMapOf k v) = D1 ('MetaData "IntMapOf" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "IntMapOf" 'PrefixI 'True) (S1 ('MetaSel ('Just "getIntMap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (IntMap v))))

Methods

from :: IntMapOf k v -> Rep (IntMapOf k v) x #

to :: Rep (IntMapOf k v) x -> IntMapOf k v #

Read v => Read (IntMapOf k v) # |
Instance details Defined in Data.Semiring Methods readsPrec :: Int -> ReadS (IntMapOf k v) # readList :: ReadS [IntMapOf k v] # readPrec :: ReadPrec (IntMapOf k v) # readListPrec :: ReadPrec [IntMapOf k v] #
Show v => Show (IntMapOf k v) # |
Instance details Defined in Data.Semiring Methods showsPrec :: Int -> IntMapOf k v -> ShowS # show :: IntMapOf k v -> String # showList :: [IntMapOf k v] -> ShowS #
Eq v => Eq (IntMapOf k v) # |
Instance details Defined in Data.Semiring Methods (==) :: IntMapOf k v -> IntMapOf k v -> Bool # (/=) :: IntMapOf k v -> IntMapOf k v -> Bool #
Ord v => Ord (IntMapOf k v) # |
Instance details Defined in Data.Semiring Methods compare :: IntMapOf k v -> IntMapOf k v -> Ordering # (<) :: IntMapOf k v -> IntMapOf k v -> Bool # (<=) :: IntMapOf k v -> IntMapOf k v -> Bool # (>) :: IntMapOf k v -> IntMapOf k v -> Bool # (>=) :: IntMapOf k v -> IntMapOf k v -> Bool # max :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v # min :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v #
(Coercible Int k, Monoid k, Semiring v) => Semiring (IntMapOf k v) # |
Instance details Defined in Data.Semiring Methods plus :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v # zero :: IntMapOf k v # times :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v # one :: IntMapOf k v # fromNatural :: Natural -> IntMapOf k v #
type Rep1 (IntMapOf k :: Type -> Type) # |
Instance details Defined in Data.Semiring type Rep1 (IntMapOf k :: Type -> Type) = D1 ('MetaData "IntMapOf" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "IntMapOf" 'PrefixI 'True) (S1 ('MetaSel ('Just "getIntMap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 IntMap)))
type Rep (IntMapOf k v) # |
Instance details Defined in Data.Semiring type Rep (IntMapOf k v) = D1 ('MetaData "IntMapOf" "Data.Semiring" "semirings-0.7-IhyDtHS7M7uHyZ7s7mY4S7" 'True) (C1 ('MetaCons "IntMapOf" 'PrefixI 'True) (S1 ('MetaSel ('Just "getIntMap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (IntMap v))))

# Ring typeclass

class Semiring a => Ring a where #

The class of semirings with an additive inverse.

    negate a + a = zero

Methods

negate :: a -> a #

#### Instances

Instances details

Ring CChar # |
Instance details Defined in Data.Semiring Methods negate :: CChar -> CChar #
Ring CClock # |
Instance details Defined in Data.Semiring Methods negate :: CClock -> CClock #
Ring CDouble # |
Instance details Defined in Data.Semiring Methods negate :: CDouble -> CDouble #
Ring CFloat # |
Instance details Defined in Data.Semiring Methods negate :: CFloat -> CFloat #
Ring CInt # |
Instance details Defined in Data.Semiring Methods negate :: CInt -> CInt #
Ring CIntMax # |
Instance details Defined in Data.Semiring Methods negate :: CIntMax -> CIntMax #
Ring CIntPtr # |
Instance details Defined in Data.Semiring Methods negate :: CIntPtr -> CIntPtr #
Ring CLLong # |
Instance details Defined in Data.Semiring Methods negate :: CLLong -> CLLong #
Ring CLong # |
Instance details Defined in Data.Semiring Methods negate :: CLong -> CLong #
Ring CPtrdiff # |
Instance details Defined in Data.Semiring Methods negate :: CPtrdiff -> CPtrdiff #
Ring CSChar # |
Instance details Defined in Data.Semiring Methods negate :: CSChar -> CSChar #
Ring CSUSeconds # |
Instance details Defined in Data.Semiring Methods negate :: CSUSeconds -> CSUSeconds #
Ring CShort # |
Instance details Defined in Data.Semiring Methods negate :: CShort -> CShort #
Ring CSigAtomic # |
Instance details Defined in Data.Semiring Methods negate :: CSigAtomic -> CSigAtomic #
Ring CSize # |
Instance details Defined in Data.Semiring Methods negate :: CSize -> CSize #
Ring CTime # |
Instance details Defined in Data.Semiring Methods negate :: CTime -> CTime #
Ring CUChar # |
Instance details Defined in Data.Semiring Methods negate :: CUChar -> CUChar #
Ring CUInt # |
Instance details Defined in Data.Semiring Methods negate :: CUInt -> CUInt #
Ring CUIntMax # |
Instance details Defined in Data.Semiring Methods negate :: CUIntMax -> CUIntMax #
Ring CUIntPtr # |
Instance details Defined in Data.Semiring Methods negate :: CUIntPtr -> CUIntPtr #
Ring CULLong # |
Instance details Defined in Data.Semiring Methods negate :: CULLong -> CULLong #
Ring CULong # |
Instance details Defined in Data.Semiring Methods negate :: CULong -> CULong #
Ring CUSeconds # |
Instance details Defined in Data.Semiring Methods negate :: CUSeconds -> CUSeconds #
Ring CUShort # |
Instance details Defined in Data.Semiring Methods negate :: CUShort -> CUShort #
Ring CWchar # |
Instance details Defined in Data.Semiring Methods negate :: CWchar -> CWchar #
Ring IntPtr # |
Instance details Defined in Data.Semiring Methods negate :: IntPtr -> IntPtr #
Ring WordPtr # |
Instance details Defined in Data.Semiring Methods negate :: WordPtr -> WordPtr #
Ring Int16 # |
Instance details Defined in Data.Semiring Methods negate :: Int16 -> Int16 #
Ring Int32 # |
Instance details Defined in Data.Semiring Methods negate :: Int32 -> Int32 #
Ring Int64 # |
Instance details Defined in Data.Semiring Methods negate :: Int64 -> Int64 #
Ring Int8 # |
Instance details Defined in Data.Semiring Methods negate :: Int8 -> Int8 #
Ring CCc # |
Instance details Defined in Data.Semiring Methods negate :: CCc -> CCc #
Ring CDev # |
Instance details Defined in Data.Semiring Methods negate :: CDev -> CDev #
Ring CGid # |
Instance details Defined in Data.Semiring Methods negate :: CGid -> CGid #
Ring CIno # |
Instance details Defined in Data.Semiring Methods negate :: CIno -> CIno #
Ring CMode # |
Instance details Defined in Data.Semiring Methods negate :: CMode -> CMode #
Ring CNlink # |
Instance details Defined in Data.Semiring Methods negate :: CNlink -> CNlink #
Ring COff # |
Instance details Defined in Data.Semiring Methods negate :: COff -> COff #
Ring CPid # |
Instance details Defined in Data.Semiring Methods negate :: CPid -> CPid #
Ring CRLim # |
Instance details Defined in Data.Semiring Methods negate :: CRLim -> CRLim #
Ring CSpeed # |
Instance details Defined in Data.Semiring Methods negate :: CSpeed -> CSpeed #
Ring CSsize # |
Instance details Defined in Data.Semiring Methods negate :: CSsize -> CSsize #
Ring CTcflag # |
Instance details Defined in Data.Semiring Methods negate :: CTcflag -> CTcflag #
Ring CUid # |
Instance details Defined in Data.Semiring Methods negate :: CUid -> CUid #
Ring Fd # |
Instance details Defined in Data.Semiring Methods negate :: Fd -> Fd #
Ring Word16 # |
Instance details Defined in Data.Semiring Methods negate :: Word16 -> Word16 #
Ring Word32 # |
Instance details Defined in Data.Semiring Methods negate :: Word32 -> Word32 #
Ring Word64 # |
Instance details Defined in Data.Semiring Methods negate :: Word64 -> Word64 #
Ring Word8 # |
Instance details Defined in Data.Semiring Methods negate :: Word8 -> Word8 #
Ring Mod2 # |
Instance details Defined in Data.Semiring Methods negate :: Mod2 -> Mod2 #
Ring Integer # |
Instance details Defined in Data.Semiring Methods negate :: Integer -> Integer #
Ring () # |
Instance details Defined in Data.Semiring Methods negate :: () -> () #
Ring Double # |
Instance details Defined in Data.Semiring Methods negate :: Double -> Double #
Ring Float # |
Instance details Defined in Data.Semiring Methods negate :: Float -> Float #
Ring Int # |
Instance details Defined in Data.Semiring Methods negate :: Int -> Int #
Ring Word # |
Instance details Defined in Data.Semiring Methods negate :: Word -> Word #
Ring a => Ring (Complex a) # |
Instance details Defined in Data.Semiring Methods negate :: Complex a -> Complex a #
Ring a => Ring (Identity a) # |
Instance details Defined in Data.Semiring Methods negate :: Identity a -> Identity a #
Ring a => Ring (Down a) # |
Instance details Defined in Data.Semiring Methods negate :: Down a -> Down a #
Ring a => Ring (Dual a) # |
Instance details Defined in Data.Semiring Methods negate :: Dual a -> Dual a #
Integral a => Ring (Ratio a) # |
Instance details Defined in Data.Semiring Methods negate :: Ratio a -> Ratio a #
Ring a => Ring (IO a) # |
Instance details Defined in Data.Semiring Methods negate :: IO a -> IO a #
Num a => Ring (WrappedFractional a) # |
Instance details Defined in Data.Euclidean Methods negate :: WrappedFractional a -> WrappedFractional a #
Num a => Ring (WrappedIntegral a) # |
Instance details Defined in Data.Euclidean Methods negate :: WrappedIntegral a -> WrappedIntegral a #
Ring (Modular Word16) # |
Instance details Defined in Data.Ring.Ordered Methods negate :: Modular Word16 -> Modular Word16 #
Ring (Modular Word32) # |
Instance details Defined in Data.Ring.Ordered Methods negate :: Modular Word32 -> Modular Word32 #
Ring (Modular Word64) # |
Instance details Defined in Data.Ring.Ordered Methods negate :: Modular Word64 -> Modular Word64 #
Ring (Modular Word8) # |
Instance details Defined in Data.Ring.Ordered Methods negate :: Modular Word8 -> Modular Word8 #
Ring (Modular Word) # |
Instance details Defined in Data.Ring.Ordered Methods negate :: Modular Word -> Modular Word #
Num a => Ring (WrappedNum a) # |
Instance details Defined in Data.Semiring Methods negate :: WrappedNum a -> WrappedNum a #
HasResolution a => Ring (Fixed a) # |
Instance details Defined in Data.Semiring Methods negate :: Fixed a -> Fixed a #
Ring a => Ring (Op a b) # |
Instance details Defined in Data.Semiring Methods negate :: Op a b -> Op a b #
(Ring a, Ring b) => Ring (a, b) # |
Instance details Defined in Data.Semiring Methods negate :: (a, b) -> (a, b) #
Ring b => Ring (a -> b) # |
Instance details Defined in Data.Semiring Methods negate :: (a -> b) -> a -> b #
Ring a => Ring (Const a b) # |
Instance details Defined in Data.Semiring Methods negate :: Const a b -> Const a b #
(Ring a, Applicative f) => Ring (Ap f a) # |
Instance details Defined in Data.Semiring Methods negate :: Ap f a -> Ap f a #
(Ring a, Ring b, Ring c) => Ring (a, b, c) # |
Instance details Defined in Data.Semiring Methods negate :: (a, b, c) -> (a, b, c) #
(Ring a, Ring b, Ring c, Ring d) => Ring (a, b, c, d) # |
Instance details Defined in Data.Semiring Methods negate :: (a, b, c, d) -> (a, b, c, d) #
(Ring a, Ring b, Ring c, Ring d, Ring e) => Ring (a, b, c, d, e) # |
Instance details Defined in Data.Semiring Methods negate :: (a, b, c, d, e) -> (a, b, c, d, e) #
(Ring a, Ring b, Ring c, Ring d, Ring e, Ring f) => Ring (a, b, c, d, e, f) # |
Instance details Defined in Data.Semiring Methods negate :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) #
(Ring a, Ring b, Ring c, Ring d, Ring e, Ring f, Ring g) => Ring (a, b, c, d, e, f, g) # |
Instance details Defined in Data.Semiring Methods negate :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) #

fromInteger :: Ring a => Integer -> a #

Convert from integer to ring.

When `{-#` `LANGUAGE RebindableSyntax #-}` is enabled, this function is used for desugaring integer literals. This may be used to facilitate transition from `Num` to `Ring`: no need to replace 0 and 1 with `one` and `zero` or to cast numeric literals.

fromIntegral :: (Integral a, Ring b) => a -> b #

Convert from integral to ring.

minus :: Ring a => a -> a -> a infixl 6 #

Subtract two `Ring` values. For any type `R` with a `Num` instance, this is the same as `(-)`.

    x minus y = x + negate y

(-) :: Ring a => a -> a -> a infixl 6 #

Infix shorthand for `minus`.