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

plus infixl 6 Source #

Arguments

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

zero Source #

Arguments

:: a | Commutative Unit

times infixl 7 Source #

Arguments

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

one Source #

Arguments

:: a | Associative Unit

fromNatural Source #

Arguments

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

#### Instances

Instances details

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

Infix shorthand for `plus`.

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

Infix shorthand for `times`.

(^) :: (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`.

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

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

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

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

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

Is the value `zero`?

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

Is the value `one`?

# Types

newtype Add a Source #

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

Constructors

Add |

Fields

- getAdd :: a

#### Instances

Instances details

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

Instance details

Defined in Data.Semiring

Methods

fold :: Monoid m => Add m -> m Source #

foldMap :: Monoid m => (a -> m) -> Add a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Add a -> m Source #

foldr :: (a -> b -> b) -> b -> Add a -> b Source #

foldr' :: (a -> b -> b) -> b -> Add a -> b Source #

foldl :: (b -> a -> b) -> b -> Add a -> b Source #

foldl' :: (b -> a -> b) -> b -> Add a -> b Source #

foldr1 :: (a -> a -> a) -> Add a -> a Source #

foldl1 :: (a -> a -> a) -> Add a -> a Source #

toList :: Add a -> [a] Source #

null :: Add a -> Bool Source #

length :: Add a -> Int Source #

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

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

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

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

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

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

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-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "Add" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAdd") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))

Methods

from1 :: Add a -> Rep1 Add a Source #

to1 :: Rep1 Add a -> Add a Source #

Semiring a => Monoid (Add a) Source # |
Instance details Defined in Data.Semiring Methods mempty :: Add a Source # mappend :: Add a -> Add a -> Add a Source # mconcat :: [Add a] -> Add a Source #
Semiring a => Semigroup (Add a) Source # |
Instance details Defined in Data.Semiring Methods (<>) :: Add a -> Add a -> Add a Source # sconcat :: NonEmpty (Add a) -> Add a Source # stimes :: Integral b => b -> Add a -> Add a Source #
Bounded a => Bounded (Add a) Source # |
Instance details Defined in Data.Semiring Methods minBound :: Add a Source # maxBound :: Add a Source #
Enum a => Enum (Add a) Source # |
Instance details Defined in Data.Semiring Methods succ :: Add a -> Add a Source # pred :: Add a -> Add a Source # toEnum :: Int -> Add a Source # fromEnum :: Add a -> Int Source # enumFrom :: Add a -> [Add a] Source # enumFromThen :: Add a -> Add a -> [Add a] Source # enumFromTo :: Add a -> Add a -> [Add a] Source # enumFromThenTo :: Add a -> Add a -> Add a -> [Add a] Source #
Storable a => Storable (Add a) Source # |

Instance details

Defined in Data.Semiring

Methods

sizeOf :: Add a -> Int Source #

alignment :: Add a -> Int Source #

peekElemOff :: Ptr (Add a) -> Int -> IO (Add a) Source #

pokeElemOff :: Ptr (Add a) -> Int -> Add a -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO (Add a) Source #

pokeByteOff :: Ptr b -> Int -> Add a -> IO () Source #

peek :: Ptr (Add a) -> IO (Add a) Source #

poke :: Ptr (Add a) -> Add a -> IO () Source #

Generic (Add a) Source # |

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-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "Add" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAdd") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Methods

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

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

Num a => Num (Add a) Source # |
Instance details Defined in Data.Semiring Methods (+) :: Add a -> Add a -> Add a Source # (-) :: Add a -> Add a -> Add a Source # (*) :: Add a -> Add a -> Add a Source # negate :: Add a -> Add a Source # abs :: Add a -> Add a Source # signum :: Add a -> Add a Source # fromInteger :: Integer -> Add a Source #
Read a => Read (Add a) Source # |
Instance details Defined in Data.Semiring Methods readsPrec :: Int -> ReadS (Add a) Source # readList :: ReadS [Add a] Source # readPrec :: ReadPrec (Add a) Source # readListPrec :: ReadPrec [Add a] Source #
Fractional a => Fractional (Add a) Source # |
Instance details Defined in Data.Semiring Methods (/) :: Add a -> Add a -> Add a Source # recip :: Add a -> Add a Source # fromRational :: Rational -> Add a Source #
Real a => Real (Add a) Source # |
Instance details Defined in Data.Semiring Methods toRational :: Add a -> Rational Source #
RealFrac a => RealFrac (Add a) Source # |
Instance details Defined in Data.Semiring Methods properFraction :: Integral b => Add a -> (b, Add a) Source # truncate :: Integral b => Add a -> b Source # round :: Integral b => Add a -> b Source # ceiling :: Integral b => Add a -> b Source # floor :: Integral b => Add a -> b Source #
Show a => Show (Add a) Source # |
Instance details Defined in Data.Semiring Methods showsPrec :: Int -> Add a -> ShowS Source # show :: Add a -> String Source # showList :: [Add a] -> ShowS Source #
Eq a => Eq (Add a) Source # |
Instance details Defined in Data.Semiring Methods (==) :: Add a -> Add a -> Bool Source # (/=) :: Add a -> Add a -> Bool Source #
Ord a => Ord (Add a) Source # |
Instance details Defined in Data.Semiring Methods compare :: Add a -> Add a -> Ordering Source # (<) :: Add a -> Add a -> Bool Source # (<=) :: Add a -> Add a -> Bool Source # (>) :: Add a -> Add a -> Bool Source # (>=) :: Add a -> Add a -> Bool Source # max :: Add a -> Add a -> Add a Source # min :: Add a -> Add a -> Add a Source #
type Rep1 Add Source # |
Instance details 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 # |
Instance details 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)))

newtype Mul a Source #

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

Constructors

Mul |

Fields

- getMul :: a

#### Instances

Instances details

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

Instance details

Defined in Data.Semiring

Methods

fold :: Monoid m => Mul m -> m Source #

foldMap :: Monoid m => (a -> m) -> Mul a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Mul a -> m Source #

foldr :: (a -> b -> b) -> b -> Mul a -> b Source #

foldr' :: (a -> b -> b) -> b -> Mul a -> b Source #

foldl :: (b -> a -> b) -> b -> Mul a -> b Source #

foldl' :: (b -> a -> b) -> b -> Mul a -> b Source #

foldr1 :: (a -> a -> a) -> Mul a -> a Source #

foldl1 :: (a -> a -> a) -> Mul a -> a Source #

toList :: Mul a -> [a] Source #

null :: Mul a -> Bool Source #

length :: Mul a -> Int Source #

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

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

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

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

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

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

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-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "Mul" 'PrefixI 'True) (S1 ('MetaSel ('Just "getMul") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))

Methods

from1 :: Mul a -> Rep1 Mul a Source #

to1 :: Rep1 Mul a -> Mul a Source #

Semiring a => Monoid (Mul a) Source # |
Instance details Defined in Data.Semiring Methods mempty :: Mul a Source # mappend :: Mul a -> Mul a -> Mul a Source # mconcat :: [Mul a] -> Mul a Source #
Semiring a => Semigroup (Mul a) Source # |
Instance details Defined in Data.Semiring Methods (<>) :: Mul a -> Mul a -> Mul a Source # sconcat :: NonEmpty (Mul a) -> Mul a Source # stimes :: Integral b => b -> Mul a -> Mul a Source #
Bounded a => Bounded (Mul a) Source # |
Instance details Defined in Data.Semiring Methods minBound :: Mul a Source # maxBound :: Mul a Source #
Enum a => Enum (Mul a) Source # |
Instance details Defined in Data.Semiring Methods succ :: Mul a -> Mul a Source # pred :: Mul a -> Mul a Source # toEnum :: Int -> Mul a Source # fromEnum :: Mul a -> Int Source # enumFrom :: Mul a -> [Mul a] Source # enumFromThen :: Mul a -> Mul a -> [Mul a] Source # enumFromTo :: Mul a -> Mul a -> [Mul a] Source # enumFromThenTo :: Mul a -> Mul a -> Mul a -> [Mul a] Source #
Storable a => Storable (Mul a) Source # |

Instance details

Defined in Data.Semiring

Methods

sizeOf :: Mul a -> Int Source #

alignment :: Mul a -> Int Source #

peekElemOff :: Ptr (Mul a) -> Int -> IO (Mul a) Source #

pokeElemOff :: Ptr (Mul a) -> Int -> Mul a -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO (Mul a) Source #

pokeByteOff :: Ptr b -> Int -> Mul a -> IO () Source #

peek :: Ptr (Mul a) -> IO (Mul a) Source #

poke :: Ptr (Mul a) -> Mul a -> IO () Source #

Generic (Mul a) Source # |

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-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "Mul" 'PrefixI 'True) (S1 ('MetaSel ('Just "getMul") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Methods

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

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

Num a => Num (Mul a) Source # |
Instance details Defined in Data.Semiring Methods (+) :: Mul a -> Mul a -> Mul a Source # (-) :: Mul a -> Mul a -> Mul a Source # (*) :: Mul a -> Mul a -> Mul a Source # negate :: Mul a -> Mul a Source # abs :: Mul a -> Mul a Source # signum :: Mul a -> Mul a Source # fromInteger :: Integer -> Mul a Source #
Read a => Read (Mul a) Source # |
Instance details Defined in Data.Semiring Methods readsPrec :: Int -> ReadS (Mul a) Source # readList :: ReadS [Mul a] Source # readPrec :: ReadPrec (Mul a) Source # readListPrec :: ReadPrec [Mul a] Source #
Fractional a => Fractional (Mul a) Source # |
Instance details Defined in Data.Semiring Methods (/) :: Mul a -> Mul a -> Mul a Source # recip :: Mul a -> Mul a Source # fromRational :: Rational -> Mul a Source #
Real a => Real (Mul a) Source # |
Instance details Defined in Data.Semiring Methods toRational :: Mul a -> Rational Source #
RealFrac a => RealFrac (Mul a) Source # |
Instance details Defined in Data.Semiring Methods properFraction :: Integral b => Mul a -> (b, Mul a) Source # truncate :: Integral b => Mul a -> b Source # round :: Integral b => Mul a -> b Source # ceiling :: Integral b => Mul a -> b Source # floor :: Integral b => Mul a -> b Source #
Show a => Show (Mul a) Source # |
Instance details Defined in Data.Semiring Methods showsPrec :: Int -> Mul a -> ShowS Source # show :: Mul a -> String Source # showList :: [Mul a] -> ShowS Source #
Eq a => Eq (Mul a) Source # |
Instance details Defined in Data.Semiring Methods (==) :: Mul a -> Mul a -> Bool Source # (/=) :: Mul a -> Mul a -> Bool Source #
Ord a => Ord (Mul a) Source # |
Instance details Defined in Data.Semiring Methods compare :: Mul a -> Mul a -> Ordering Source # (<) :: Mul a -> Mul a -> Bool Source # (<=) :: Mul a -> Mul a -> Bool Source # (>) :: Mul a -> Mul a -> Bool Source # (>=) :: Mul a -> Mul a -> Bool Source # max :: Mul a -> Mul a -> Mul a Source # min :: Mul a -> Mul a -> Mul a Source #
type Rep1 Mul Source # |
Instance details 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 # |
Instance details 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.

Constructors

WrapNum |

Fields

- unwrapNum :: a

#### Instances

Instances details

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

Instance details

Defined in Data.Semiring

Methods

fold :: Monoid m => WrappedNum m -> m Source #

foldMap :: Monoid m => (a -> m) -> WrappedNum a -> m Source #

foldMap' :: Monoid m => (a -> m) -> WrappedNum a -> m Source #

foldr :: (a -> b -> b) -> b -> WrappedNum a -> b Source #

foldr' :: (a -> b -> b) -> b -> WrappedNum a -> b Source #

foldl :: (b -> a -> b) -> b -> WrappedNum a -> b Source #

foldl' :: (b -> a -> b) -> b -> WrappedNum a -> b Source #

foldr1 :: (a -> a -> a) -> WrappedNum a -> a Source #

foldl1 :: (a -> a -> a) -> WrappedNum a -> a Source #

toList :: WrappedNum a -> [a] Source #

null :: WrappedNum a -> Bool Source #

length :: WrappedNum a -> Int Source #

elem :: Eq a => a -> WrappedNum a -> Bool Source #

maximum :: Ord a => WrappedNum a -> a Source #

minimum :: Ord a => WrappedNum a -> a Source #

sum :: Num a => WrappedNum a -> a Source #

product :: Num a => WrappedNum a -> a Source #

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

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-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "WrapNum" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapNum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))

Methods

from1 :: WrappedNum a -> Rep1 WrappedNum a Source #

to1 :: Rep1 WrappedNum a -> WrappedNum a Source #

Bits a => Bits (WrappedNum a) Source # |

Instance details

Defined in Data.Semiring

Methods

(.&.) :: WrappedNum a -> WrappedNum a -> WrappedNum a Source #

(.|.) :: WrappedNum a -> WrappedNum a -> WrappedNum a Source #

xor :: WrappedNum a -> WrappedNum a -> WrappedNum a Source #

complement :: WrappedNum a -> WrappedNum a Source #

shift :: WrappedNum a -> Int -> WrappedNum a Source #

rotate :: WrappedNum a -> Int -> WrappedNum a Source #

zeroBits :: WrappedNum a Source #

bit :: Int -> WrappedNum a Source #

setBit :: WrappedNum a -> Int -> WrappedNum a Source #

clearBit :: WrappedNum a -> Int -> WrappedNum a Source #

complementBit :: WrappedNum a -> Int -> WrappedNum a Source #

testBit :: WrappedNum a -> Int -> Bool Source #

bitSizeMaybe :: WrappedNum a -> Maybe Int Source #

bitSize :: WrappedNum a -> Int Source #

isSigned :: WrappedNum a -> Bool Source #

shiftL :: WrappedNum a -> Int -> WrappedNum a Source #

unsafeShiftL :: WrappedNum a -> Int -> WrappedNum a Source #

shiftR :: WrappedNum a -> Int -> WrappedNum a Source #

unsafeShiftR :: WrappedNum a -> Int -> WrappedNum a Source #

rotateL :: WrappedNum a -> Int -> WrappedNum a Source #

rotateR :: WrappedNum a -> Int -> WrappedNum a Source #

popCount :: WrappedNum a -> Int Source #

Bounded a => Bounded (WrappedNum a) Source # |
Instance details Defined in Data.Semiring Methods minBound :: WrappedNum a Source # maxBound :: WrappedNum a Source #
Enum a => Enum (WrappedNum a) Source # |

Instance details

Defined in Data.Semiring

Methods

succ :: WrappedNum a -> WrappedNum a Source #

pred :: WrappedNum a -> WrappedNum a Source #

toEnum :: Int -> WrappedNum a Source #

fromEnum :: WrappedNum a -> Int Source #

enumFrom :: WrappedNum a -> [WrappedNum a] Source #

enumFromThen :: WrappedNum a -> WrappedNum a -> [WrappedNum a] Source #

enumFromTo :: WrappedNum a -> WrappedNum a -> [WrappedNum a] Source #

enumFromThenTo :: WrappedNum a -> WrappedNum a -> WrappedNum a -> [WrappedNum a] Source #

Storable a => Storable (WrappedNum a) Source # |

Instance details

Defined in Data.Semiring

Methods

sizeOf :: WrappedNum a -> Int Source #

alignment :: WrappedNum a -> Int Source #

peekElemOff :: Ptr (WrappedNum a) -> Int -> IO (WrappedNum a) Source #

pokeElemOff :: Ptr (WrappedNum a) -> Int -> WrappedNum a -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO (WrappedNum a) Source #

pokeByteOff :: Ptr b -> Int -> WrappedNum a -> IO () Source #

peek :: Ptr (WrappedNum a) -> IO (WrappedNum a) Source #

poke :: Ptr (WrappedNum a) -> WrappedNum a -> IO () Source #

Generic (WrappedNum a) Source # |

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-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "WrapNum" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapNum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Methods

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

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

Num a => Num (WrappedNum a) Source # |

Instance details

Defined in Data.Semiring

Methods

(+) :: WrappedNum a -> WrappedNum a -> WrappedNum a Source #

(-) :: WrappedNum a -> WrappedNum a -> WrappedNum a Source #

(*) :: WrappedNum a -> WrappedNum a -> WrappedNum a Source #

negate :: WrappedNum a -> WrappedNum a Source #

abs :: WrappedNum a -> WrappedNum a Source #

signum :: WrappedNum a -> WrappedNum a Source #

fromInteger :: Integer -> WrappedNum a Source #

Read a => Read (WrappedNum a) Source # |
Instance details Defined in Data.Semiring Methods readsPrec :: Int -> ReadS (WrappedNum a) Source # readList :: ReadS [WrappedNum a] Source # readPrec :: ReadPrec (WrappedNum a) Source # readListPrec :: ReadPrec [WrappedNum a] Source #
Fractional a => Fractional (WrappedNum a) Source # |
Instance details Defined in Data.Semiring Methods (/) :: WrappedNum a -> WrappedNum a -> WrappedNum a Source # recip :: WrappedNum a -> WrappedNum a Source # fromRational :: Rational -> WrappedNum a Source #
Real a => Real (WrappedNum a) Source # |
Instance details Defined in Data.Semiring Methods toRational :: WrappedNum a -> Rational Source #
RealFrac a => RealFrac (WrappedNum a) Source # |
Instance details Defined in Data.Semiring Methods properFraction :: Integral b => WrappedNum a -> (b, WrappedNum a) Source # truncate :: Integral b => WrappedNum a -> b Source # round :: Integral b => WrappedNum a -> b Source # ceiling :: Integral b => WrappedNum a -> b Source # floor :: Integral b => WrappedNum a -> b Source #
Show a => Show (WrappedNum a) Source # |
Instance details Defined in Data.Semiring Methods showsPrec :: Int -> WrappedNum a -> ShowS Source # show :: WrappedNum a -> String Source # showList :: [WrappedNum a] -> ShowS Source #
Eq a => Eq (WrappedNum a) Source # |
Instance details Defined in Data.Semiring Methods (==) :: WrappedNum a -> WrappedNum a -> Bool Source # (/=) :: WrappedNum a -> WrappedNum a -> Bool Source #
Ord a => Ord (WrappedNum a) Source # |

Instance details

Defined in Data.Semiring

Methods

compare :: WrappedNum a -> WrappedNum a -> Ordering Source #

(<) :: WrappedNum a -> WrappedNum a -> Bool Source #

(<=) :: WrappedNum a -> WrappedNum a -> Bool Source #

(>) :: WrappedNum a -> WrappedNum a -> Bool Source #

(>=) :: WrappedNum a -> WrappedNum a -> Bool Source #

max :: WrappedNum a -> WrappedNum a -> WrappedNum a Source #

min :: WrappedNum a -> WrappedNum a -> WrappedNum a Source #

Num a => Ring (WrappedNum a) Source # |
Instance details Defined in Data.Semiring Methods negate :: WrappedNum a -> WrappedNum a Source #
Num a => Semiring (WrappedNum a) Source # |
Instance details 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 # |
Instance details 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 # |
Instance details 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)))

newtype Mod2 Source #

`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 Source # |
Instance details Defined in Data.Semiring Methods minBound :: Mod2 Source # maxBound :: Mod2 Source #
Enum Mod2 Source # |
Instance details Defined in Data.Semiring Methods succ :: Mod2 -> Mod2 Source # pred :: Mod2 -> Mod2 Source # toEnum :: Int -> Mod2 Source # fromEnum :: Mod2 -> Int Source # enumFrom :: Mod2 -> [Mod2] Source # enumFromThen :: Mod2 -> Mod2 -> [Mod2] Source # enumFromTo :: Mod2 -> Mod2 -> [Mod2] Source # enumFromThenTo :: Mod2 -> Mod2 -> Mod2 -> [Mod2] Source #
Generic Mod2 Source # |

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-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "Mod2" 'PrefixI 'True) (S1 ('MetaSel ('Just "getMod2") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))

Methods

from :: Mod2 -> Rep Mod2 x Source #

to :: Rep Mod2 x -> Mod2 Source #

Read Mod2 Source # |
Instance details Defined in Data.Semiring Methods readsPrec :: Int -> ReadS Mod2 Source # readList :: ReadS [Mod2] Source # readPrec :: ReadPrec Mod2 Source # readListPrec :: ReadPrec [Mod2] Source #
Show Mod2 Source # |
Instance details Defined in Data.Semiring Methods showsPrec :: Int -> Mod2 -> ShowS Source # show :: Mod2 -> String Source # showList :: [Mod2] -> ShowS Source #
Eq Mod2 Source # |
Instance details Defined in Data.Semiring Methods (==) :: Mod2 -> Mod2 -> Bool Source # (/=) :: Mod2 -> Mod2 -> Bool Source #
Ord Mod2 Source # |
Instance details Defined in Data.Semiring Methods compare :: Mod2 -> Mod2 -> Ordering Source # (<) :: Mod2 -> Mod2 -> Bool Source # (<=) :: Mod2 -> Mod2 -> Bool Source # (>) :: Mod2 -> Mod2 -> Bool Source # (>=) :: Mod2 -> Mod2 -> Bool Source # max :: Mod2 -> Mod2 -> Mod2 Source # min :: Mod2 -> Mod2 -> Mod2 Source #
Euclidean Mod2 Source # |
Instance details Defined in Data.Euclidean Methods quotRem :: Mod2 -> Mod2 -> (Mod2, Mod2) Source # quot :: Mod2 -> Mod2 -> Mod2 Source # rem :: Mod2 -> Mod2 -> Mod2 Source # degree :: Mod2 -> Natural Source #
Field Mod2 Source # |
Instance details Defined in Data.Euclidean
GcdDomain Mod2 Source # |
Instance details Defined in Data.Euclidean Methods divide :: Mod2 -> Mod2 -> Maybe Mod2 Source # gcd :: Mod2 -> Mod2 -> Mod2 Source # lcm :: Mod2 -> Mod2 -> Mod2 Source # coprime :: Mod2 -> Mod2 -> Bool Source #
Ring Mod2 Source # |
Instance details Defined in Data.Semiring Methods negate :: Mod2 -> Mod2 Source #
Semiring Mod2 Source # |
Instance details Defined in Data.Semiring Methods plus :: Mod2 -> Mod2 -> Mod2 Source # zero :: Mod2 Source # times :: Mod2 -> Mod2 -> Mod2 Source # one :: Mod2 Source # fromNatural :: Natural -> Mod2 Source #
Star Mod2 Source # |
Instance details Defined in Data.Star Methods star :: Mod2 -> Mod2 Source # aplus :: Mod2 -> Mod2 Source #
type Rep Mod2 Source # |
Instance details 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)))

newtype IntSetOf a Source #

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

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-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "IntSetOf" 'PrefixI 'True) (S1 ('MetaSel ('Just "getIntSet") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IntSet)))

Methods

from1 :: IntSetOf a -> Rep1 IntSetOf a Source #

to1 :: Rep1 IntSetOf a -> IntSetOf a Source #

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

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-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "IntSetOf" 'PrefixI 'True) (S1 ('MetaSel ('Just "getIntSet") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IntSet)))

Methods

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

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

Read (IntSetOf a) Source # |
Instance details Defined in Data.Semiring Methods readsPrec :: Int -> ReadS (IntSetOf a) Source # readList :: ReadS [IntSetOf a] Source # readPrec :: ReadPrec (IntSetOf a) Source # readListPrec :: ReadPrec [IntSetOf a] Source #
Show (IntSetOf a) Source # |
Instance details Defined in Data.Semiring Methods showsPrec :: Int -> IntSetOf a -> ShowS Source # show :: IntSetOf a -> String Source # showList :: [IntSetOf a] -> ShowS Source #
Eq (IntSetOf a) Source # |
Instance details Defined in Data.Semiring Methods (==) :: IntSetOf a -> IntSetOf a -> Bool Source # (/=) :: IntSetOf a -> IntSetOf a -> Bool Source #
Ord (IntSetOf a) Source # |

Instance details

Defined in Data.Semiring

Methods

compare :: IntSetOf a -> IntSetOf a -> Ordering Source #

(<) :: IntSetOf a -> IntSetOf a -> Bool Source #

(<=) :: IntSetOf a -> IntSetOf a -> Bool Source #

(>) :: IntSetOf a -> IntSetOf a -> Bool Source #

(>=) :: IntSetOf a -> IntSetOf a -> Bool Source #

max :: IntSetOf a -> IntSetOf a -> IntSetOf a Source #

min :: IntSetOf a -> IntSetOf a -> IntSetOf a Source #

(Coercible Int a, Monoid a) => Semiring (IntSetOf a) Source # |
Instance details Defined in Data.Semiring Methods plus :: IntSetOf a -> IntSetOf a -> IntSetOf a Source # zero :: IntSetOf a Source # times :: IntSetOf a -> IntSetOf a -> IntSetOf a Source # one :: IntSetOf a Source # fromNatural :: Natural -> IntSetOf a Source #
type Rep1 IntSetOf Source # |
Instance details 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 # |
Instance details 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)))

newtype IntMapOf k v Source #

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

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-GfH8CFjnoFgLT6ACdLwAYA" 'True) (C1 ('MetaCons "IntMapOf" 'PrefixI 'True) (S1 ('MetaSel ('Just "getIntMap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 IntMap)))

Methods

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

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

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

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-GfH8CFjnoFgLT6ACdLwAYA" '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 Source #

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

Read v => Read (IntMapOf k v) Source # |
Instance details Defined in Data.Semiring Methods readsPrec :: Int -> ReadS (IntMapOf k v) Source # readList :: ReadS [IntMapOf k v] Source # readPrec :: ReadPrec (IntMapOf k v) Source # readListPrec :: ReadPrec [IntMapOf k v] Source #
Show v => Show (IntMapOf k v) Source # |
Instance details Defined in Data.Semiring Methods showsPrec :: Int -> IntMapOf k v -> ShowS Source # show :: IntMapOf k v -> String Source # showList :: [IntMapOf k v] -> ShowS Source #
Eq v => Eq (IntMapOf k v) Source # |
Instance details Defined in Data.Semiring Methods (==) :: IntMapOf k v -> IntMapOf k v -> Bool Source # (/=) :: IntMapOf k v -> IntMapOf k v -> Bool Source #
Ord v => Ord (IntMapOf k v) Source # |

Instance details

Defined in Data.Semiring

Methods

compare :: IntMapOf k v -> IntMapOf k v -> Ordering Source #

(<) :: IntMapOf k v -> IntMapOf k v -> Bool Source #

(<=) :: IntMapOf k v -> IntMapOf k v -> Bool Source #

(>) :: IntMapOf k v -> IntMapOf k v -> Bool Source #

(>=) :: IntMapOf k v -> IntMapOf k v -> Bool Source #

max :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v Source #

min :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v Source #

(Coercible Int k, Monoid k, Semiring v) => Semiring (IntMapOf k v) Source # |
Instance details Defined in Data.Semiring Methods plus :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v Source # zero :: IntMapOf k v Source # times :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v Source # one :: IntMapOf k v Source # fromNatural :: Natural -> IntMapOf k v Source #
type Rep1 (IntMapOf k :: Type -> Type) Source # |
Instance details 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 # |
Instance details 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 #

The class of semirings with an additive inverse.

    negate a + a = zero

Methods

negate :: a -> a Source #

#### Instances

Instances details

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

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

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

Convert from integral to ring.

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

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

Infix shorthand for `minus`.