{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
#if MIN_VERSION_base(4,12,0)
{-# LANGUAGE DerivingVia #-}
#else
{-# LANGUAGE TemplateHaskell #-}
#endif
module Data.Semiring
(
Semiring(..)
, (+)
, (*)
, (^)
, foldMapP
, foldMapT
, sum
, product
, sum'
, product'
, isZero
, isOne
, Add(..)
, Mul(..)
, WrappedNum(..)
, Mod2(..)
#if defined(VERSION_containers)
, IntSetOf(..)
, IntMapOf(..)
#endif
, Ring(..)
, fromInteger
, fromIntegral
, minus
, (-)
) where
import Control.Applicative (Applicative(..), Const(..), liftA2)
import Data.Bits (Bits)
import Data.Bool (Bool(..), (||), (&&), otherwise)
import Data.Coerce (Coercible, coerce)
import Data.Complex (Complex(..))
import Data.Eq (Eq(..))
import Data.Fixed (Fixed, HasResolution)
import Data.Foldable (Foldable(foldMap))
import qualified Data.Foldable as Foldable
import Data.Function ((.), const, id)
#if defined(VERSION_unordered_containers) || defined(VERSION_containers)
import Data.Function (flip)
#endif
import Data.Functor (Functor(..))
#if MIN_VERSION_base(4,12,0)
import Data.Functor.Contravariant (Predicate(..), Equivalence(..), Op(..))
#endif
import Data.Functor.Identity (Identity(..))
#if defined(VERSION_unordered_containers)
import Data.Hashable (Hashable)
import Data.HashMap.Strict (HashMap)
import qualified Data.HashMap.Strict as HashMap
import Data.HashSet (HashSet)
import qualified Data.HashSet as HashSet
#endif
import Data.Int (Int, Int8, Int16, Int32, Int64)
import Data.Maybe (Maybe(..))
#if MIN_VERSION_base(4,12,0)
import Data.Monoid (Ap(..))
#endif
#if defined(VERSION_containers)
#if MIN_VERSION_base(4,7,0)
import Data.IntMap (IntMap)
import qualified Data.IntMap as IntMap
import Data.IntSet (IntSet)
import qualified Data.IntSet as IntSet
#endif
import Data.Map (Map)
import qualified Data.Map as Map
#endif
import Data.Monoid (Monoid(..), Dual(..))
import Data.Ord (Ord((<)), (>=))
import Data.Ord (Down(..))
import Data.Proxy (Proxy(..))
import Data.Ratio (Ratio, Rational, (%))
import Data.Semigroup.Compat (Semigroup(..))
#if defined(VERSION_containers)
import Data.Set (Set)
import qualified Data.Set as Set
#endif
import Data.Traversable (Traversable)
import Data.Typeable (Typeable)
import Data.Word (Word, Word8, Word16, Word32, Word64)
import Foreign.C.Types
(CChar, CClock, CDouble, CFloat, CInt,
CIntMax, CIntPtr, CLLong, CLong,
CPtrdiff, CSChar, CSUSeconds, CShort,
CSigAtomic, CSize, CTime, CUChar, CUInt,
CUIntMax, CUIntPtr, CULLong, CULong,
CUSeconds, CUShort, CWchar)
import Foreign.Ptr (IntPtr, WordPtr)
import Foreign.Storable (Storable)
import GHC.Enum (Enum, Bounded)
import GHC.Err (error)
import GHC.Float (Float, Double)
import GHC.Generics (Generic,Generic1)
import GHC.IO (IO)
import qualified GHC.Num as Num
import GHC.Read (Read)
import GHC.Real (Integral, Fractional, Real, RealFrac)
import qualified GHC.Real as Real
import GHC.Show (Show)
import Numeric.Natural (Natural)
import Prelude (Integer)
#if !MIN_VERSION_base(4,12,0)
import Language.Haskell.TH.Syntax (Q, Dec, Type)
import qualified Prelude as P
#endif
#ifdef mingw32_HOST_OS
#define HOST_OS_WINDOWS 1
#else
#define HOST_OS_WINDOWS 0
#endif
#if !HOST_OS_WINDOWS
import System.Posix.Types
(CCc, CDev, CGid, CIno, CMode, CNlink,
COff, CPid, CRLim, CSpeed, CSsize,
CTcflag, CUid, Fd)
#endif
infixl 7 *, `times`
infixl 6 +, `plus`, -, `minus`
infixr 8 ^
{-# SPECIALISE [1] (^) ::
Integer -> Integer -> Integer,
Integer -> Int -> Integer,
Int -> Int -> Int #-}
{-# INLINABLE [1] (^) #-}
(^) :: (Semiring a, Integral b) => a -> b -> a
a
x ^ :: a -> b -> a
^ b
y
| b
y b -> b -> Bool
forall a. Ord a => a -> a -> Bool
< b
0 = [Char] -> a
forall a. HasCallStack => [Char] -> a
error [Char]
"Data.Semiring.^: negative power"
| b
y b -> b -> Bool
forall a. Eq a => a -> a -> Bool
== b
0 = a
forall a. Semiring a => a
one
| Bool
otherwise = Mul a -> a
forall a. Mul a -> a
getMul (b -> Mul a -> Mul a
forall a b. (Semigroup a, Integral b) => b -> a -> a
stimes b
y (a -> Mul a
forall a. a -> Mul a
Mul a
x))
{-# RULES
"^0/Int" forall x. x ^ (0 :: Int) = one
"^1/Int" forall x. x ^ (1 :: Int) = let u = x in u
"^2/Int" forall x. x ^ (2 :: Int) = let u = x in u*u
"^3/Int" forall x. x ^ (3 :: Int) = let u = x in u*u*u
"^4/Int" forall x. x ^ (4 :: Int) = let u = x in u*u*u*u
"^5/Int" forall x. x ^ (5 :: Int) = let u = x in u*u*u*u*u
"^0/Integer" forall x. x ^ (0 :: Integer) = one
"^1/Integer" forall x. x ^ (1 :: Integer) = let u = x in u
"^2/Integer" forall x. x ^ (2 :: Integer) = let u = x in u*u
"^3/Integer" forall x. x ^ (3 :: Integer) = let u = x in u*u*u
"^4/Integer" forall x. x ^ (4 :: Integer) = let u = x in u*u*u*u
"^5/Integer" forall x. x ^ (5 :: Integer) = let u = x in u*u*u*u*u
#-}
(+) :: Semiring a => a -> a -> a
+ :: a -> a -> a
(+) = a -> a -> a
forall a. Semiring a => a -> a -> a
plus
{-# INLINE (+) #-}
(*) :: Semiring a => a -> a -> a
* :: a -> a -> a
(*) = a -> a -> a
forall a. Semiring a => a -> a -> a
times
{-# INLINE (*) #-}
(-) :: Ring a => a -> a -> a
(-) = a -> a -> a
forall a. Ring a => a -> a -> a
minus
{-# INLINE (-) #-}
foldMapP :: (Foldable t, Semiring s) => (a -> s) -> t a -> s
foldMapP :: (a -> s) -> t a -> s
foldMapP a -> s
f = (a -> s -> s) -> s -> t a -> s
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
Foldable.foldr (s -> s -> s
forall a. Semiring a => a -> a -> a
plus (s -> s -> s) -> (a -> s) -> a -> s -> s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> s
f) s
forall a. Semiring a => a
zero
{-# INLINE foldMapP #-}
foldMapT :: (Foldable t, Semiring s) => (a -> s) -> t a -> s
foldMapT :: (a -> s) -> t a -> s
foldMapT a -> s
f = (a -> s -> s) -> s -> t a -> s
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
Foldable.foldr (s -> s -> s
forall a. Semiring a => a -> a -> a
times (s -> s -> s) -> (a -> s) -> a -> s -> s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> s
f) s
forall a. Semiring a => a
one
{-# INLINE foldMapT #-}
infixr 9 #.
(#.) :: Coercible b c => (b -> c) -> (a -> b) -> a -> c
#. :: (b -> c) -> (a -> b) -> a -> c
(#.) b -> c
_ = (a -> b) -> a -> c
coerce
sum :: (Foldable t, Semiring a) => t a -> a
sum :: t a -> a
sum = Add a -> a
forall a. Add a -> a
getAdd (Add a -> a) -> (t a -> Add a) -> t a -> a
forall b c a. Coercible b c => (b -> c) -> (a -> b) -> a -> c
#. (a -> Add a) -> t a -> Add a
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> Add a
forall a. a -> Add a
Add
{-# INLINE sum #-}
product :: (Foldable t, Semiring a) => t a -> a
product :: t a -> a
product = Mul a -> a
forall a. Mul a -> a
getMul (Mul a -> a) -> (t a -> Mul a) -> t a -> a
forall b c a. Coercible b c => (b -> c) -> (a -> b) -> a -> c
#. (a -> Mul a) -> t a -> Mul a
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> Mul a
forall a. a -> Mul a
Mul
{-# INLINE product #-}
sum' :: (Foldable t, Semiring a) => t a -> a
sum' :: t a -> a
sum' = (a -> a -> a) -> a -> t a -> a
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
Foldable.foldl' a -> a -> a
forall a. Semiring a => a -> a -> a
plus a
forall a. Semiring a => a
zero
{-# INLINE sum' #-}
product' :: (Foldable t, Semiring a) => t a -> a
product' :: t a -> a
product' = (a -> a -> a) -> a -> t a -> a
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
Foldable.foldl' a -> a -> a
forall a. Semiring a => a -> a -> a
times a
forall a. Semiring a => a
one
{-# INLINE product' #-}
newtype Add a = Add { Add a -> a
getAdd :: a }
deriving
( Add a
Add a -> Add a -> Bounded (Add a)
forall a. a -> a -> Bounded a
forall a. Bounded a => Add a
maxBound :: Add a
$cmaxBound :: forall a. Bounded a => Add a
minBound :: Add a
$cminBound :: forall a. Bounded a => Add a
Bounded
, Int -> Add a
Add a -> Int
Add a -> [Add a]
Add a -> Add a
Add a -> Add a -> [Add a]
Add a -> Add a -> Add a -> [Add a]
(Add a -> Add a)
-> (Add a -> Add a)
-> (Int -> Add a)
-> (Add a -> Int)
-> (Add a -> [Add a])
-> (Add a -> Add a -> [Add a])
-> (Add a -> Add a -> [Add a])
-> (Add a -> Add a -> Add a -> [Add a])
-> Enum (Add a)
forall a. Enum a => Int -> Add a
forall a. Enum a => Add a -> Int
forall a. Enum a => Add a -> [Add a]
forall a. Enum a => Add a -> Add a
forall a. Enum a => Add a -> Add a -> [Add a]
forall a. Enum a => Add a -> Add a -> Add a -> [Add a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Add a -> Add a -> Add a -> [Add a]
$cenumFromThenTo :: forall a. Enum a => Add a -> Add a -> Add a -> [Add a]
enumFromTo :: Add a -> Add a -> [Add a]
$cenumFromTo :: forall a. Enum a => Add a -> Add a -> [Add a]
enumFromThen :: Add a -> Add a -> [Add a]
$cenumFromThen :: forall a. Enum a => Add a -> Add a -> [Add a]
enumFrom :: Add a -> [Add a]
$cenumFrom :: forall a. Enum a => Add a -> [Add a]
fromEnum :: Add a -> Int
$cfromEnum :: forall a. Enum a => Add a -> Int
toEnum :: Int -> Add a
$ctoEnum :: forall a. Enum a => Int -> Add a
pred :: Add a -> Add a
$cpred :: forall a. Enum a => Add a -> Add a
succ :: Add a -> Add a
$csucc :: forall a. Enum a => Add a -> Add a
Enum
, Add a -> Add a -> Bool
(Add a -> Add a -> Bool) -> (Add a -> Add a -> Bool) -> Eq (Add a)
forall a. Eq a => Add a -> Add a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Add a -> Add a -> Bool
$c/= :: forall a. Eq a => Add a -> Add a -> Bool
== :: Add a -> Add a -> Bool
$c== :: forall a. Eq a => Add a -> Add a -> Bool
Eq
, Add a -> Bool
(a -> m) -> Add a -> m
(a -> b -> b) -> b -> Add a -> b
(forall m. Monoid m => Add m -> m)
-> (forall m a. Monoid m => (a -> m) -> Add a -> m)
-> (forall m a. Monoid m => (a -> m) -> Add a -> m)
-> (forall a b. (a -> b -> b) -> b -> Add a -> b)
-> (forall a b. (a -> b -> b) -> b -> Add a -> b)
-> (forall b a. (b -> a -> b) -> b -> Add a -> b)
-> (forall b a. (b -> a -> b) -> b -> Add a -> b)
-> (forall a. (a -> a -> a) -> Add a -> a)
-> (forall a. (a -> a -> a) -> Add a -> a)
-> (forall a. Add a -> [a])
-> (forall a. Add a -> Bool)
-> (forall a. Add a -> Int)
-> (forall a. Eq a => a -> Add a -> Bool)
-> (forall a. Ord a => Add a -> a)
-> (forall a. Ord a => Add a -> a)
-> (forall a. Num a => Add a -> a)
-> (forall a. Num a => Add a -> a)
-> Foldable Add
forall a. Eq a => a -> Add a -> Bool
forall a. Num a => Add a -> a
forall a. Ord a => Add a -> a
forall m. Monoid m => Add m -> m
forall a. Add a -> Bool
forall a. Add a -> Int
forall a. Add a -> [a]
forall a. (a -> a -> a) -> Add a -> a
forall m a. Monoid m => (a -> m) -> Add a -> m
forall b a. (b -> a -> b) -> b -> Add a -> b
forall a b. (a -> b -> b) -> b -> Add a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: Add a -> a
$cproduct :: forall a. Num a => Add a -> a
sum :: Add a -> a
$csum :: forall a. Num a => Add a -> a
minimum :: Add a -> a
$cminimum :: forall a. Ord a => Add a -> a
maximum :: Add a -> a
$cmaximum :: forall a. Ord a => Add a -> a
elem :: a -> Add a -> Bool
$celem :: forall a. Eq a => a -> Add a -> Bool
length :: Add a -> Int
$clength :: forall a. Add a -> Int
null :: Add a -> Bool
$cnull :: forall a. Add a -> Bool
toList :: Add a -> [a]
$ctoList :: forall a. Add a -> [a]
foldl1 :: (a -> a -> a) -> Add a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Add a -> a
foldr1 :: (a -> a -> a) -> Add a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Add a -> a
foldl' :: (b -> a -> b) -> b -> Add a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Add a -> b
foldl :: (b -> a -> b) -> b -> Add a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Add a -> b
foldr' :: (a -> b -> b) -> b -> Add a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Add a -> b
foldr :: (a -> b -> b) -> b -> Add a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Add a -> b
foldMap' :: (a -> m) -> Add a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Add a -> m
foldMap :: (a -> m) -> Add a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Add a -> m
fold :: Add m -> m
$cfold :: forall m. Monoid m => Add m -> m
Foldable
, Num (Add a)
Num (Add a)
-> (Add a -> Add a -> Add a)
-> (Add a -> Add a)
-> (Rational -> Add a)
-> Fractional (Add a)
Rational -> Add a
Add a -> Add a
Add a -> Add a -> Add a
forall a. Fractional a => Num (Add a)
forall a. Fractional a => Rational -> Add a
forall a. Fractional a => Add a -> Add a
forall a. Fractional a => Add a -> Add a -> Add a
forall a.
Num a
-> (a -> a -> a) -> (a -> a) -> (Rational -> a) -> Fractional a
fromRational :: Rational -> Add a
$cfromRational :: forall a. Fractional a => Rational -> Add a
recip :: Add a -> Add a
$crecip :: forall a. Fractional a => Add a -> Add a
/ :: Add a -> Add a -> Add a
$c/ :: forall a. Fractional a => Add a -> Add a -> Add a
$cp1Fractional :: forall a. Fractional a => Num (Add a)
Fractional
, a -> Add b -> Add a
(a -> b) -> Add a -> Add b
(forall a b. (a -> b) -> Add a -> Add b)
-> (forall a b. a -> Add b -> Add a) -> Functor Add
forall a b. a -> Add b -> Add a
forall a b. (a -> b) -> Add a -> Add b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Add b -> Add a
$c<$ :: forall a b. a -> Add b -> Add a
fmap :: (a -> b) -> Add a -> Add b
$cfmap :: forall a b. (a -> b) -> Add a -> Add b
Functor
, (forall x. Add a -> Rep (Add a) x)
-> (forall x. Rep (Add a) x -> Add a) -> Generic (Add a)
forall x. Rep (Add a) x -> Add a
forall x. Add a -> Rep (Add a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Add a) x -> Add a
forall a x. Add a -> Rep (Add a) x
$cto :: forall a x. Rep (Add a) x -> Add a
$cfrom :: forall a x. Add a -> Rep (Add a) x
Generic
, (forall a. Add a -> Rep1 Add a)
-> (forall a. Rep1 Add a -> Add a) -> Generic1 Add
forall a. Rep1 Add a -> Add a
forall a. Add a -> Rep1 Add a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cto1 :: forall a. Rep1 Add a -> Add a
$cfrom1 :: forall a. Add a -> Rep1 Add a
Generic1
, Integer -> Add a
Add a -> Add a
Add a -> Add a -> Add a
(Add a -> Add a -> Add a)
-> (Add a -> Add a -> Add a)
-> (Add a -> Add a -> Add a)
-> (Add a -> Add a)
-> (Add a -> Add a)
-> (Add a -> Add a)
-> (Integer -> Add a)
-> Num (Add a)
forall a. Num a => Integer -> Add a
forall a. Num a => Add a -> Add a
forall a. Num a => Add a -> Add a -> Add a
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> Add a
$cfromInteger :: forall a. Num a => Integer -> Add a
signum :: Add a -> Add a
$csignum :: forall a. Num a => Add a -> Add a
abs :: Add a -> Add a
$cabs :: forall a. Num a => Add a -> Add a
negate :: Add a -> Add a
$cnegate :: forall a. Num a => Add a -> Add a
* :: Add a -> Add a -> Add a
$c* :: forall a. Num a => Add a -> Add a -> Add a
- :: Add a -> Add a -> Add a
$c- :: forall a. Num a => Add a -> Add a -> Add a
+ :: Add a -> Add a -> Add a
$c+ :: forall a. Num a => Add a -> Add a -> Add a
Num.Num
, Eq (Add a)
Eq (Add a)
-> (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)
-> (Add a -> Add a -> Add a)
-> (Add a -> Add a -> Add a)
-> Ord (Add a)
Add a -> Add a -> Bool
Add a -> Add a -> Ordering
Add a -> Add a -> Add a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (Add a)
forall a. Ord a => Add a -> Add a -> Bool
forall a. Ord a => Add a -> Add a -> Ordering
forall a. Ord a => Add a -> Add a -> Add a
min :: Add a -> Add a -> Add a
$cmin :: forall a. Ord a => Add a -> Add a -> Add a
max :: Add a -> Add a -> Add a
$cmax :: forall a. Ord a => Add a -> Add a -> Add a
>= :: Add a -> Add a -> Bool
$c>= :: forall a. Ord a => Add a -> Add a -> Bool
> :: Add a -> Add a -> Bool
$c> :: forall a. Ord a => Add a -> Add a -> Bool
<= :: Add a -> Add a -> Bool
$c<= :: forall a. Ord a => Add a -> Add a -> Bool
< :: Add a -> Add a -> Bool
$c< :: forall a. Ord a => Add a -> Add a -> Bool
compare :: Add a -> Add a -> Ordering
$ccompare :: forall a. Ord a => Add a -> Add a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Add a)
Ord
, ReadPrec [Add a]
ReadPrec (Add a)
Int -> ReadS (Add a)
ReadS [Add a]
(Int -> ReadS (Add a))
-> ReadS [Add a]
-> ReadPrec (Add a)
-> ReadPrec [Add a]
-> Read (Add a)
forall a. Read a => ReadPrec [Add a]
forall a. Read a => ReadPrec (Add a)
forall a. Read a => Int -> ReadS (Add a)
forall a. Read a => ReadS [Add a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Add a]
$creadListPrec :: forall a. Read a => ReadPrec [Add a]
readPrec :: ReadPrec (Add a)
$creadPrec :: forall a. Read a => ReadPrec (Add a)
readList :: ReadS [Add a]
$creadList :: forall a. Read a => ReadS [Add a]
readsPrec :: Int -> ReadS (Add a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Add a)
Read
, Num (Add a)
Ord (Add a)
Num (Add a) -> Ord (Add a) -> (Add a -> Rational) -> Real (Add a)
Add a -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
forall a. Real a => Num (Add a)
forall a. Real a => Ord (Add a)
forall a. Real a => Add a -> Rational
toRational :: Add a -> Rational
$ctoRational :: forall a. Real a => Add a -> Rational
$cp2Real :: forall a. Real a => Ord (Add a)
$cp1Real :: forall a. Real a => Num (Add a)
Real
, Fractional (Add a)
Real (Add a)
Real (Add a)
-> Fractional (Add a)
-> (forall b. Integral b => Add a -> (b, Add a))
-> (forall b. Integral b => Add a -> b)
-> (forall b. Integral b => Add a -> b)
-> (forall b. Integral b => Add a -> b)
-> (forall b. Integral b => Add a -> b)
-> RealFrac (Add a)
Add a -> b
Add a -> b
Add a -> b
Add a -> b
Add a -> (b, Add a)
forall b. Integral b => Add a -> b
forall b. Integral b => Add a -> (b, Add a)
forall a.
Real a
-> Fractional a
-> (forall b. Integral b => a -> (b, a))
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> RealFrac a
forall a. RealFrac a => Fractional (Add a)
forall a. RealFrac a => Real (Add a)
forall a b. (RealFrac a, Integral b) => Add a -> b
forall a b. (RealFrac a, Integral b) => Add a -> (b, Add a)
floor :: Add a -> b
$cfloor :: forall a b. (RealFrac a, Integral b) => Add a -> b
ceiling :: Add a -> b
$cceiling :: forall a b. (RealFrac a, Integral b) => Add a -> b
round :: Add a -> b
$cround :: forall a b. (RealFrac a, Integral b) => Add a -> b
truncate :: Add a -> b
$ctruncate :: forall a b. (RealFrac a, Integral b) => Add a -> b
properFraction :: Add a -> (b, Add a)
$cproperFraction :: forall a b. (RealFrac a, Integral b) => Add a -> (b, Add a)
$cp2RealFrac :: forall a. RealFrac a => Fractional (Add a)
$cp1RealFrac :: forall a. RealFrac a => Real (Add a)
RealFrac
, Int -> Add a -> ShowS
[Add a] -> ShowS
Add a -> [Char]
(Int -> Add a -> ShowS)
-> (Add a -> [Char]) -> ([Add a] -> ShowS) -> Show (Add a)
forall a. Show a => Int -> Add a -> ShowS
forall a. Show a => [Add a] -> ShowS
forall a. Show a => Add a -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [Add a] -> ShowS
$cshowList :: forall a. Show a => [Add a] -> ShowS
show :: Add a -> [Char]
$cshow :: forall a. Show a => Add a -> [Char]
showsPrec :: Int -> Add a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Add a -> ShowS
Show
, Ptr b -> Int -> IO (Add a)
Ptr b -> Int -> Add a -> IO ()
Ptr (Add a) -> IO (Add a)
Ptr (Add a) -> Int -> IO (Add a)
Ptr (Add a) -> Int -> Add a -> IO ()
Ptr (Add a) -> Add a -> IO ()
Add a -> Int
(Add a -> Int)
-> (Add a -> Int)
-> (Ptr (Add a) -> Int -> IO (Add a))
-> (Ptr (Add a) -> Int -> Add a -> IO ())
-> (forall b. Ptr b -> Int -> IO (Add a))
-> (forall b. Ptr b -> Int -> Add a -> IO ())
-> (Ptr (Add a) -> IO (Add a))
-> (Ptr (Add a) -> Add a -> IO ())
-> Storable (Add a)
forall b. Ptr b -> Int -> IO (Add a)
forall b. Ptr b -> Int -> Add a -> IO ()
forall a. Storable a => Ptr (Add a) -> IO (Add a)
forall a. Storable a => Ptr (Add a) -> Int -> IO (Add a)
forall a. Storable a => Ptr (Add a) -> Int -> Add a -> IO ()
forall a. Storable a => Ptr (Add a) -> Add a -> IO ()
forall a. Storable a => Add a -> Int
forall a b. Storable a => Ptr b -> Int -> IO (Add a)
forall a b. Storable a => Ptr b -> Int -> Add a -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr (Add a) -> Add a -> IO ()
$cpoke :: forall a. Storable a => Ptr (Add a) -> Add a -> IO ()
peek :: Ptr (Add a) -> IO (Add a)
$cpeek :: forall a. Storable a => Ptr (Add a) -> IO (Add a)
pokeByteOff :: Ptr b -> Int -> Add a -> IO ()
$cpokeByteOff :: forall a b. Storable a => Ptr b -> Int -> Add a -> IO ()
peekByteOff :: Ptr b -> Int -> IO (Add a)
$cpeekByteOff :: forall a b. Storable a => Ptr b -> Int -> IO (Add a)
pokeElemOff :: Ptr (Add a) -> Int -> Add a -> IO ()
$cpokeElemOff :: forall a. Storable a => Ptr (Add a) -> Int -> Add a -> IO ()
peekElemOff :: Ptr (Add a) -> Int -> IO (Add a)
$cpeekElemOff :: forall a. Storable a => Ptr (Add a) -> Int -> IO (Add a)
alignment :: Add a -> Int
$calignment :: forall a. Storable a => Add a -> Int
sizeOf :: Add a -> Int
$csizeOf :: forall a. Storable a => Add a -> Int
Storable
, Functor Add
Foldable Add
Functor Add
-> Foldable Add
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Add a -> f (Add b))
-> (forall (f :: * -> *) a.
Applicative f =>
Add (f a) -> f (Add a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Add a -> m (Add b))
-> (forall (m :: * -> *) a. Monad m => Add (m a) -> m (Add a))
-> Traversable Add
(a -> f b) -> Add a -> f (Add b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Add (m a) -> m (Add a)
forall (f :: * -> *) a. Applicative f => Add (f a) -> f (Add a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Add a -> m (Add b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Add a -> f (Add b)
sequence :: Add (m a) -> m (Add a)
$csequence :: forall (m :: * -> *) a. Monad m => Add (m a) -> m (Add a)
mapM :: (a -> m b) -> Add a -> m (Add b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Add a -> m (Add b)
sequenceA :: Add (f a) -> f (Add a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => Add (f a) -> f (Add a)
traverse :: (a -> f b) -> Add a -> f (Add b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Add a -> f (Add b)
$cp2Traversable :: Foldable Add
$cp1Traversable :: Functor Add
Traversable
, Typeable
)
instance Semiring a => Semigroup (Add a) where
Add a
a <> :: Add a -> Add a -> Add a
<> Add a
b = a -> Add a
forall a. a -> Add a
Add (a
a a -> a -> a
forall a. Semiring a => a -> a -> a
+ a
b)
stimes :: b -> Add a -> Add a
stimes b
n (Add a
a) = a -> Add a
forall a. a -> Add a
Add (Natural -> a
forall a. Semiring a => Natural -> a
fromNatural (b -> Natural
forall a b. (Integral a, Num b) => a -> b
Real.fromIntegral b
n) a -> a -> a
forall a. Semiring a => a -> a -> a
* a
a)
{-# INLINE (<>) #-}
instance Semiring a => Monoid (Add a) where
mempty :: Add a
mempty = a -> Add a
forall a. a -> Add a
Add a
forall a. Semiring a => a
zero
mappend :: Add a -> Add a -> Add a
mappend = Add a -> Add a -> Add a
forall a. Semigroup a => a -> a -> a
(<>)
{-# INLINE mempty #-}
{-# INLINE mappend #-}
newtype Add' a = Add' { Add' a -> a
getAdd' :: a }
instance Semiring a => Semigroup (Add' a) where
Add' a
a <> :: Add' a -> Add' a -> Add' a
<> Add' a
b = a -> Add' a
forall a. a -> Add' a
Add' (a
a a -> a -> a
forall a. Semiring a => a -> a -> a
+ a
b)
newtype Mul a = Mul { Mul a -> a
getMul :: a }
deriving
( Mul a
Mul a -> Mul a -> Bounded (Mul a)
forall a. a -> a -> Bounded a
forall a. Bounded a => Mul a
maxBound :: Mul a
$cmaxBound :: forall a. Bounded a => Mul a
minBound :: Mul a
$cminBound :: forall a. Bounded a => Mul a
Bounded
, Int -> Mul a
Mul a -> Int
Mul a -> [Mul a]
Mul a -> Mul a
Mul a -> Mul a -> [Mul a]
Mul a -> Mul a -> Mul a -> [Mul a]
(Mul a -> Mul a)
-> (Mul a -> Mul a)
-> (Int -> Mul a)
-> (Mul a -> Int)
-> (Mul a -> [Mul a])
-> (Mul a -> Mul a -> [Mul a])
-> (Mul a -> Mul a -> [Mul a])
-> (Mul a -> Mul a -> Mul a -> [Mul a])
-> Enum (Mul a)
forall a. Enum a => Int -> Mul a
forall a. Enum a => Mul a -> Int
forall a. Enum a => Mul a -> [Mul a]
forall a. Enum a => Mul a -> Mul a
forall a. Enum a => Mul a -> Mul a -> [Mul a]
forall a. Enum a => Mul a -> Mul a -> Mul a -> [Mul a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Mul a -> Mul a -> Mul a -> [Mul a]
$cenumFromThenTo :: forall a. Enum a => Mul a -> Mul a -> Mul a -> [Mul a]
enumFromTo :: Mul a -> Mul a -> [Mul a]
$cenumFromTo :: forall a. Enum a => Mul a -> Mul a -> [Mul a]
enumFromThen :: Mul a -> Mul a -> [Mul a]
$cenumFromThen :: forall a. Enum a => Mul a -> Mul a -> [Mul a]
enumFrom :: Mul a -> [Mul a]
$cenumFrom :: forall a. Enum a => Mul a -> [Mul a]
fromEnum :: Mul a -> Int
$cfromEnum :: forall a. Enum a => Mul a -> Int
toEnum :: Int -> Mul a
$ctoEnum :: forall a. Enum a => Int -> Mul a
pred :: Mul a -> Mul a
$cpred :: forall a. Enum a => Mul a -> Mul a
succ :: Mul a -> Mul a
$csucc :: forall a. Enum a => Mul a -> Mul a
Enum
, Mul a -> Mul a -> Bool
(Mul a -> Mul a -> Bool) -> (Mul a -> Mul a -> Bool) -> Eq (Mul a)
forall a. Eq a => Mul a -> Mul a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Mul a -> Mul a -> Bool
$c/= :: forall a. Eq a => Mul a -> Mul a -> Bool
== :: Mul a -> Mul a -> Bool
$c== :: forall a. Eq a => Mul a -> Mul a -> Bool
Eq
, Mul a -> Bool
(a -> m) -> Mul a -> m
(a -> b -> b) -> b -> Mul a -> b
(forall m. Monoid m => Mul m -> m)
-> (forall m a. Monoid m => (a -> m) -> Mul a -> m)
-> (forall m a. Monoid m => (a -> m) -> Mul a -> m)
-> (forall a b. (a -> b -> b) -> b -> Mul a -> b)
-> (forall a b. (a -> b -> b) -> b -> Mul a -> b)
-> (forall b a. (b -> a -> b) -> b -> Mul a -> b)
-> (forall b a. (b -> a -> b) -> b -> Mul a -> b)
-> (forall a. (a -> a -> a) -> Mul a -> a)
-> (forall a. (a -> a -> a) -> Mul a -> a)
-> (forall a. Mul a -> [a])
-> (forall a. Mul a -> Bool)
-> (forall a. Mul a -> Int)
-> (forall a. Eq a => a -> Mul a -> Bool)
-> (forall a. Ord a => Mul a -> a)
-> (forall a. Ord a => Mul a -> a)
-> (forall a. Num a => Mul a -> a)
-> (forall a. Num a => Mul a -> a)
-> Foldable Mul
forall a. Eq a => a -> Mul a -> Bool
forall a. Num a => Mul a -> a
forall a. Ord a => Mul a -> a
forall m. Monoid m => Mul m -> m
forall a. Mul a -> Bool
forall a. Mul a -> Int
forall a. Mul a -> [a]
forall a. (a -> a -> a) -> Mul a -> a
forall m a. Monoid m => (a -> m) -> Mul a -> m
forall b a. (b -> a -> b) -> b -> Mul a -> b
forall a b. (a -> b -> b) -> b -> Mul a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: Mul a -> a
$cproduct :: forall a. Num a => Mul a -> a
sum :: Mul a -> a
$csum :: forall a. Num a => Mul a -> a
minimum :: Mul a -> a
$cminimum :: forall a. Ord a => Mul a -> a
maximum :: Mul a -> a
$cmaximum :: forall a. Ord a => Mul a -> a
elem :: a -> Mul a -> Bool
$celem :: forall a. Eq a => a -> Mul a -> Bool
length :: Mul a -> Int
$clength :: forall a. Mul a -> Int
null :: Mul a -> Bool
$cnull :: forall a. Mul a -> Bool
toList :: Mul a -> [a]
$ctoList :: forall a. Mul a -> [a]
foldl1 :: (a -> a -> a) -> Mul a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Mul a -> a
foldr1 :: (a -> a -> a) -> Mul a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Mul a -> a
foldl' :: (b -> a -> b) -> b -> Mul a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Mul a -> b
foldl :: (b -> a -> b) -> b -> Mul a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Mul a -> b
foldr' :: (a -> b -> b) -> b -> Mul a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Mul a -> b
foldr :: (a -> b -> b) -> b -> Mul a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Mul a -> b
foldMap' :: (a -> m) -> Mul a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Mul a -> m
foldMap :: (a -> m) -> Mul a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Mul a -> m
fold :: Mul m -> m
$cfold :: forall m. Monoid m => Mul m -> m
Foldable
, Num (Mul a)
Num (Mul a)
-> (Mul a -> Mul a -> Mul a)
-> (Mul a -> Mul a)
-> (Rational -> Mul a)
-> Fractional (Mul a)
Rational -> Mul a
Mul a -> Mul a
Mul a -> Mul a -> Mul a
forall a. Fractional a => Num (Mul a)
forall a. Fractional a => Rational -> Mul a
forall a. Fractional a => Mul a -> Mul a
forall a. Fractional a => Mul a -> Mul a -> Mul a
forall a.
Num a
-> (a -> a -> a) -> (a -> a) -> (Rational -> a) -> Fractional a
fromRational :: Rational -> Mul a
$cfromRational :: forall a. Fractional a => Rational -> Mul a
recip :: Mul a -> Mul a
$crecip :: forall a. Fractional a => Mul a -> Mul a
/ :: Mul a -> Mul a -> Mul a
$c/ :: forall a. Fractional a => Mul a -> Mul a -> Mul a
$cp1Fractional :: forall a. Fractional a => Num (Mul a)
Fractional
, a -> Mul b -> Mul a
(a -> b) -> Mul a -> Mul b
(forall a b. (a -> b) -> Mul a -> Mul b)
-> (forall a b. a -> Mul b -> Mul a) -> Functor Mul
forall a b. a -> Mul b -> Mul a
forall a b. (a -> b) -> Mul a -> Mul b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Mul b -> Mul a
$c<$ :: forall a b. a -> Mul b -> Mul a
fmap :: (a -> b) -> Mul a -> Mul b
$cfmap :: forall a b. (a -> b) -> Mul a -> Mul b
Functor
, (forall x. Mul a -> Rep (Mul a) x)
-> (forall x. Rep (Mul a) x -> Mul a) -> Generic (Mul a)
forall x. Rep (Mul a) x -> Mul a
forall x. Mul a -> Rep (Mul a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Mul a) x -> Mul a
forall a x. Mul a -> Rep (Mul a) x
$cto :: forall a x. Rep (Mul a) x -> Mul a
$cfrom :: forall a x. Mul a -> Rep (Mul a) x
Generic
, (forall a. Mul a -> Rep1 Mul a)
-> (forall a. Rep1 Mul a -> Mul a) -> Generic1 Mul
forall a. Rep1 Mul a -> Mul a
forall a. Mul a -> Rep1 Mul a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cto1 :: forall a. Rep1 Mul a -> Mul a
$cfrom1 :: forall a. Mul a -> Rep1 Mul a
Generic1
, Integer -> Mul a
Mul a -> Mul a
Mul a -> Mul a -> Mul a
(Mul a -> Mul a -> Mul a)
-> (Mul a -> Mul a -> Mul a)
-> (Mul a -> Mul a -> Mul a)
-> (Mul a -> Mul a)
-> (Mul a -> Mul a)
-> (Mul a -> Mul a)
-> (Integer -> Mul a)
-> Num (Mul a)
forall a. Num a => Integer -> Mul a
forall a. Num a => Mul a -> Mul a
forall a. Num a => Mul a -> Mul a -> Mul a
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> Mul a
$cfromInteger :: forall a. Num a => Integer -> Mul a
signum :: Mul a -> Mul a
$csignum :: forall a. Num a => Mul a -> Mul a
abs :: Mul a -> Mul a
$cabs :: forall a. Num a => Mul a -> Mul a
negate :: Mul a -> Mul a
$cnegate :: forall a. Num a => Mul a -> Mul a
* :: Mul a -> Mul a -> Mul a
$c* :: forall a. Num a => Mul a -> Mul a -> Mul a
- :: Mul a -> Mul a -> Mul a
$c- :: forall a. Num a => Mul a -> Mul a -> Mul a
+ :: Mul a -> Mul a -> Mul a
$c+ :: forall a. Num a => Mul a -> Mul a -> Mul a
Num.Num
, Eq (Mul a)
Eq (Mul a)
-> (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)
-> (Mul a -> Mul a -> Mul a)
-> (Mul a -> Mul a -> Mul a)
-> Ord (Mul a)
Mul a -> Mul a -> Bool
Mul a -> Mul a -> Ordering
Mul a -> Mul a -> Mul a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (Mul a)
forall a. Ord a => Mul a -> Mul a -> Bool
forall a. Ord a => Mul a -> Mul a -> Ordering
forall a. Ord a => Mul a -> Mul a -> Mul a
min :: Mul a -> Mul a -> Mul a
$cmin :: forall a. Ord a => Mul a -> Mul a -> Mul a
max :: Mul a -> Mul a -> Mul a
$cmax :: forall a. Ord a => Mul a -> Mul a -> Mul a
>= :: Mul a -> Mul a -> Bool
$c>= :: forall a. Ord a => Mul a -> Mul a -> Bool
> :: Mul a -> Mul a -> Bool
$c> :: forall a. Ord a => Mul a -> Mul a -> Bool
<= :: Mul a -> Mul a -> Bool
$c<= :: forall a. Ord a => Mul a -> Mul a -> Bool
< :: Mul a -> Mul a -> Bool
$c< :: forall a. Ord a => Mul a -> Mul a -> Bool
compare :: Mul a -> Mul a -> Ordering
$ccompare :: forall a. Ord a => Mul a -> Mul a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Mul a)
Ord
, ReadPrec [Mul a]
ReadPrec (Mul a)
Int -> ReadS (Mul a)
ReadS [Mul a]
(Int -> ReadS (Mul a))
-> ReadS [Mul a]
-> ReadPrec (Mul a)
-> ReadPrec [Mul a]
-> Read (Mul a)
forall a. Read a => ReadPrec [Mul a]
forall a. Read a => ReadPrec (Mul a)
forall a. Read a => Int -> ReadS (Mul a)
forall a. Read a => ReadS [Mul a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Mul a]
$creadListPrec :: forall a. Read a => ReadPrec [Mul a]
readPrec :: ReadPrec (Mul a)
$creadPrec :: forall a. Read a => ReadPrec (Mul a)
readList :: ReadS [Mul a]
$creadList :: forall a. Read a => ReadS [Mul a]
readsPrec :: Int -> ReadS (Mul a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Mul a)
Read
, Num (Mul a)
Ord (Mul a)
Num (Mul a) -> Ord (Mul a) -> (Mul a -> Rational) -> Real (Mul a)
Mul a -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
forall a. Real a => Num (Mul a)
forall a. Real a => Ord (Mul a)
forall a. Real a => Mul a -> Rational
toRational :: Mul a -> Rational
$ctoRational :: forall a. Real a => Mul a -> Rational
$cp2Real :: forall a. Real a => Ord (Mul a)
$cp1Real :: forall a. Real a => Num (Mul a)
Real
, Fractional (Mul a)
Real (Mul a)
Real (Mul a)
-> Fractional (Mul a)
-> (forall b. Integral b => Mul a -> (b, Mul a))
-> (forall b. Integral b => Mul a -> b)
-> (forall b. Integral b => Mul a -> b)
-> (forall b. Integral b => Mul a -> b)
-> (forall b. Integral b => Mul a -> b)
-> RealFrac (Mul a)
Mul a -> b
Mul a -> b
Mul a -> b
Mul a -> b
Mul a -> (b, Mul a)
forall b. Integral b => Mul a -> b
forall b. Integral b => Mul a -> (b, Mul a)
forall a.
Real a
-> Fractional a
-> (forall b. Integral b => a -> (b, a))
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> RealFrac a
forall a. RealFrac a => Fractional (Mul a)
forall a. RealFrac a => Real (Mul a)
forall a b. (RealFrac a, Integral b) => Mul a -> b
forall a b. (RealFrac a, Integral b) => Mul a -> (b, Mul a)
floor :: Mul a -> b
$cfloor :: forall a b. (RealFrac a, Integral b) => Mul a -> b
ceiling :: Mul a -> b
$cceiling :: forall a b. (RealFrac a, Integral b) => Mul a -> b
round :: Mul a -> b
$cround :: forall a b. (RealFrac a, Integral b) => Mul a -> b
truncate :: Mul a -> b
$ctruncate :: forall a b. (RealFrac a, Integral b) => Mul a -> b
properFraction :: Mul a -> (b, Mul a)
$cproperFraction :: forall a b. (RealFrac a, Integral b) => Mul a -> (b, Mul a)
$cp2RealFrac :: forall a. RealFrac a => Fractional (Mul a)
$cp1RealFrac :: forall a. RealFrac a => Real (Mul a)
RealFrac
, Int -> Mul a -> ShowS
[Mul a] -> ShowS
Mul a -> [Char]
(Int -> Mul a -> ShowS)
-> (Mul a -> [Char]) -> ([Mul a] -> ShowS) -> Show (Mul a)
forall a. Show a => Int -> Mul a -> ShowS
forall a. Show a => [Mul a] -> ShowS
forall a. Show a => Mul a -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [Mul a] -> ShowS
$cshowList :: forall a. Show a => [Mul a] -> ShowS
show :: Mul a -> [Char]
$cshow :: forall a. Show a => Mul a -> [Char]
showsPrec :: Int -> Mul a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Mul a -> ShowS
Show
, Ptr b -> Int -> IO (Mul a)
Ptr b -> Int -> Mul a -> IO ()
Ptr (Mul a) -> IO (Mul a)
Ptr (Mul a) -> Int -> IO (Mul a)
Ptr (Mul a) -> Int -> Mul a -> IO ()
Ptr (Mul a) -> Mul a -> IO ()
Mul a -> Int
(Mul a -> Int)
-> (Mul a -> Int)
-> (Ptr (Mul a) -> Int -> IO (Mul a))
-> (Ptr (Mul a) -> Int -> Mul a -> IO ())
-> (forall b. Ptr b -> Int -> IO (Mul a))
-> (forall b. Ptr b -> Int -> Mul a -> IO ())
-> (Ptr (Mul a) -> IO (Mul a))
-> (Ptr (Mul a) -> Mul a -> IO ())
-> Storable (Mul a)
forall b. Ptr b -> Int -> IO (Mul a)
forall b. Ptr b -> Int -> Mul a -> IO ()
forall a. Storable a => Ptr (Mul a) -> IO (Mul a)
forall a. Storable a => Ptr (Mul a) -> Int -> IO (Mul a)
forall a. Storable a => Ptr (Mul a) -> Int -> Mul a -> IO ()
forall a. Storable a => Ptr (Mul a) -> Mul a -> IO ()
forall a. Storable a => Mul a -> Int
forall a b. Storable a => Ptr b -> Int -> IO (Mul a)
forall a b. Storable a => Ptr b -> Int -> Mul a -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr (Mul a) -> Mul a -> IO ()
$cpoke :: forall a. Storable a => Ptr (Mul a) -> Mul a -> IO ()
peek :: Ptr (Mul a) -> IO (Mul a)
$cpeek :: forall a. Storable a => Ptr (Mul a) -> IO (Mul a)
pokeByteOff :: Ptr b -> Int -> Mul a -> IO ()
$cpokeByteOff :: forall a b. Storable a => Ptr b -> Int -> Mul a -> IO ()
peekByteOff :: Ptr b -> Int -> IO (Mul a)
$cpeekByteOff :: forall a b. Storable a => Ptr b -> Int -> IO (Mul a)
pokeElemOff :: Ptr (Mul a) -> Int -> Mul a -> IO ()
$cpokeElemOff :: forall a. Storable a => Ptr (Mul a) -> Int -> Mul a -> IO ()
peekElemOff :: Ptr (Mul a) -> Int -> IO (Mul a)
$cpeekElemOff :: forall a. Storable a => Ptr (Mul a) -> Int -> IO (Mul a)
alignment :: Mul a -> Int
$calignment :: forall a. Storable a => Mul a -> Int
sizeOf :: Mul a -> Int
$csizeOf :: forall a. Storable a => Mul a -> Int
Storable
, Functor Mul
Foldable Mul
Functor Mul
-> Foldable Mul
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Mul a -> f (Mul b))
-> (forall (f :: * -> *) a.
Applicative f =>
Mul (f a) -> f (Mul a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Mul a -> m (Mul b))
-> (forall (m :: * -> *) a. Monad m => Mul (m a) -> m (Mul a))
-> Traversable Mul
(a -> f b) -> Mul a -> f (Mul b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Mul (m a) -> m (Mul a)
forall (f :: * -> *) a. Applicative f => Mul (f a) -> f (Mul a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Mul a -> m (Mul b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Mul a -> f (Mul b)
sequence :: Mul (m a) -> m (Mul a)
$csequence :: forall (m :: * -> *) a. Monad m => Mul (m a) -> m (Mul a)
mapM :: (a -> m b) -> Mul a -> m (Mul b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Mul a -> m (Mul b)
sequenceA :: Mul (f a) -> f (Mul a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => Mul (f a) -> f (Mul a)
traverse :: (a -> f b) -> Mul a -> f (Mul b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Mul a -> f (Mul b)
$cp2Traversable :: Foldable Mul
$cp1Traversable :: Functor Mul
Traversable
, Typeable
)
instance Semiring a => Semigroup (Mul a) where
Mul a
a <> :: Mul a -> Mul a -> Mul a
<> Mul a
b = a -> Mul a
forall a. a -> Mul a
Mul (a
a a -> a -> a
forall a. Semiring a => a -> a -> a
* a
b)
{-# INLINE (<>) #-}
instance Semiring a => Monoid (Mul a) where
mempty :: Mul a
mempty = a -> Mul a
forall a. a -> Mul a
Mul a
forall a. Semiring a => a
one
mappend :: Mul a -> Mul a -> Mul a
mappend = Mul a -> Mul a -> Mul a
forall a. Semigroup a => a -> a -> a
(<>)
{-# INLINE mempty #-}
{-# INLINE mappend #-}
newtype WrappedNum a = WrapNum { WrappedNum a -> a
unwrapNum :: a }
deriving
( WrappedNum a
WrappedNum a -> WrappedNum a -> Bounded (WrappedNum a)
forall a. a -> a -> Bounded a
forall a. Bounded a => WrappedNum a
maxBound :: WrappedNum a
$cmaxBound :: forall a. Bounded a => WrappedNum a
minBound :: WrappedNum a
$cminBound :: forall a. Bounded a => WrappedNum a
Bounded
, Int -> WrappedNum a
WrappedNum a -> Int
WrappedNum a -> [WrappedNum a]
WrappedNum a -> WrappedNum a
WrappedNum a -> WrappedNum a -> [WrappedNum a]
WrappedNum a -> WrappedNum a -> WrappedNum a -> [WrappedNum a]
(WrappedNum a -> WrappedNum a)
-> (WrappedNum a -> WrappedNum a)
-> (Int -> WrappedNum a)
-> (WrappedNum a -> Int)
-> (WrappedNum a -> [WrappedNum a])
-> (WrappedNum a -> WrappedNum a -> [WrappedNum a])
-> (WrappedNum a -> WrappedNum a -> [WrappedNum a])
-> (WrappedNum a -> WrappedNum a -> WrappedNum a -> [WrappedNum a])
-> Enum (WrappedNum a)
forall a. Enum a => Int -> WrappedNum a
forall a. Enum a => WrappedNum a -> Int
forall a. Enum a => WrappedNum a -> [WrappedNum a]
forall a. Enum a => WrappedNum a -> WrappedNum a
forall a. Enum a => WrappedNum a -> WrappedNum a -> [WrappedNum a]
forall a.
Enum a =>
WrappedNum a -> WrappedNum a -> WrappedNum a -> [WrappedNum a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: WrappedNum a -> WrappedNum a -> WrappedNum a -> [WrappedNum a]
$cenumFromThenTo :: forall a.
Enum a =>
WrappedNum a -> WrappedNum a -> WrappedNum a -> [WrappedNum a]
enumFromTo :: WrappedNum a -> WrappedNum a -> [WrappedNum a]
$cenumFromTo :: forall a. Enum a => WrappedNum a -> WrappedNum a -> [WrappedNum a]
enumFromThen :: WrappedNum a -> WrappedNum a -> [WrappedNum a]
$cenumFromThen :: forall a. Enum a => WrappedNum a -> WrappedNum a -> [WrappedNum a]
enumFrom :: WrappedNum a -> [WrappedNum a]
$cenumFrom :: forall a. Enum a => WrappedNum a -> [WrappedNum a]
fromEnum :: WrappedNum a -> Int
$cfromEnum :: forall a. Enum a => WrappedNum a -> Int
toEnum :: Int -> WrappedNum a
$ctoEnum :: forall a. Enum a => Int -> WrappedNum a
pred :: WrappedNum a -> WrappedNum a
$cpred :: forall a. Enum a => WrappedNum a -> WrappedNum a
succ :: WrappedNum a -> WrappedNum a
$csucc :: forall a. Enum a => WrappedNum a -> WrappedNum a
Enum
, WrappedNum a -> WrappedNum a -> Bool
(WrappedNum a -> WrappedNum a -> Bool)
-> (WrappedNum a -> WrappedNum a -> Bool) -> Eq (WrappedNum a)
forall a. Eq a => WrappedNum a -> WrappedNum a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WrappedNum a -> WrappedNum a -> Bool
$c/= :: forall a. Eq a => WrappedNum a -> WrappedNum a -> Bool
== :: WrappedNum a -> WrappedNum a -> Bool
$c== :: forall a. Eq a => WrappedNum a -> WrappedNum a -> Bool
Eq
, WrappedNum a -> Bool
(a -> m) -> WrappedNum a -> m
(a -> b -> b) -> b -> WrappedNum a -> b
(forall m. Monoid m => WrappedNum m -> m)
-> (forall m a. Monoid m => (a -> m) -> WrappedNum a -> m)
-> (forall m a. Monoid m => (a -> m) -> WrappedNum a -> m)
-> (forall a b. (a -> b -> b) -> b -> WrappedNum a -> b)
-> (forall a b. (a -> b -> b) -> b -> WrappedNum a -> b)
-> (forall b a. (b -> a -> b) -> b -> WrappedNum a -> b)
-> (forall b a. (b -> a -> b) -> b -> WrappedNum a -> b)
-> (forall a. (a -> a -> a) -> WrappedNum a -> a)
-> (forall a. (a -> a -> a) -> WrappedNum a -> a)
-> (forall a. WrappedNum a -> [a])
-> (forall a. WrappedNum a -> Bool)
-> (forall a. WrappedNum a -> Int)
-> (forall a. Eq a => a -> WrappedNum a -> Bool)
-> (forall a. Ord a => WrappedNum a -> a)
-> (forall a. Ord a => WrappedNum a -> a)
-> (forall a. Num a => WrappedNum a -> a)
-> (forall a. Num a => WrappedNum a -> a)
-> Foldable WrappedNum
forall a. Eq a => a -> WrappedNum a -> Bool
forall a. Num a => WrappedNum a -> a
forall a. Ord a => WrappedNum a -> a
forall m. Monoid m => WrappedNum m -> m
forall a. WrappedNum a -> Bool
forall a. WrappedNum a -> Int
forall a. WrappedNum a -> [a]
forall a. (a -> a -> a) -> WrappedNum a -> a
forall m a. Monoid m => (a -> m) -> WrappedNum a -> m
forall b a. (b -> a -> b) -> b -> WrappedNum a -> b
forall a b. (a -> b -> b) -> b -> WrappedNum a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: WrappedNum a -> a
$cproduct :: forall a. Num a => WrappedNum a -> a
sum :: WrappedNum a -> a
$csum :: forall a. Num a => WrappedNum a -> a
minimum :: WrappedNum a -> a
$cminimum :: forall a. Ord a => WrappedNum a -> a
maximum :: WrappedNum a -> a
$cmaximum :: forall a. Ord a => WrappedNum a -> a
elem :: a -> WrappedNum a -> Bool
$celem :: forall a. Eq a => a -> WrappedNum a -> Bool
length :: WrappedNum a -> Int
$clength :: forall a. WrappedNum a -> Int
null :: WrappedNum a -> Bool
$cnull :: forall a. WrappedNum a -> Bool
toList :: WrappedNum a -> [a]
$ctoList :: forall a. WrappedNum a -> [a]
foldl1 :: (a -> a -> a) -> WrappedNum a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> WrappedNum a -> a
foldr1 :: (a -> a -> a) -> WrappedNum a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> WrappedNum a -> a
foldl' :: (b -> a -> b) -> b -> WrappedNum a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> WrappedNum a -> b
foldl :: (b -> a -> b) -> b -> WrappedNum a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> WrappedNum a -> b
foldr' :: (a -> b -> b) -> b -> WrappedNum a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> WrappedNum a -> b
foldr :: (a -> b -> b) -> b -> WrappedNum a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> WrappedNum a -> b
foldMap' :: (a -> m) -> WrappedNum a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> WrappedNum a -> m
foldMap :: (a -> m) -> WrappedNum a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> WrappedNum a -> m
fold :: WrappedNum m -> m
$cfold :: forall m. Monoid m => WrappedNum m -> m
Foldable
, Num (WrappedNum a)
Num (WrappedNum a)
-> (WrappedNum a -> WrappedNum a -> WrappedNum a)
-> (WrappedNum a -> WrappedNum a)
-> (Rational -> WrappedNum a)
-> Fractional (WrappedNum a)
Rational -> WrappedNum a
WrappedNum a -> WrappedNum a
WrappedNum a -> WrappedNum a -> WrappedNum a
forall a. Fractional a => Num (WrappedNum a)
forall a. Fractional a => Rational -> WrappedNum a
forall a. Fractional a => WrappedNum a -> WrappedNum a
forall a.
Fractional a =>
WrappedNum a -> WrappedNum a -> WrappedNum a
forall a.
Num a
-> (a -> a -> a) -> (a -> a) -> (Rational -> a) -> Fractional a
fromRational :: Rational -> WrappedNum a
$cfromRational :: forall a. Fractional a => Rational -> WrappedNum a
recip :: WrappedNum a -> WrappedNum a
$crecip :: forall a. Fractional a => WrappedNum a -> WrappedNum a
/ :: WrappedNum a -> WrappedNum a -> WrappedNum a
$c/ :: forall a.
Fractional a =>
WrappedNum a -> WrappedNum a -> WrappedNum a
$cp1Fractional :: forall a. Fractional a => Num (WrappedNum a)
Fractional
, a -> WrappedNum b -> WrappedNum a
(a -> b) -> WrappedNum a -> WrappedNum b
(forall a b. (a -> b) -> WrappedNum a -> WrappedNum b)
-> (forall a b. a -> WrappedNum b -> WrappedNum a)
-> Functor WrappedNum
forall a b. a -> WrappedNum b -> WrappedNum a
forall a b. (a -> b) -> WrappedNum a -> WrappedNum b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> WrappedNum b -> WrappedNum a
$c<$ :: forall a b. a -> WrappedNum b -> WrappedNum a
fmap :: (a -> b) -> WrappedNum a -> WrappedNum b
$cfmap :: forall a b. (a -> b) -> WrappedNum a -> WrappedNum b
Functor
, (forall x. WrappedNum a -> Rep (WrappedNum a) x)
-> (forall x. Rep (WrappedNum a) x -> WrappedNum a)
-> Generic (WrappedNum a)
forall x. Rep (WrappedNum a) x -> WrappedNum a
forall x. WrappedNum a -> Rep (WrappedNum a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (WrappedNum a) x -> WrappedNum a
forall a x. WrappedNum a -> Rep (WrappedNum a) x
$cto :: forall a x. Rep (WrappedNum a) x -> WrappedNum a
$cfrom :: forall a x. WrappedNum a -> Rep (WrappedNum a) x
Generic
, (forall a. WrappedNum a -> Rep1 WrappedNum a)
-> (forall a. Rep1 WrappedNum a -> WrappedNum a)
-> Generic1 WrappedNum
forall a. Rep1 WrappedNum a -> WrappedNum a
forall a. WrappedNum a -> Rep1 WrappedNum a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cto1 :: forall a. Rep1 WrappedNum a -> WrappedNum a
$cfrom1 :: forall a. WrappedNum a -> Rep1 WrappedNum a
Generic1
, Integer -> WrappedNum a
WrappedNum a -> WrappedNum a
WrappedNum a -> WrappedNum a -> WrappedNum a
(WrappedNum a -> WrappedNum a -> WrappedNum a)
-> (WrappedNum a -> WrappedNum a -> WrappedNum a)
-> (WrappedNum a -> WrappedNum a -> WrappedNum a)
-> (WrappedNum a -> WrappedNum a)
-> (WrappedNum a -> WrappedNum a)
-> (WrappedNum a -> WrappedNum a)
-> (Integer -> WrappedNum a)
-> Num (WrappedNum a)
forall a. Num a => Integer -> WrappedNum a
forall a. Num a => WrappedNum a -> WrappedNum a
forall a. Num a => WrappedNum a -> WrappedNum a -> WrappedNum a
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> WrappedNum a
$cfromInteger :: forall a. Num a => Integer -> WrappedNum a
signum :: WrappedNum a -> WrappedNum a
$csignum :: forall a. Num a => WrappedNum a -> WrappedNum a
abs :: WrappedNum a -> WrappedNum a
$cabs :: forall a. Num a => WrappedNum a -> WrappedNum a
negate :: WrappedNum a -> WrappedNum a
$cnegate :: forall a. Num a => WrappedNum a -> WrappedNum a
* :: WrappedNum a -> WrappedNum a -> WrappedNum a
$c* :: forall a. Num a => WrappedNum a -> WrappedNum a -> WrappedNum a
- :: WrappedNum a -> WrappedNum a -> WrappedNum a
$c- :: forall a. Num a => WrappedNum a -> WrappedNum a -> WrappedNum a
+ :: WrappedNum a -> WrappedNum a -> WrappedNum a
$c+ :: forall a. Num a => WrappedNum a -> WrappedNum a -> WrappedNum a
Num.Num
, Eq (WrappedNum a)
Eq (WrappedNum a)
-> (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)
-> (WrappedNum a -> WrappedNum a -> WrappedNum a)
-> (WrappedNum a -> WrappedNum a -> WrappedNum a)
-> Ord (WrappedNum a)
WrappedNum a -> WrappedNum a -> Bool
WrappedNum a -> WrappedNum a -> Ordering
WrappedNum a -> WrappedNum a -> WrappedNum a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (WrappedNum a)
forall a. Ord a => WrappedNum a -> WrappedNum a -> Bool
forall a. Ord a => WrappedNum a -> WrappedNum a -> Ordering
forall a. Ord a => WrappedNum a -> WrappedNum a -> WrappedNum a
min :: WrappedNum a -> WrappedNum a -> WrappedNum a
$cmin :: forall a. Ord a => WrappedNum a -> WrappedNum a -> WrappedNum a
max :: WrappedNum a -> WrappedNum a -> WrappedNum a
$cmax :: forall a. Ord a => WrappedNum a -> WrappedNum a -> WrappedNum a
>= :: WrappedNum a -> WrappedNum a -> Bool
$c>= :: forall a. Ord a => WrappedNum a -> WrappedNum a -> Bool
> :: WrappedNum a -> WrappedNum a -> Bool
$c> :: forall a. Ord a => WrappedNum a -> WrappedNum a -> Bool
<= :: WrappedNum a -> WrappedNum a -> Bool
$c<= :: forall a. Ord a => WrappedNum a -> WrappedNum a -> Bool
< :: WrappedNum a -> WrappedNum a -> Bool
$c< :: forall a. Ord a => WrappedNum a -> WrappedNum a -> Bool
compare :: WrappedNum a -> WrappedNum a -> Ordering
$ccompare :: forall a. Ord a => WrappedNum a -> WrappedNum a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (WrappedNum a)
Ord
, ReadPrec [WrappedNum a]
ReadPrec (WrappedNum a)
Int -> ReadS (WrappedNum a)
ReadS [WrappedNum a]
(Int -> ReadS (WrappedNum a))
-> ReadS [WrappedNum a]
-> ReadPrec (WrappedNum a)
-> ReadPrec [WrappedNum a]
-> Read (WrappedNum a)
forall a. Read a => ReadPrec [WrappedNum a]
forall a. Read a => ReadPrec (WrappedNum a)
forall a. Read a => Int -> ReadS (WrappedNum a)
forall a. Read a => ReadS [WrappedNum a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WrappedNum a]
$creadListPrec :: forall a. Read a => ReadPrec [WrappedNum a]
readPrec :: ReadPrec (WrappedNum a)
$creadPrec :: forall a. Read a => ReadPrec (WrappedNum a)
readList :: ReadS [WrappedNum a]
$creadList :: forall a. Read a => ReadS [WrappedNum a]
readsPrec :: Int -> ReadS (WrappedNum a)
$creadsPrec :: forall a. Read a => Int -> ReadS (WrappedNum a)
Read
, Num (WrappedNum a)
Ord (WrappedNum a)
Num (WrappedNum a)
-> Ord (WrappedNum a)
-> (WrappedNum a -> Rational)
-> Real (WrappedNum a)
WrappedNum a -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
forall a. Real a => Num (WrappedNum a)
forall a. Real a => Ord (WrappedNum a)
forall a. Real a => WrappedNum a -> Rational
toRational :: WrappedNum a -> Rational
$ctoRational :: forall a. Real a => WrappedNum a -> Rational
$cp2Real :: forall a. Real a => Ord (WrappedNum a)
$cp1Real :: forall a. Real a => Num (WrappedNum a)
Real
, Fractional (WrappedNum a)
Real (WrappedNum a)
Real (WrappedNum a)
-> Fractional (WrappedNum a)
-> (forall b. Integral b => WrappedNum a -> (b, WrappedNum a))
-> (forall b. Integral b => WrappedNum a -> b)
-> (forall b. Integral b => WrappedNum a -> b)
-> (forall b. Integral b => WrappedNum a -> b)
-> (forall b. Integral b => WrappedNum a -> b)
-> RealFrac (WrappedNum a)
WrappedNum a -> b
WrappedNum a -> b
WrappedNum a -> b
WrappedNum a -> b
WrappedNum a -> (b, WrappedNum a)
forall b. Integral b => WrappedNum a -> b
forall b. Integral b => WrappedNum a -> (b, WrappedNum a)
forall a.
Real a
-> Fractional a
-> (forall b. Integral b => a -> (b, a))
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> RealFrac a
forall a. RealFrac a => Fractional (WrappedNum a)
forall a. RealFrac a => Real (WrappedNum a)
forall a b. (RealFrac a, Integral b) => WrappedNum a -> b
forall a b.
(RealFrac a, Integral b) =>
WrappedNum a -> (b, WrappedNum a)
floor :: WrappedNum a -> b
$cfloor :: forall a b. (RealFrac a, Integral b) => WrappedNum a -> b
ceiling :: WrappedNum a -> b
$cceiling :: forall a b. (RealFrac a, Integral b) => WrappedNum a -> b
round :: WrappedNum a -> b
$cround :: forall a b. (RealFrac a, Integral b) => WrappedNum a -> b
truncate :: WrappedNum a -> b
$ctruncate :: forall a b. (RealFrac a, Integral b) => WrappedNum a -> b
properFraction :: WrappedNum a -> (b, WrappedNum a)
$cproperFraction :: forall a b.
(RealFrac a, Integral b) =>
WrappedNum a -> (b, WrappedNum a)
$cp2RealFrac :: forall a. RealFrac a => Fractional (WrappedNum a)
$cp1RealFrac :: forall a. RealFrac a => Real (WrappedNum a)
RealFrac
, Int -> WrappedNum a -> ShowS
[WrappedNum a] -> ShowS
WrappedNum a -> [Char]
(Int -> WrappedNum a -> ShowS)
-> (WrappedNum a -> [Char])
-> ([WrappedNum a] -> ShowS)
-> Show (WrappedNum a)
forall a. Show a => Int -> WrappedNum a -> ShowS
forall a. Show a => [WrappedNum a] -> ShowS
forall a. Show a => WrappedNum a -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [WrappedNum a] -> ShowS
$cshowList :: forall a. Show a => [WrappedNum a] -> ShowS
show :: WrappedNum a -> [Char]
$cshow :: forall a. Show a => WrappedNum a -> [Char]
showsPrec :: Int -> WrappedNum a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> WrappedNum a -> ShowS
Show
, Ptr b -> Int -> IO (WrappedNum a)
Ptr b -> Int -> WrappedNum a -> IO ()
Ptr (WrappedNum a) -> IO (WrappedNum a)
Ptr (WrappedNum a) -> Int -> IO (WrappedNum a)
Ptr (WrappedNum a) -> Int -> WrappedNum a -> IO ()
Ptr (WrappedNum a) -> WrappedNum a -> IO ()
WrappedNum a -> Int
(WrappedNum a -> Int)
-> (WrappedNum a -> Int)
-> (Ptr (WrappedNum a) -> Int -> IO (WrappedNum a))
-> (Ptr (WrappedNum a) -> Int -> WrappedNum a -> IO ())
-> (forall b. Ptr b -> Int -> IO (WrappedNum a))
-> (forall b. Ptr b -> Int -> WrappedNum a -> IO ())
-> (Ptr (WrappedNum a) -> IO (WrappedNum a))
-> (Ptr (WrappedNum a) -> WrappedNum a -> IO ())
-> Storable (WrappedNum a)
forall b. Ptr b -> Int -> IO (WrappedNum a)
forall b. Ptr b -> Int -> WrappedNum a -> IO ()
forall a. Storable a => Ptr (WrappedNum a) -> IO (WrappedNum a)
forall a.
Storable a =>
Ptr (WrappedNum a) -> Int -> IO (WrappedNum a)
forall a.
Storable a =>
Ptr (WrappedNum a) -> Int -> WrappedNum a -> IO ()
forall a. Storable a => Ptr (WrappedNum a) -> WrappedNum a -> IO ()
forall a. Storable a => WrappedNum a -> Int
forall a b. Storable a => Ptr b -> Int -> IO (WrappedNum a)
forall a b. Storable a => Ptr b -> Int -> WrappedNum a -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr (WrappedNum a) -> WrappedNum a -> IO ()
$cpoke :: forall a. Storable a => Ptr (WrappedNum a) -> WrappedNum a -> IO ()
peek :: Ptr (WrappedNum a) -> IO (WrappedNum a)
$cpeek :: forall a. Storable a => Ptr (WrappedNum a) -> IO (WrappedNum a)
pokeByteOff :: Ptr b -> Int -> WrappedNum a -> IO ()
$cpokeByteOff :: forall a b. Storable a => Ptr b -> Int -> WrappedNum a -> IO ()
peekByteOff :: Ptr b -> Int -> IO (WrappedNum a)
$cpeekByteOff :: forall a b. Storable a => Ptr b -> Int -> IO (WrappedNum a)
pokeElemOff :: Ptr (WrappedNum a) -> Int -> WrappedNum a -> IO ()
$cpokeElemOff :: forall a.
Storable a =>
Ptr (WrappedNum a) -> Int -> WrappedNum a -> IO ()
peekElemOff :: Ptr (WrappedNum a) -> Int -> IO (WrappedNum a)
$cpeekElemOff :: forall a.
Storable a =>
Ptr (WrappedNum a) -> Int -> IO (WrappedNum a)
alignment :: WrappedNum a -> Int
$calignment :: forall a. Storable a => WrappedNum a -> Int
sizeOf :: WrappedNum a -> Int
$csizeOf :: forall a. Storable a => WrappedNum a -> Int
Storable
, Functor WrappedNum
Foldable WrappedNum
Functor WrappedNum
-> Foldable WrappedNum
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> WrappedNum a -> f (WrappedNum b))
-> (forall (f :: * -> *) a.
Applicative f =>
WrappedNum (f a) -> f (WrappedNum a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> WrappedNum a -> m (WrappedNum b))
-> (forall (m :: * -> *) a.
Monad m =>
WrappedNum (m a) -> m (WrappedNum a))
-> Traversable WrappedNum
(a -> f b) -> WrappedNum a -> f (WrappedNum b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
WrappedNum (m a) -> m (WrappedNum a)
forall (f :: * -> *) a.
Applicative f =>
WrappedNum (f a) -> f (WrappedNum a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> WrappedNum a -> m (WrappedNum b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> WrappedNum a -> f (WrappedNum b)
sequence :: WrappedNum (m a) -> m (WrappedNum a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
WrappedNum (m a) -> m (WrappedNum a)
mapM :: (a -> m b) -> WrappedNum a -> m (WrappedNum b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> WrappedNum a -> m (WrappedNum b)
sequenceA :: WrappedNum (f a) -> f (WrappedNum a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
WrappedNum (f a) -> f (WrappedNum a)
traverse :: (a -> f b) -> WrappedNum a -> f (WrappedNum b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> WrappedNum a -> f (WrappedNum b)
$cp2Traversable :: Foldable WrappedNum
$cp1Traversable :: Functor WrappedNum
Traversable
, Typeable
, Eq (WrappedNum a)
WrappedNum a
Eq (WrappedNum a)
-> (WrappedNum a -> WrappedNum a -> WrappedNum a)
-> (WrappedNum a -> WrappedNum a -> WrappedNum a)
-> (WrappedNum a -> WrappedNum a -> WrappedNum a)
-> (WrappedNum a -> WrappedNum a)
-> (WrappedNum a -> Int -> WrappedNum a)
-> (WrappedNum a -> Int -> WrappedNum a)
-> WrappedNum a
-> (Int -> WrappedNum a)
-> (WrappedNum a -> Int -> WrappedNum a)
-> (WrappedNum a -> Int -> WrappedNum a)
-> (WrappedNum a -> Int -> WrappedNum a)
-> (WrappedNum a -> Int -> Bool)
-> (WrappedNum a -> Maybe Int)
-> (WrappedNum a -> Int)
-> (WrappedNum a -> Bool)
-> (WrappedNum a -> Int -> WrappedNum a)
-> (WrappedNum a -> Int -> WrappedNum a)
-> (WrappedNum a -> Int -> WrappedNum a)
-> (WrappedNum a -> Int -> WrappedNum a)
-> (WrappedNum a -> Int -> WrappedNum a)
-> (WrappedNum a -> Int -> WrappedNum a)
-> (WrappedNum a -> Int)
-> Bits (WrappedNum a)
Int -> WrappedNum a
WrappedNum a -> Bool
WrappedNum a -> Int
WrappedNum a -> Maybe Int
WrappedNum a -> WrappedNum a
WrappedNum a -> Int -> Bool
WrappedNum a -> Int -> WrappedNum a
WrappedNum a -> WrappedNum a -> WrappedNum a
forall a.
Eq a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
forall a. Bits a => Eq (WrappedNum a)
forall a. Bits a => WrappedNum a
forall a. Bits a => Int -> WrappedNum a
forall a. Bits a => WrappedNum a -> Bool
forall a. Bits a => WrappedNum a -> Int
forall a. Bits a => WrappedNum a -> Maybe Int
forall a. Bits a => WrappedNum a -> WrappedNum a
forall a. Bits a => WrappedNum a -> Int -> Bool
forall a. Bits a => WrappedNum a -> Int -> WrappedNum a
forall a. Bits a => WrappedNum a -> WrappedNum a -> WrappedNum a
popCount :: WrappedNum a -> Int
$cpopCount :: forall a. Bits a => WrappedNum a -> Int
rotateR :: WrappedNum a -> Int -> WrappedNum a
$crotateR :: forall a. Bits a => WrappedNum a -> Int -> WrappedNum a
rotateL :: WrappedNum a -> Int -> WrappedNum a
$crotateL :: forall a. Bits a => WrappedNum a -> Int -> WrappedNum a
unsafeShiftR :: WrappedNum a -> Int -> WrappedNum a
$cunsafeShiftR :: forall a. Bits a => WrappedNum a -> Int -> WrappedNum a
shiftR :: WrappedNum a -> Int -> WrappedNum a
$cshiftR :: forall a. Bits a => WrappedNum a -> Int -> WrappedNum a
unsafeShiftL :: WrappedNum a -> Int -> WrappedNum a
$cunsafeShiftL :: forall a. Bits a => WrappedNum a -> Int -> WrappedNum a
shiftL :: WrappedNum a -> Int -> WrappedNum a
$cshiftL :: forall a. Bits a => WrappedNum a -> Int -> WrappedNum a
isSigned :: WrappedNum a -> Bool
$cisSigned :: forall a. Bits a => WrappedNum a -> Bool
bitSize :: WrappedNum a -> Int
$cbitSize :: forall a. Bits a => WrappedNum a -> Int
bitSizeMaybe :: WrappedNum a -> Maybe Int
$cbitSizeMaybe :: forall a. Bits a => WrappedNum a -> Maybe Int
testBit :: WrappedNum a -> Int -> Bool
$ctestBit :: forall a. Bits a => WrappedNum a -> Int -> Bool
complementBit :: WrappedNum a -> Int -> WrappedNum a
$ccomplementBit :: forall a. Bits a => WrappedNum a -> Int -> WrappedNum a
clearBit :: WrappedNum a -> Int -> WrappedNum a
$cclearBit :: forall a. Bits a => WrappedNum a -> Int -> WrappedNum a
setBit :: WrappedNum a -> Int -> WrappedNum a
$csetBit :: forall a. Bits a => WrappedNum a -> Int -> WrappedNum a
bit :: Int -> WrappedNum a
$cbit :: forall a. Bits a => Int -> WrappedNum a
zeroBits :: WrappedNum a
$czeroBits :: forall a. Bits a => WrappedNum a
rotate :: WrappedNum a -> Int -> WrappedNum a
$crotate :: forall a. Bits a => WrappedNum a -> Int -> WrappedNum a
shift :: WrappedNum a -> Int -> WrappedNum a
$cshift :: forall a. Bits a => WrappedNum a -> Int -> WrappedNum a
complement :: WrappedNum a -> WrappedNum a
$ccomplement :: forall a. Bits a => WrappedNum a -> WrappedNum a
xor :: WrappedNum a -> WrappedNum a -> WrappedNum a
$cxor :: forall a. Bits a => WrappedNum a -> WrappedNum a -> WrappedNum a
.|. :: WrappedNum a -> WrappedNum a -> WrappedNum a
$c.|. :: forall a. Bits a => WrappedNum a -> WrappedNum a -> WrappedNum a
.&. :: WrappedNum a -> WrappedNum a -> WrappedNum a
$c.&. :: forall a. Bits a => WrappedNum a -> WrappedNum a -> WrappedNum a
$cp1Bits :: forall a. Bits a => Eq (WrappedNum a)
Bits
)
instance Num.Num a => Semiring (WrappedNum a) where
plus :: WrappedNum a -> WrappedNum a -> WrappedNum a
plus = WrappedNum a -> WrappedNum a -> WrappedNum a
forall a. Num a => a -> a -> a
(Num.+)
zero :: WrappedNum a
zero = WrappedNum a
0
times :: WrappedNum a -> WrappedNum a -> WrappedNum a
times = WrappedNum a -> WrappedNum a -> WrappedNum a
forall a. Num a => a -> a -> a
(Num.*)
one :: WrappedNum a
one = WrappedNum a
1
fromNatural :: Natural -> WrappedNum a
fromNatural = Natural -> WrappedNum a
forall a b. (Integral a, Num b) => a -> b
Real.fromIntegral
instance Num.Num a => Ring (WrappedNum a) where
negate :: WrappedNum a -> WrappedNum a
negate = WrappedNum a -> WrappedNum a
forall a. Num a => a -> a
Num.negate
newtype Mod2 = Mod2 { Mod2 -> Bool
getMod2 :: Bool }
deriving
( Mod2
Mod2 -> Mod2 -> Bounded Mod2
forall a. a -> a -> Bounded a
maxBound :: Mod2
$cmaxBound :: Mod2
minBound :: Mod2
$cminBound :: Mod2
Bounded
, Int -> Mod2
Mod2 -> Int
Mod2 -> [Mod2]
Mod2 -> Mod2
Mod2 -> Mod2 -> [Mod2]
Mod2 -> Mod2 -> Mod2 -> [Mod2]
(Mod2 -> Mod2)
-> (Mod2 -> Mod2)
-> (Int -> Mod2)
-> (Mod2 -> Int)
-> (Mod2 -> [Mod2])
-> (Mod2 -> Mod2 -> [Mod2])
-> (Mod2 -> Mod2 -> [Mod2])
-> (Mod2 -> Mod2 -> Mod2 -> [Mod2])
-> Enum Mod2
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Mod2 -> Mod2 -> Mod2 -> [Mod2]
$cenumFromThenTo :: Mod2 -> Mod2 -> Mod2 -> [Mod2]
enumFromTo :: Mod2 -> Mod2 -> [Mod2]
$cenumFromTo :: Mod2 -> Mod2 -> [Mod2]
enumFromThen :: Mod2 -> Mod2 -> [Mod2]
$cenumFromThen :: Mod2 -> Mod2 -> [Mod2]
enumFrom :: Mod2 -> [Mod2]
$cenumFrom :: Mod2 -> [Mod2]
fromEnum :: Mod2 -> Int
$cfromEnum :: Mod2 -> Int
toEnum :: Int -> Mod2
$ctoEnum :: Int -> Mod2
pred :: Mod2 -> Mod2
$cpred :: Mod2 -> Mod2
succ :: Mod2 -> Mod2
$csucc :: Mod2 -> Mod2
Enum
, Mod2 -> Mod2 -> Bool
(Mod2 -> Mod2 -> Bool) -> (Mod2 -> Mod2 -> Bool) -> Eq Mod2
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Mod2 -> Mod2 -> Bool
$c/= :: Mod2 -> Mod2 -> Bool
== :: Mod2 -> Mod2 -> Bool
$c== :: Mod2 -> Mod2 -> Bool
Eq
, Eq Mod2
Eq Mod2
-> (Mod2 -> Mod2 -> Ordering)
-> (Mod2 -> Mod2 -> Bool)
-> (Mod2 -> Mod2 -> Bool)
-> (Mod2 -> Mod2 -> Bool)
-> (Mod2 -> Mod2 -> Bool)
-> (Mod2 -> Mod2 -> Mod2)
-> (Mod2 -> Mod2 -> Mod2)
-> Ord Mod2
Mod2 -> Mod2 -> Bool
Mod2 -> Mod2 -> Ordering
Mod2 -> Mod2 -> Mod2
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Mod2 -> Mod2 -> Mod2
$cmin :: Mod2 -> Mod2 -> Mod2
max :: Mod2 -> Mod2 -> Mod2
$cmax :: Mod2 -> Mod2 -> Mod2
>= :: Mod2 -> Mod2 -> Bool
$c>= :: Mod2 -> Mod2 -> Bool
> :: Mod2 -> Mod2 -> Bool
$c> :: Mod2 -> Mod2 -> Bool
<= :: Mod2 -> Mod2 -> Bool
$c<= :: Mod2 -> Mod2 -> Bool
< :: Mod2 -> Mod2 -> Bool
$c< :: Mod2 -> Mod2 -> Bool
compare :: Mod2 -> Mod2 -> Ordering
$ccompare :: Mod2 -> Mod2 -> Ordering
$cp1Ord :: Eq Mod2
Ord
, ReadPrec [Mod2]
ReadPrec Mod2
Int -> ReadS Mod2
ReadS [Mod2]
(Int -> ReadS Mod2)
-> ReadS [Mod2] -> ReadPrec Mod2 -> ReadPrec [Mod2] -> Read Mod2
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Mod2]
$creadListPrec :: ReadPrec [Mod2]
readPrec :: ReadPrec Mod2
$creadPrec :: ReadPrec Mod2
readList :: ReadS [Mod2]
$creadList :: ReadS [Mod2]
readsPrec :: Int -> ReadS Mod2
$creadsPrec :: Int -> ReadS Mod2
Read
, Int -> Mod2 -> ShowS
[Mod2] -> ShowS
Mod2 -> [Char]
(Int -> Mod2 -> ShowS)
-> (Mod2 -> [Char]) -> ([Mod2] -> ShowS) -> Show Mod2
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [Mod2] -> ShowS
$cshowList :: [Mod2] -> ShowS
show :: Mod2 -> [Char]
$cshow :: Mod2 -> [Char]
showsPrec :: Int -> Mod2 -> ShowS
$cshowsPrec :: Int -> Mod2 -> ShowS
Show
, (forall x. Mod2 -> Rep Mod2 x)
-> (forall x. Rep Mod2 x -> Mod2) -> Generic Mod2
forall x. Rep Mod2 x -> Mod2
forall x. Mod2 -> Rep Mod2 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Mod2 x -> Mod2
$cfrom :: forall x. Mod2 -> Rep Mod2 x
Generic
)
instance Semiring Mod2 where
plus :: Mod2 -> Mod2 -> Mod2
plus (Mod2 Bool
x) (Mod2 Bool
y) = Bool -> Mod2
Mod2 (Bool
x Bool -> Bool -> Bool
forall a. Eq a => a -> a -> Bool
/= Bool
y)
times :: Mod2 -> Mod2 -> Mod2
times (Mod2 Bool
x) (Mod2 Bool
y) = Bool -> Mod2
Mod2 (Bool
x Bool -> Bool -> Bool
&& Bool
y)
zero :: Mod2
zero = Bool -> Mod2
Mod2 Bool
False
one :: Mod2
one = Bool -> Mod2
Mod2 Bool
True
instance Ring Mod2 where
negate :: Mod2 -> Mod2
negate = Mod2 -> Mod2
forall a. a -> a
id
{-# INLINE negate #-}
class Semiring a where
#if __GLASGOW_HASKELL__ >= 708
{-# MINIMAL plus, times, (zero, one | fromNatural) #-}
#endif
plus :: a -> a -> a
zero :: a
zero = Natural -> a
forall a. Semiring a => Natural -> a
fromNatural Natural
0
times :: a -> a -> a
one :: a
one = Natural -> a
forall a. Semiring a => Natural -> a
fromNatural Natural
1
fromNatural :: Natural -> a
fromNatural Natural
0 = a
forall a. Semiring a => a
zero
fromNatural Natural
n = Add' a -> a
forall a. Add' a -> a
getAdd' (Natural -> Add' a -> Add' a
forall a b. (Semigroup a, Integral b) => b -> a -> a
stimes Natural
n (a -> Add' a
forall a. a -> Add' a
Add' a
forall a. Semiring a => a
one))
class Semiring a => Ring a where
#if __GLASGOW_HASKELL__ >= 708
{-# MINIMAL negate #-}
#endif
negate :: a -> a
minus :: Ring a => a -> a -> a
minus :: a -> a -> a
minus a
x a
y = a
x a -> a -> a
forall a. Semiring a => a -> a -> a
+ a -> a
forall a. Ring a => a -> a
negate a
y
{-# INLINE minus #-}
fromInteger :: Ring a => Integer -> a
fromInteger :: Integer -> a
fromInteger Integer
x
| Integer
x Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
>= Integer
0 = Natural -> a
forall a. Semiring a => Natural -> a
fromNatural (Integer -> Natural
forall a. Num a => Integer -> a
Num.fromInteger Integer
x)
| Bool
otherwise = a -> a
forall a. Ring a => a -> a
negate (Natural -> a
forall a. Semiring a => Natural -> a
fromNatural (Integer -> Natural
forall a. Num a => Integer -> a
Num.fromInteger (Integer -> Integer
forall a. Num a => a -> a
Num.negate Integer
x)))
{-# INLINE fromInteger #-}
fromIntegral :: (Integral a, Ring b) => a -> b
fromIntegral :: a -> b
fromIntegral a
x
| a
x a -> a -> Bool
forall a. Ord a => a -> a -> Bool
>= a
0 = Natural -> b
forall a. Semiring a => Natural -> a
fromNatural (a -> Natural
forall a b. (Integral a, Num b) => a -> b
Real.fromIntegral a
x)
| Bool
otherwise = b -> b
forall a. Ring a => a -> a
negate (Natural -> b
forall a. Semiring a => Natural -> a
fromNatural (a -> Natural
forall a b. (Integral a, Num b) => a -> b
Real.fromIntegral (a -> a
forall a. Num a => a -> a
Num.negate a
x)))
{-# INLINE fromIntegral #-}
instance Semiring b => Semiring (a -> b) where
plus :: (a -> b) -> (a -> b) -> a -> b
plus a -> b
f a -> b
g = \a
x -> a -> b
f a
x b -> b -> b
forall a. Semiring a => a -> a -> a
`plus` a -> b
g a
x
zero :: a -> b
zero = b -> a -> b
forall a b. a -> b -> a
const b
forall a. Semiring a => a
zero
times :: (a -> b) -> (a -> b) -> a -> b
times a -> b
f a -> b
g = \a
x -> a -> b
f a
x b -> b -> b
forall a. Semiring a => a -> a -> a
`times` a -> b
g a
x
one :: a -> b
one = b -> a -> b
forall a b. a -> b -> a
const b
forall a. Semiring a => a
one
fromNatural :: Natural -> a -> b
fromNatural = b -> a -> b
forall a b. a -> b -> a
const (b -> a -> b) -> (Natural -> b) -> Natural -> a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> b
forall a. Semiring a => Natural -> a
fromNatural
{-# INLINE plus #-}
{-# INLINE zero #-}
{-# INLINE times #-}
{-# INLINE one #-}
{-# INLINE fromNatural #-}
instance Ring b => Ring (a -> b) where
negate :: (a -> b) -> a -> b
negate a -> b
f a
x = b -> b
forall a. Ring a => a -> a
negate (a -> b
f a
x)
{-# INLINE negate #-}
instance Semiring () where
plus :: () -> () -> ()
plus ()
_ ()
_ = ()
zero :: ()
zero = ()
times :: () -> () -> ()
times ()
_ ()
_ = ()
one :: ()
one = ()
fromNatural :: Natural -> ()
fromNatural Natural
_ = ()
{-# INLINE plus #-}
{-# INLINE zero #-}
{-# INLINE times #-}
{-# INLINE one #-}
{-# INLINE fromNatural #-}
instance Ring () where
negate :: () -> ()
negate ()
_ = ()
{-# INLINE negate #-}
instance Semiring (Proxy a) where
plus :: Proxy a -> Proxy a -> Proxy a
plus Proxy a
_ Proxy a
_ = Proxy a
forall k (t :: k). Proxy t
Proxy
zero :: Proxy a
zero = Proxy a
forall k (t :: k). Proxy t
Proxy
times :: Proxy a -> Proxy a -> Proxy a
times Proxy a
_ Proxy a
_ = Proxy a
forall k (t :: k). Proxy t
Proxy
one :: Proxy a
one = Proxy a
forall k (t :: k). Proxy t
Proxy
fromNatural :: Natural -> Proxy a
fromNatural Natural
_ = Proxy a
forall k (t :: k). Proxy t
Proxy
{-# INLINE plus #-}
{-# INLINE zero #-}
{-# INLINE times #-}
{-# INLINE one #-}
{-# INLINE fromNatural #-}
instance Semiring Bool where
plus :: Bool -> Bool -> Bool
plus = Bool -> Bool -> Bool
(||)
zero :: Bool
zero = Bool
False
times :: Bool -> Bool -> Bool
times = Bool -> Bool -> Bool
(&&)
one :: Bool
one = Bool
True
fromNatural :: Natural -> Bool
fromNatural Natural
0 = Bool
False
fromNatural Natural
_ = Bool
True
{-# INLINE plus #-}
{-# INLINE zero #-}
{-# INLINE times #-}
{-# INLINE one #-}
{-# INLINE fromNatural #-}
instance Semiring a => Semiring (Maybe a) where
zero :: Maybe a
zero = Maybe a
forall a. Maybe a
Nothing
one :: Maybe a
one = a -> Maybe a
forall a. a -> Maybe a
Just a
forall a. Semiring a => a
one
plus :: Maybe a -> Maybe a -> Maybe a
plus Maybe a
Nothing Maybe a
y = Maybe a
y
plus Maybe a
x Maybe a
Nothing = Maybe a
x
plus (Just a
x) (Just a
y) = a -> Maybe a
forall a. a -> Maybe a
Just (a -> a -> a
forall a. Semiring a => a -> a -> a
plus a
x a
y)
times :: Maybe a -> Maybe a -> Maybe a
times Maybe a
Nothing Maybe a
_ = Maybe a
forall a. Maybe a
Nothing
times Maybe a
_ Maybe a
Nothing = Maybe a
forall a. Maybe a
Nothing
times (Just a
x) (Just a
y) = a -> Maybe a
forall a. a -> Maybe a
Just (a -> a -> a
forall a. Semiring a => a -> a -> a
times a
x a
y)
fromNatural :: Natural -> Maybe a
fromNatural Natural
0 = Maybe a
forall a. Maybe a
Nothing
fromNatural Natural
n = a -> Maybe a
forall a. a -> Maybe a
Just (Natural -> a
forall a. Semiring a => Natural -> a
fromNatural Natural
n)
{-# INLINE plus #-}
{-# INLINE zero #-}
{-# INLINE times #-}
{-# INLINE one #-}
{-# INLINE fromNatural #-}
instance Semiring a => Semiring (IO a) where
zero :: IO a
zero = a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
forall a. Semiring a => a
zero
one :: IO a
one = a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
forall a. Semiring a => a
one
plus :: IO a -> IO a -> IO a
plus = (a -> a -> a) -> IO a -> IO a -> IO a
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Semiring a => a -> a -> a
plus
times :: IO a -> IO a -> IO a
times = (a -> a -> a) -> IO a -> IO a -> IO a
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Semiring a => a -> a -> a
times
fromNatural :: Natural -> IO a
fromNatural = a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> IO a) -> (Natural -> a) -> Natural -> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> a
forall a. Semiring a => Natural -> a
fromNatural
{-# INLINE plus #-}
{-# INLINE zero #-}
{-# INLINE times #-}
{-# INLINE one #-}
{-# INLINE fromNatural #-}
instance Ring a => Ring (IO a) where
negate :: IO a -> IO a
negate = (a -> a) -> IO a -> IO a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Ring a => a -> a
negate
{-# INLINE negate #-}
instance Semiring a => Semiring (Dual a) where
zero :: Dual a
zero = a -> Dual a
forall a. a -> Dual a
Dual a
forall a. Semiring a => a
zero
Dual a
x plus :: Dual a -> Dual a -> Dual a
`plus` Dual a
y = a -> Dual a
forall a. a -> Dual a
Dual (a
y a -> a -> a
forall a. Semiring a => a -> a -> a
`plus` a
x)
one :: Dual a
one = a -> Dual a
forall a. a -> Dual a
Dual a
forall a. Semiring a => a
one
Dual a
x times :: Dual a -> Dual a -> Dual a
`times` Dual a
y = a -> Dual a
forall a. a -> Dual a
Dual (a
y a -> a -> a
forall a. Semiring a => a -> a -> a
`times` a
x)
fromNatural :: Natural -> Dual a
fromNatural = a -> Dual a
forall a. a -> Dual a
Dual (a -> Dual a) -> (Natural -> a) -> Natural -> Dual a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> a
forall a. Semiring a => Natural -> a
fromNatural
{-# INLINE plus #-}
{-# INLINE zero #-}
{-# INLINE times #-}
{-# INLINE one #-}
{-# INLINE fromNatural #-}
instance Ring a => Ring (Dual a) where
negate :: Dual a -> Dual a
negate (Dual a
x) = a -> Dual a
forall a. a -> Dual a
Dual (a -> a
forall a. Ring a => a -> a
negate a
x)
{-# INLINE negate #-}
instance Semiring a => Semiring (Const a b) where
zero :: Const a b
zero = a -> Const a b
forall k a (b :: k). a -> Const a b
Const a
forall a. Semiring a => a
zero
one :: Const a b
one = a -> Const a b
forall k a (b :: k). a -> Const a b
Const a
forall a. Semiring a => a
one
plus :: Const a b -> Const a b -> Const a b
plus (Const a
x) (Const a
y) = a -> Const a b
forall k a (b :: k). a -> Const a b
Const (a
x a -> a -> a
forall a. Semiring a => a -> a -> a
`plus` a
y)
times :: Const a b -> Const a b -> Const a b
times (Const a
x) (Const a
y) = a -> Const a b
forall k a (b :: k). a -> Const a b
Const (a
x a -> a -> a
forall a. Semiring a => a -> a -> a
`times` a
y)
fromNatural :: Natural -> Const a b
fromNatural = a -> Const a b
forall k a (b :: k). a -> Const a b
Const (a -> Const a b) -> (Natural -> a) -> Natural -> Const a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> a
forall a. Semiring a => Natural -> a
fromNatural
{-# INLINE plus #-}
{-# INLINE zero #-}
{-# INLINE times #-}
{-# INLINE one #-}
{-# INLINE fromNatural #-}
instance Ring a => Ring (Const a b) where
negate :: Const a b -> Const a b
negate (Const a
x) = a -> Const a b
forall k a (b :: k). a -> Const a b
Const (a -> a
forall a. Ring a => a -> a
negate a
x)
{-# INLINE negate #-}
instance Ring a => Semiring (Complex a) where
zero :: Complex a
zero = a
forall a. Semiring a => a
zero a -> a -> Complex a
forall a. a -> a -> Complex a
:+ a
forall a. Semiring a => a
zero
one :: Complex a
one = a
forall a. Semiring a => a
one a -> a -> Complex a
forall a. a -> a -> Complex a
:+ a
forall a. Semiring a => a
zero
plus :: Complex a -> Complex a -> Complex a
plus (a
x :+ a
y) (a
x' :+ a
y') = a -> a -> a
forall a. Semiring a => a -> a -> a
plus a
x a
x' a -> a -> Complex a
forall a. a -> a -> Complex a
:+ a -> a -> a
forall a. Semiring a => a -> a -> a
plus a
y a
y'
times :: Complex a -> Complex a -> Complex a
times (a
x :+ a
y) (a
x' :+ a
y')
= (a
x a -> a -> a
forall a. Semiring a => a -> a -> a
* a
x' a -> a -> a
forall a. Ring a => a -> a -> a
- (a
y a -> a -> a
forall a. Semiring a => a -> a -> a
* a
y')) a -> a -> Complex a
forall a. a -> a -> Complex a
:+ (a
x a -> a -> a
forall a. Semiring a => a -> a -> a
* a
y' a -> a -> a
forall a. Semiring a => a -> a -> a
+ a
y a -> a -> a
forall a. Semiring a => a -> a -> a
* a
x')
fromNatural :: Natural -> Complex a
fromNatural Natural
n = Natural -> a
forall a. Semiring a => Natural -> a
fromNatural Natural
n a -> a -> Complex a
forall a. a -> a -> Complex a
:+ a
forall a. Semiring a => a
zero
{-# INLINE plus #-}
{-# INLINE zero #-}
{-# INLINE times #-}
{-# INLINE one #-}
{-# INLINE fromNatural #-}
instance Ring a => Ring (Complex a) where
negate :: Complex a -> Complex a
negate (a
x :+ a
y) = a -> a
forall a. Ring a => a -> a
negate a
x a -> a -> Complex a
forall a. a -> a -> Complex a
:+ a -> a
forall a. Ring a => a -> a
negate a
y
{-# INLINE negate #-}
#if MIN_VERSION_base(4,12,0)
instance (Semiring a, Applicative f) => Semiring (Ap f a) where
zero :: Ap f a
zero = a -> Ap f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
forall a. Semiring a => a
zero
one :: Ap f a
one = a -> Ap f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
forall a. Semiring a => a
one
plus :: Ap f a -> Ap f a -> Ap f a
plus = (a -> a -> a) -> Ap f a -> Ap f a -> Ap f a
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Semiring a => a -> a -> a
plus
times :: Ap f a -> Ap f a -> Ap f a
times = (a -> a -> a) -> Ap f a -> Ap f a -> Ap f a
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Semiring a => a -> a -> a
times
fromNatural :: Natural -> Ap f a
fromNatural = a -> Ap f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> Ap f a) -> (Natural -> a) -> Natural -> Ap f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> a
forall a. Semiring a => Natural -> a
fromNatural
{-# INLINE plus #-}
{-# INLINE zero #-}
{-# INLINE times #-}
{-# INLINE one #-}
{-# INLINE fromNatural #-}
instance (Ring a, Applicative f) => Ring (Ap f a) where
negate :: Ap f a -> Ap f a
negate = (a -> a) -> Ap f a -> Ap f a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Ring a => a -> a
negate
{-# INLINE negate #-}
#endif
#if MIN_VERSION_base(4,12,0)
deriving instance Semiring (Predicate a)
deriving instance Semiring a => Semiring (Equivalence a)
deriving instance Semiring a => Semiring (Op a b)
deriving instance Ring a => Ring (Op a b)
#endif
instance Integral a => Semiring (Ratio a) where
{-# SPECIALIZE instance Semiring Rational #-}
zero :: Ratio a
zero = a
0 a -> a -> Ratio a
forall a. Integral a => a -> a -> Ratio a
% a
1
one :: Ratio a
one = a
1 a -> a -> Ratio a
forall a. Integral a => a -> a -> Ratio a
% a
1
plus :: Ratio a -> Ratio a -> Ratio a
plus = Ratio a -> Ratio a -> Ratio a
forall a. Num a => a -> a -> a
(Num.+)
times :: Ratio a -> Ratio a -> Ratio a
times = Ratio a -> Ratio a -> Ratio a
forall a. Num a => a -> a -> a
(Num.*)
fromNatural :: Natural -> Ratio a
fromNatural Natural
n = Natural -> a
forall a b. (Integral a, Num b) => a -> b
Real.fromIntegral Natural
n a -> a -> Ratio a
forall a. Integral a => a -> a -> Ratio a
% a
1
{-# INLINE zero #-}
{-# INLINE one #-}
{-# INLINE plus #-}
{-# INLINE times #-}
{-# INLINE fromNatural #-}
deriving instance Semiring a => Semiring (Identity a)
deriving instance Semiring a => Semiring (Down a)
instance HasResolution a => Semiring (Fixed a) where
zero :: Fixed a
zero = Fixed a
0
one :: Fixed a
one = Fixed a
1
plus :: Fixed a -> Fixed a -> Fixed a
plus = Fixed a -> Fixed a -> Fixed a
forall a. Num a => a -> a -> a
(Num.+)
times :: Fixed a -> Fixed a -> Fixed a
times = Fixed a -> Fixed a -> Fixed a
forall a. Num a => a -> a -> a
(Num.*)
fromNatural :: Natural -> Fixed a
fromNatural = Natural -> Fixed a
forall a b. (Integral a, Num b) => a -> b
Real.fromIntegral
{-# INLINE zero #-}
{-# INLINE one #-}
{-# INLINE plus #-}
{-# INLINE times #-}
{-# INLINE fromNatural #-}
instance Integral a => Ring (Ratio a) where
negate :: Ratio a -> Ratio a
negate = Ratio a -> Ratio a
forall a. Num a => a -> a
Num.negate
{-# INLINE negate #-}
deriving instance Ring a => Ring (Down a)
deriving instance Ring a => Ring (Identity a)
instance HasResolution a => Ring (Fixed a) where
negate :: Fixed a -> Fixed a
negate = Fixed a -> Fixed a
forall a. Num a => a -> a
Num.negate
{-# INLINE negate #-}
#if defined(VERSION_containers)
instance (Ord a, Monoid a) => Semiring (Set a) where
zero :: Set a
zero = Set a
forall a. Set a
Set.empty
one :: Set a
one = a -> Set a
forall a. a -> Set a
Set.singleton a
forall a. Monoid a => a
mempty
plus :: Set a -> Set a -> Set a
plus = Set a -> Set a -> Set a
forall a. Ord a => Set a -> Set a -> Set a
Set.union
times :: Set a -> Set a -> Set a
times Set a
xs Set a
ys = (a -> Set a) -> Set a -> Set a
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
Foldable.foldMap (((a -> a) -> Set a -> Set a) -> Set a -> (a -> a) -> Set a
forall a b c. (a -> b -> c) -> b -> a -> c
flip (a -> a) -> Set a -> Set a
forall b a. Ord b => (a -> b) -> Set a -> Set b
Set.map Set a
ys ((a -> a) -> Set a) -> (a -> a -> a) -> a -> Set a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a -> a
forall a. Monoid a => a -> a -> a
mappend) Set a
xs
fromNatural :: Natural -> Set a
fromNatural Natural
0 = Set a
forall a. Semiring a => a
zero
fromNatural Natural
_ = Set a
forall a. Semiring a => a
one
{-# INLINE plus #-}
{-# INLINE zero #-}
{-# INLINE times #-}
{-# INLINE one #-}
{-# INLINE fromNatural #-}
newtype IntSetOf a = IntSetOf { IntSetOf a -> IntSet
getIntSet :: IntSet }
deriving
( IntSetOf a -> IntSetOf a -> Bool
(IntSetOf a -> IntSetOf a -> Bool)
-> (IntSetOf a -> IntSetOf a -> Bool) -> Eq (IntSetOf a)
forall a. IntSetOf a -> IntSetOf a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IntSetOf a -> IntSetOf a -> Bool
$c/= :: forall a. IntSetOf a -> IntSetOf a -> Bool
== :: IntSetOf a -> IntSetOf a -> Bool
$c== :: forall a. IntSetOf a -> IntSetOf a -> Bool
Eq
, (forall x. IntSetOf a -> Rep (IntSetOf a) x)
-> (forall x. Rep (IntSetOf a) x -> IntSetOf a)
-> Generic (IntSetOf a)
forall x. Rep (IntSetOf a) x -> IntSetOf a
forall x. IntSetOf a -> Rep (IntSetOf a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (IntSetOf a) x -> IntSetOf a
forall a x. IntSetOf a -> Rep (IntSetOf a) x
$cto :: forall a x. Rep (IntSetOf a) x -> IntSetOf a
$cfrom :: forall a x. IntSetOf a -> Rep (IntSetOf a) x
Generic
, (forall a. IntSetOf a -> Rep1 IntSetOf a)
-> (forall a. Rep1 IntSetOf a -> IntSetOf a) -> Generic1 IntSetOf
forall a. Rep1 IntSetOf a -> IntSetOf a
forall a. IntSetOf a -> Rep1 IntSetOf a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cto1 :: forall a. Rep1 IntSetOf a -> IntSetOf a
$cfrom1 :: forall a. IntSetOf a -> Rep1 IntSetOf a
Generic1
, Eq (IntSetOf a)
Eq (IntSetOf a)
-> (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)
-> (IntSetOf a -> IntSetOf a -> IntSetOf a)
-> (IntSetOf a -> IntSetOf a -> IntSetOf a)
-> Ord (IntSetOf a)
IntSetOf a -> IntSetOf a -> Bool
IntSetOf a -> IntSetOf a -> Ordering
IntSetOf a -> IntSetOf a -> IntSetOf a
forall a. Eq (IntSetOf a)
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. IntSetOf a -> IntSetOf a -> Bool
forall a. IntSetOf a -> IntSetOf a -> Ordering
forall a. IntSetOf a -> IntSetOf a -> IntSetOf a
min :: IntSetOf a -> IntSetOf a -> IntSetOf a
$cmin :: forall a. IntSetOf a -> IntSetOf a -> IntSetOf a
max :: IntSetOf a -> IntSetOf a -> IntSetOf a
$cmax :: forall a. IntSetOf a -> IntSetOf a -> IntSetOf a
>= :: IntSetOf a -> IntSetOf a -> Bool
$c>= :: forall a. IntSetOf a -> IntSetOf a -> Bool
> :: IntSetOf a -> IntSetOf a -> Bool
$c> :: forall a. IntSetOf a -> IntSetOf a -> Bool
<= :: IntSetOf a -> IntSetOf a -> Bool
$c<= :: forall a. IntSetOf a -> IntSetOf a -> Bool
< :: IntSetOf a -> IntSetOf a -> Bool
$c< :: forall a. IntSetOf a -> IntSetOf a -> Bool
compare :: IntSetOf a -> IntSetOf a -> Ordering
$ccompare :: forall a. IntSetOf a -> IntSetOf a -> Ordering
$cp1Ord :: forall a. Eq (IntSetOf a)
Ord
, ReadPrec [IntSetOf a]
ReadPrec (IntSetOf a)
Int -> ReadS (IntSetOf a)
ReadS [IntSetOf a]
(Int -> ReadS (IntSetOf a))
-> ReadS [IntSetOf a]
-> ReadPrec (IntSetOf a)
-> ReadPrec [IntSetOf a]
-> Read (IntSetOf a)
forall a. ReadPrec [IntSetOf a]
forall a. ReadPrec (IntSetOf a)
forall a. Int -> ReadS (IntSetOf a)
forall a. ReadS [IntSetOf a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IntSetOf a]
$creadListPrec :: forall a. ReadPrec [IntSetOf a]
readPrec :: ReadPrec (IntSetOf a)
$creadPrec :: forall a. ReadPrec (IntSetOf a)
readList :: ReadS [IntSetOf a]
$creadList :: forall a. ReadS [IntSetOf a]
readsPrec :: Int -> ReadS (IntSetOf a)
$creadsPrec :: forall a. Int -> ReadS (IntSetOf a)
Read
, Int -> IntSetOf a -> ShowS
[IntSetOf a] -> ShowS
IntSetOf a -> [Char]
(Int -> IntSetOf a -> ShowS)
-> (IntSetOf a -> [Char])
-> ([IntSetOf a] -> ShowS)
-> Show (IntSetOf a)
forall a. Int -> IntSetOf a -> ShowS
forall a. [IntSetOf a] -> ShowS
forall a. IntSetOf a -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [IntSetOf a] -> ShowS
$cshowList :: forall a. [IntSetOf a] -> ShowS
show :: IntSetOf a -> [Char]
$cshow :: forall a. IntSetOf a -> [Char]
showsPrec :: Int -> IntSetOf a -> ShowS
$cshowsPrec :: forall a. Int -> IntSetOf a -> ShowS
Show
, Typeable
, b -> IntSetOf a -> IntSetOf a
NonEmpty (IntSetOf a) -> IntSetOf a
IntSetOf a -> IntSetOf a -> IntSetOf a
(IntSetOf a -> IntSetOf a -> IntSetOf a)
-> (NonEmpty (IntSetOf a) -> IntSetOf a)
-> (forall b. Integral b => b -> IntSetOf a -> IntSetOf a)
-> Semigroup (IntSetOf a)
forall b. Integral b => b -> IntSetOf a -> IntSetOf a
forall a. NonEmpty (IntSetOf a) -> IntSetOf a
forall a. IntSetOf a -> IntSetOf a -> IntSetOf a
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
forall a b. Integral b => b -> IntSetOf a -> IntSetOf a
stimes :: b -> IntSetOf a -> IntSetOf a
$cstimes :: forall a b. Integral b => b -> IntSetOf a -> IntSetOf a
sconcat :: NonEmpty (IntSetOf a) -> IntSetOf a
$csconcat :: forall a. NonEmpty (IntSetOf a) -> IntSetOf a
<> :: IntSetOf a -> IntSetOf a -> IntSetOf a
$c<> :: forall a. IntSetOf a -> IntSetOf a -> IntSetOf a
Semigroup
, Semigroup (IntSetOf a)
IntSetOf a
Semigroup (IntSetOf a)
-> IntSetOf a
-> (IntSetOf a -> IntSetOf a -> IntSetOf a)
-> ([IntSetOf a] -> IntSetOf a)
-> Monoid (IntSetOf a)
[IntSetOf a] -> IntSetOf a
IntSetOf a -> IntSetOf a -> IntSetOf a
forall a. Semigroup (IntSetOf a)
forall a. IntSetOf a
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
forall a. [IntSetOf a] -> IntSetOf a
forall a. IntSetOf a -> IntSetOf a -> IntSetOf a
mconcat :: [IntSetOf a] -> IntSetOf a
$cmconcat :: forall a. [IntSetOf a] -> IntSetOf a
mappend :: IntSetOf a -> IntSetOf a -> IntSetOf a
$cmappend :: forall a. IntSetOf a -> IntSetOf a -> IntSetOf a
mempty :: IntSetOf a
$cmempty :: forall a. IntSetOf a
$cp1Monoid :: forall a. Semigroup (IntSetOf a)
Monoid
)
instance (Coercible Int a, Monoid a) => Semiring (IntSetOf a) where
zero :: IntSetOf a
zero = IntSet -> IntSetOf a
coerce IntSet
IntSet.empty
one :: IntSetOf a
one = (Int -> IntSet) -> a -> IntSetOf a
coerce Int -> IntSet
IntSet.singleton (a
forall a. Monoid a => a
mempty :: a)
plus :: IntSetOf a -> IntSetOf a -> IntSetOf a
plus = (IntSet -> IntSet -> IntSet)
-> IntSetOf a -> IntSetOf a -> IntSetOf a
coerce IntSet -> IntSet -> IntSet
IntSet.union
IntSetOf a
xs times :: IntSetOf a -> IntSetOf a -> IntSetOf a
`times` IntSetOf a
ys
= ([Int] -> IntSet) -> [a] -> IntSetOf a
coerce [Int] -> IntSet
IntSet.fromList
[ a -> a -> a
forall a. Monoid a => a -> a -> a
mappend a
k a
l
| a
k :: a <- (IntSet -> [Int]) -> IntSetOf a -> [a]
coerce IntSet -> [Int]
IntSet.toList IntSetOf a
xs
, a
l :: a <- (IntSet -> [Int]) -> IntSetOf a -> [a]
coerce IntSet -> [Int]
IntSet.toList IntSetOf a
ys
]
fromNatural :: Natural -> IntSetOf a
fromNatural Natural
0 = IntSetOf a
forall a. Semiring a => a
zero
fromNatural Natural
_ = IntSetOf a
forall a. Semiring a => a
one
{-# INLINE plus #-}
{-# INLINE zero #-}
{-# INLINE times #-}
{-# INLINE one #-}
{-# INLINE fromNatural #-}
instance (Ord k, Monoid k, Semiring v) => Semiring (Map k v) where
zero :: Map k v
zero = Map k v
forall k a. Map k a
Map.empty
one :: Map k v
one = k -> v -> Map k v
forall k a. k -> a -> Map k a
Map.singleton k
forall a. Monoid a => a
mempty v
forall a. Semiring a => a
one
plus :: Map k v -> Map k v -> Map k v
plus = (v -> v -> v) -> Map k v -> Map k v -> Map k v
forall k a. Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a
Map.unionWith v -> v -> v
forall a. Semiring a => a -> a -> a
(+)
Map k v
xs times :: Map k v -> Map k v -> Map k v
`times` Map k v
ys
= (v -> v -> v) -> [(k, v)] -> Map k v
forall k a. Ord k => (a -> a -> a) -> [(k, a)] -> Map k a
Map.fromListWith v -> v -> v
forall a. Semiring a => a -> a -> a
(+)
[ (k -> k -> k
forall a. Monoid a => a -> a -> a
mappend k
k k
l, v
v v -> v -> v
forall a. Semiring a => a -> a -> a
* v
u)
| (k
k,v
v) <- Map k v -> [(k, v)]
forall k a. Map k a -> [(k, a)]
Map.toList Map k v
xs
, (k
l,v
u) <- Map k v -> [(k, v)]
forall k a. Map k a -> [(k, a)]
Map.toList Map k v
ys
]
fromNatural :: Natural -> Map k v
fromNatural Natural
0 = Map k v
forall a. Semiring a => a
zero
fromNatural Natural
n = k -> v -> Map k v
forall k a. k -> a -> Map k a
Map.singleton k
forall a. Monoid a => a
mempty (Natural -> v
forall a. Semiring a => Natural -> a
fromNatural Natural
n)
{-# INLINE plus #-}
{-# INLINE zero #-}
{-# INLINE times #-}
{-# INLINE one #-}
{-# INLINE fromNatural #-}
newtype IntMapOf k v = IntMapOf { IntMapOf k v -> IntMap v
getIntMap :: IntMap v }
deriving
( IntMapOf k v -> IntMapOf k v -> Bool
(IntMapOf k v -> IntMapOf k v -> Bool)
-> (IntMapOf k v -> IntMapOf k v -> Bool) -> Eq (IntMapOf k v)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k v. Eq v => IntMapOf k v -> IntMapOf k v -> Bool
/= :: IntMapOf k v -> IntMapOf k v -> Bool
$c/= :: forall k v. Eq v => IntMapOf k v -> IntMapOf k v -> Bool
== :: IntMapOf k v -> IntMapOf k v -> Bool
$c== :: forall k v. Eq v => IntMapOf k v -> IntMapOf k v -> Bool
Eq
, (forall x. IntMapOf k v -> Rep (IntMapOf k v) x)
-> (forall x. Rep (IntMapOf k v) x -> IntMapOf k v)
-> Generic (IntMapOf k v)
forall x. Rep (IntMapOf k v) x -> IntMapOf k v
forall x. IntMapOf k v -> Rep (IntMapOf k v) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall k v x. Rep (IntMapOf k v) x -> IntMapOf k v
forall k v x. IntMapOf k v -> Rep (IntMapOf k v) x
$cto :: forall k v x. Rep (IntMapOf k v) x -> IntMapOf k v
$cfrom :: forall k v x. IntMapOf k v -> Rep (IntMapOf k v) x
Generic
, (forall a. IntMapOf k a -> Rep1 (IntMapOf k) a)
-> (forall a. Rep1 (IntMapOf k) a -> IntMapOf k a)
-> Generic1 (IntMapOf k)
forall a. Rep1 (IntMapOf k) a -> IntMapOf k a
forall a. IntMapOf k a -> Rep1 (IntMapOf k) a
forall k a. Rep1 (IntMapOf k) a -> IntMapOf k a
forall k a. IntMapOf k a -> Rep1 (IntMapOf k) a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cto1 :: forall k a. Rep1 (IntMapOf k) a -> IntMapOf k a
$cfrom1 :: forall k a. IntMapOf k a -> Rep1 (IntMapOf k) a
Generic1
, Eq (IntMapOf k v)
Eq (IntMapOf k v)
-> (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)
-> (IntMapOf k v -> IntMapOf k v -> IntMapOf k v)
-> (IntMapOf k v -> IntMapOf k v -> IntMapOf k v)
-> Ord (IntMapOf k v)
IntMapOf k v -> IntMapOf k v -> Bool
IntMapOf k v -> IntMapOf k v -> Ordering
IntMapOf k v -> IntMapOf k v -> IntMapOf k v
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall k v. Ord v => Eq (IntMapOf k v)
forall k v. Ord v => IntMapOf k v -> IntMapOf k v -> Bool
forall k v. Ord v => IntMapOf k v -> IntMapOf k v -> Ordering
forall k v. Ord v => IntMapOf k v -> IntMapOf k v -> IntMapOf k v
min :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v
$cmin :: forall k v. Ord v => IntMapOf k v -> IntMapOf k v -> IntMapOf k v
max :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v
$cmax :: forall k v. Ord v => IntMapOf k v -> IntMapOf k v -> IntMapOf k v
>= :: IntMapOf k v -> IntMapOf k v -> Bool
$c>= :: forall k v. Ord v => IntMapOf k v -> IntMapOf k v -> Bool
> :: IntMapOf k v -> IntMapOf k v -> Bool
$c> :: forall k v. Ord v => IntMapOf k v -> IntMapOf k v -> Bool
<= :: IntMapOf k v -> IntMapOf k v -> Bool
$c<= :: forall k v. Ord v => IntMapOf k v -> IntMapOf k v -> Bool
< :: IntMapOf k v -> IntMapOf k v -> Bool
$c< :: forall k v. Ord v => IntMapOf k v -> IntMapOf k v -> Bool
compare :: IntMapOf k v -> IntMapOf k v -> Ordering
$ccompare :: forall k v. Ord v => IntMapOf k v -> IntMapOf k v -> Ordering
$cp1Ord :: forall k v. Ord v => Eq (IntMapOf k v)
Ord
, ReadPrec [IntMapOf k v]
ReadPrec (IntMapOf k v)
Int -> ReadS (IntMapOf k v)
ReadS [IntMapOf k v]
(Int -> ReadS (IntMapOf k v))
-> ReadS [IntMapOf k v]
-> ReadPrec (IntMapOf k v)
-> ReadPrec [IntMapOf k v]
-> Read (IntMapOf k v)
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall k v. Read v => ReadPrec [IntMapOf k v]
forall k v. Read v => ReadPrec (IntMapOf k v)
forall k v. Read v => Int -> ReadS (IntMapOf k v)
forall k v. Read v => ReadS [IntMapOf k v]
readListPrec :: ReadPrec [IntMapOf k v]
$creadListPrec :: forall k v. Read v => ReadPrec [IntMapOf k v]
readPrec :: ReadPrec (IntMapOf k v)
$creadPrec :: forall k v. Read v => ReadPrec (IntMapOf k v)
readList :: ReadS [IntMapOf k v]
$creadList :: forall k v. Read v => ReadS [IntMapOf k v]
readsPrec :: Int -> ReadS (IntMapOf k v)
$creadsPrec :: forall k v. Read v => Int -> ReadS (IntMapOf k v)
Read
, Int -> IntMapOf k v -> ShowS
[IntMapOf k v] -> ShowS
IntMapOf k v -> [Char]
(Int -> IntMapOf k v -> ShowS)
-> (IntMapOf k v -> [Char])
-> ([IntMapOf k v] -> ShowS)
-> Show (IntMapOf k v)
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
forall k v. Show v => Int -> IntMapOf k v -> ShowS
forall k v. Show v => [IntMapOf k v] -> ShowS
forall k v. Show v => IntMapOf k v -> [Char]
showList :: [IntMapOf k v] -> ShowS
$cshowList :: forall k v. Show v => [IntMapOf k v] -> ShowS
show :: IntMapOf k v -> [Char]
$cshow :: forall k v. Show v => IntMapOf k v -> [Char]
showsPrec :: Int -> IntMapOf k v -> ShowS
$cshowsPrec :: forall k v. Show v => Int -> IntMapOf k v -> ShowS
Show
, Typeable
, b -> IntMapOf k v -> IntMapOf k v
NonEmpty (IntMapOf k v) -> IntMapOf k v
IntMapOf k v -> IntMapOf k v -> IntMapOf k v
(IntMapOf k v -> IntMapOf k v -> IntMapOf k v)
-> (NonEmpty (IntMapOf k v) -> IntMapOf k v)
-> (forall b. Integral b => b -> IntMapOf k v -> IntMapOf k v)
-> Semigroup (IntMapOf k v)
forall b. Integral b => b -> IntMapOf k v -> IntMapOf k v
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
forall k v. NonEmpty (IntMapOf k v) -> IntMapOf k v
forall k v. IntMapOf k v -> IntMapOf k v -> IntMapOf k v
forall k v b. Integral b => b -> IntMapOf k v -> IntMapOf k v
stimes :: b -> IntMapOf k v -> IntMapOf k v
$cstimes :: forall k v b. Integral b => b -> IntMapOf k v -> IntMapOf k v
sconcat :: NonEmpty (IntMapOf k v) -> IntMapOf k v
$csconcat :: forall k v. NonEmpty (IntMapOf k v) -> IntMapOf k v
<> :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v
$c<> :: forall k v. IntMapOf k v -> IntMapOf k v -> IntMapOf k v
Semigroup
, Semigroup (IntMapOf k v)
IntMapOf k v
Semigroup (IntMapOf k v)
-> IntMapOf k v
-> (IntMapOf k v -> IntMapOf k v -> IntMapOf k v)
-> ([IntMapOf k v] -> IntMapOf k v)
-> Monoid (IntMapOf k v)
[IntMapOf k v] -> IntMapOf k v
IntMapOf k v -> IntMapOf k v -> IntMapOf k v
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
forall k v. Semigroup (IntMapOf k v)
forall k v. IntMapOf k v
forall k v. [IntMapOf k v] -> IntMapOf k v
forall k v. IntMapOf k v -> IntMapOf k v -> IntMapOf k v
mconcat :: [IntMapOf k v] -> IntMapOf k v
$cmconcat :: forall k v. [IntMapOf k v] -> IntMapOf k v
mappend :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v
$cmappend :: forall k v. IntMapOf k v -> IntMapOf k v -> IntMapOf k v
mempty :: IntMapOf k v
$cmempty :: forall k v. IntMapOf k v
$cp1Monoid :: forall k v. Semigroup (IntMapOf k v)
Monoid
)
instance (Coercible Int k, Monoid k, Semiring v) => Semiring (IntMapOf k v) where
zero :: IntMapOf k v
zero = IntMap v -> IntMapOf k v
coerce (IntMap v
forall a. IntMap a
IntMap.empty :: IntMap v)
one :: IntMapOf k v
one = (Int -> v -> IntMap v) -> k -> v -> IntMapOf k v
coerce (Int -> v -> IntMap v
forall a. Int -> a -> IntMap a
IntMap.singleton :: Int -> v -> IntMap v) (k
forall a. Monoid a => a
mempty :: k) (v
forall a. Semiring a => a
one :: v)
plus :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v
plus = (IntMap v -> IntMap v -> IntMap v)
-> IntMapOf k v -> IntMapOf k v -> IntMapOf k v
coerce ((v -> v -> v) -> IntMap v -> IntMap v -> IntMap v
forall a. (a -> a -> a) -> IntMap a -> IntMap a -> IntMap a
IntMap.unionWith v -> v -> v
forall a. Semiring a => a -> a -> a
(+) :: IntMap v -> IntMap v -> IntMap v)
IntMapOf k v
xs times :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v
`times` IntMapOf k v
ys
= ([(Int, v)] -> IntMap v) -> [(k, v)] -> IntMapOf k v
coerce ((v -> v -> v) -> [(Int, v)] -> IntMap v
forall a. (a -> a -> a) -> [(Int, a)] -> IntMap a
IntMap.fromListWith v -> v -> v
forall a. Semiring a => a -> a -> a
(+) :: [(Int, v)] -> IntMap v)
[ (k -> k -> k
forall a. Monoid a => a -> a -> a
mappend k
k k
l, v
v v -> v -> v
forall a. Semiring a => a -> a -> a
* v
u)
| (k
k :: k, v
v :: v) <- (IntMap v -> [(Int, v)]) -> IntMapOf k v -> [(k, v)]
coerce (IntMap v -> [(Int, v)]
forall a. IntMap a -> [(Int, a)]
IntMap.toList :: IntMap v -> [(Int, v)]) IntMapOf k v
xs
, (k
l :: k, v
u :: v) <- (IntMap v -> [(Int, v)]) -> IntMapOf k v -> [(k, v)]
coerce (IntMap v -> [(Int, v)]
forall a. IntMap a -> [(Int, a)]
IntMap.toList :: IntMap v -> [(Int, v)]) IntMapOf k v
ys
]
fromNatural :: Natural -> IntMapOf k v
fromNatural Natural
0 = IntMapOf k v
forall a. Semiring a => a
zero
fromNatural Natural
n = (Int -> v -> IntMap v) -> k -> v -> IntMapOf k v
coerce (Int -> v -> IntMap v
forall a. Int -> a -> IntMap a
IntMap.singleton :: Int -> v -> IntMap v) (k
forall a. Monoid a => a
mempty :: k) (Natural -> v
forall a. Semiring a => Natural -> a
fromNatural Natural
n :: v)
{-# INLINE plus #-}
{-# INLINE zero #-}
{-# INLINE times #-}
{-# INLINE one #-}
{-# INLINE fromNatural #-}
#endif
#if defined(VERSION_unordered_containers)
instance (Eq a, Hashable a, Monoid a) => Semiring (HashSet a) where
zero :: HashSet a
zero = HashSet a
forall a. HashSet a
HashSet.empty
one :: HashSet a
one = a -> HashSet a
forall a. Hashable a => a -> HashSet a
HashSet.singleton a
forall a. Monoid a => a
mempty
plus :: HashSet a -> HashSet a -> HashSet a
plus = HashSet a -> HashSet a -> HashSet a
forall a. (Eq a, Hashable a) => HashSet a -> HashSet a -> HashSet a
HashSet.union
times :: HashSet a -> HashSet a -> HashSet a
times HashSet a
xs HashSet a
ys = (a -> HashSet a) -> HashSet a -> HashSet a
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
Foldable.foldMap (((a -> a) -> HashSet a -> HashSet a)
-> HashSet a -> (a -> a) -> HashSet a
forall a b c. (a -> b -> c) -> b -> a -> c
flip (a -> a) -> HashSet a -> HashSet a
forall b a.
(Hashable b, Eq b) =>
(a -> b) -> HashSet a -> HashSet b
HashSet.map HashSet a
ys ((a -> a) -> HashSet a) -> (a -> a -> a) -> a -> HashSet a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a -> a
forall a. Monoid a => a -> a -> a
mappend) HashSet a
xs
fromNatural :: Natural -> HashSet a
fromNatural Natural
0 = HashSet a
forall a. Semiring a => a
zero
fromNatural Natural
_ = HashSet a
forall a. Semiring a => a
one
{-# INLINE plus #-}
{-# INLINE zero #-}
{-# INLINE times #-}
{-# INLINE one #-}
{-# INLINE fromNatural #-}
instance (Eq k, Hashable k, Monoid k, Semiring v) => Semiring (HashMap k v) where
zero :: HashMap k v
zero = HashMap k v
forall k v. HashMap k v
HashMap.empty
one :: HashMap k v
one = k -> v -> HashMap k v
forall k v. Hashable k => k -> v -> HashMap k v
HashMap.singleton k
forall a. Monoid a => a
mempty v
forall a. Semiring a => a
one
plus :: HashMap k v -> HashMap k v -> HashMap k v
plus = (v -> v -> v) -> HashMap k v -> HashMap k v -> HashMap k v
forall k v.
(Eq k, Hashable k) =>
(v -> v -> v) -> HashMap k v -> HashMap k v -> HashMap k v
HashMap.unionWith v -> v -> v
forall a. Semiring a => a -> a -> a
(+)
HashMap k v
xs times :: HashMap k v -> HashMap k v -> HashMap k v
`times` HashMap k v
ys
= (v -> v -> v) -> [(k, v)] -> HashMap k v
forall k v.
(Eq k, Hashable k) =>
(v -> v -> v) -> [(k, v)] -> HashMap k v
HashMap.fromListWith v -> v -> v
forall a. Semiring a => a -> a -> a
(+)
[ (k -> k -> k
forall a. Monoid a => a -> a -> a
mappend k
k k
l, v
v v -> v -> v
forall a. Semiring a => a -> a -> a
* v
u)
| (k
k,v
v) <- HashMap k v -> [(k, v)]
forall k v. HashMap k v -> [(k, v)]
HashMap.toList HashMap k v
xs
, (k
l,v
u) <- HashMap k v -> [(k, v)]
forall k v. HashMap k v -> [(k, v)]
HashMap.toList HashMap k v
ys
]
fromNatural :: Natural -> HashMap k v
fromNatural Natural
0 = HashMap k v
forall a. Semiring a => a
zero
fromNatural Natural
n = k -> v -> HashMap k v
forall k v. Hashable k => k -> v -> HashMap k v
HashMap.singleton k
forall a. Monoid a => a
mempty (Natural -> v
forall a. Semiring a => Natural -> a
fromNatural Natural
n)
{-# INLINE plus #-}
{-# INLINE zero #-}
{-# INLINE times #-}
{-# INLINE one #-}
{-# INLINE fromNatural #-}
#endif
isZero :: (Eq a, Semiring a) => a -> Bool
isZero :: a -> Bool
isZero a
x = a
x a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
forall a. Semiring a => a
zero
{-# INLINEABLE isZero #-}
isOne :: (Eq a, Semiring a) => a -> Bool
isOne :: a -> Bool
isOne a
x = a
x a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
forall a. Semiring a => a
one
{-# INLINEABLE isOne #-}
#if MIN_VERSION_base(4,12,0)
deriving via (WrappedNum Int) instance Semiring Int
deriving via (WrappedNum Int8) instance Semiring Int8
deriving via (WrappedNum Int16) instance Semiring Int16
deriving via (WrappedNum Int32) instance Semiring Int32
deriving via (WrappedNum Int64) instance Semiring Int64
deriving via (WrappedNum Integer) instance Semiring Integer
deriving via (WrappedNum Word) instance Semiring Word
deriving via (WrappedNum Word8) instance Semiring Word8
deriving via (WrappedNum Word16) instance Semiring Word16
deriving via (WrappedNum Word32) instance Semiring Word32
deriving via (WrappedNum Word64) instance Semiring Word64
deriving via (WrappedNum Float) instance Semiring Float
deriving via (WrappedNum Double) instance Semiring Double
deriving via (WrappedNum CUIntMax) instance Semiring CUIntMax
deriving via (WrappedNum CIntMax) instance Semiring CIntMax
deriving via (WrappedNum CUIntPtr) instance Semiring CUIntPtr
deriving via (WrappedNum CIntPtr) instance Semiring CIntPtr
deriving via (WrappedNum CSUSeconds) instance Semiring CSUSeconds
deriving via (WrappedNum CUSeconds) instance Semiring CUSeconds
deriving via (WrappedNum CTime) instance Semiring CTime
deriving via (WrappedNum CClock) instance Semiring CClock
deriving via (WrappedNum CSigAtomic) instance Semiring CSigAtomic
deriving via (WrappedNum CWchar) instance Semiring CWchar
deriving via (WrappedNum CSize) instance Semiring CSize
deriving via (WrappedNum CPtrdiff) instance Semiring CPtrdiff
deriving via (WrappedNum CDouble) instance Semiring CDouble
deriving via (WrappedNum CFloat) instance Semiring CFloat
deriving via (WrappedNum CULLong) instance Semiring CULLong
deriving via (WrappedNum CLLong) instance Semiring CLLong
deriving via (WrappedNum CULong) instance Semiring CULong
deriving via (WrappedNum CLong) instance Semiring CLong
deriving via (WrappedNum CUInt) instance Semiring CUInt
deriving via (WrappedNum CInt) instance Semiring CInt
deriving via (WrappedNum CUShort) instance Semiring CUShort
deriving via (WrappedNum CShort) instance Semiring CShort
deriving via (WrappedNum CUChar) instance Semiring CUChar
deriving via (WrappedNum CSChar) instance Semiring CSChar
deriving via (WrappedNum CChar) instance Semiring CChar
deriving via (WrappedNum IntPtr) instance Semiring IntPtr
deriving via (WrappedNum WordPtr) instance Semiring WordPtr
#if !HOST_OS_WINDOWS
deriving via (WrappedNum CCc) instance Semiring CCc
deriving via (WrappedNum CDev) instance Semiring CDev
deriving via (WrappedNum CGid) instance Semiring CGid
deriving via (WrappedNum CIno) instance Semiring CIno
deriving via (WrappedNum CMode) instance Semiring CMode
deriving via (WrappedNum CNlink) instance Semiring CNlink
deriving via (WrappedNum COff) instance Semiring COff
deriving via (WrappedNum CPid) instance Semiring CPid
deriving via (WrappedNum CRLim) instance Semiring CRLim
deriving via (WrappedNum CSpeed) instance Semiring CSpeed
deriving via (WrappedNum CSsize) instance Semiring CSsize
deriving via (WrappedNum CTcflag) instance Semiring CTcflag
deriving via (WrappedNum CUid) instance Semiring CUid
deriving via (WrappedNum Fd) instance Semiring Fd
#endif
deriving via (WrappedNum Natural) instance Semiring Natural
#else
$(let
deriveSemiring :: Q Type -> Q [Dec]
deriveSemiring ty = [d|
instance Semiring $ty where
zero = 0
one = 1
plus x y = (Num.+) x y
times x y = (Num.*) x y
fromNatural = Real.fromIntegral
{-# INLINE zero #-}
{-# INLINE one #-}
{-# INLINE plus #-}
{-# INLINE times #-}
{-# INLINE fromNatural #-}
|]
in P.concat P.<$> P.traverse deriveSemiring
[[t|Int|]
,[t|Int8|]
,[t|Int16|]
,[t|Int32|]
,[t|Int64|]
,[t|Integer|]
,[t|Word|]
,[t|Word8|]
,[t|Word16|]
,[t|Word32|]
,[t|Word64|]
,[t|Float|]
,[t|Double|]
,[t|CUIntMax|]
,[t|CIntMax|]
,[t|CUIntPtr|]
,[t|CIntPtr|]
,[t|CSUSeconds|]
,[t|CUSeconds|]
,[t|CTime|]
,[t|CClock|]
,[t|CSigAtomic|]
,[t|CWchar|]
,[t|CSize|]
,[t|CPtrdiff|]
,[t|CDouble|]
,[t|CFloat|]
,[t|CULLong|]
,[t|CLLong|]
,[t|CULong|]
,[t|CLong|]
,[t|CUInt|]
,[t|CInt|]
,[t|CUShort|]
,[t|CShort|]
,[t|CUChar|]
,[t|CSChar|]
,[t|CChar|]
,[t|IntPtr|]
,[t|WordPtr|]
#if !HOST_OS_WINDOWS
,[t|CCc|]
,[t|CDev|]
,[t|CGid|]
,[t|CIno|]
,[t|CMode|]
,[t|CNlink|]
,[t|COff|]
,[t|CPid|]
,[t|CRLim|]
,[t|CSpeed|]
,[t|CSsize|]
,[t|CTcflag|]
,[t|CUid|]
,[t|Fd|]
#endif
,[t|Natural|]
])
#endif
#if MIN_VERSION_base(4,12,0)
deriving via (WrappedNum Int) instance Ring Int
deriving via (WrappedNum Int8) instance Ring Int8
deriving via (WrappedNum Int16) instance Ring Int16
deriving via (WrappedNum Int32) instance Ring Int32
deriving via (WrappedNum Int64) instance Ring Int64
deriving via (WrappedNum Integer) instance Ring Integer
deriving via (WrappedNum Word) instance Ring Word
deriving via (WrappedNum Word8) instance Ring Word8
deriving via (WrappedNum Word16) instance Ring Word16
deriving via (WrappedNum Word32) instance Ring Word32
deriving via (WrappedNum Word64) instance Ring Word64
deriving via (WrappedNum Float) instance Ring Float
deriving via (WrappedNum Double) instance Ring Double
deriving via (WrappedNum CUIntMax) instance Ring CUIntMax
deriving via (WrappedNum CIntMax) instance Ring CIntMax
deriving via (WrappedNum CUIntPtr) instance Ring CUIntPtr
deriving via (WrappedNum CIntPtr) instance Ring CIntPtr
deriving via (WrappedNum CSUSeconds) instance Ring CSUSeconds
deriving via (WrappedNum CUSeconds) instance Ring CUSeconds
deriving via (WrappedNum CTime) instance Ring CTime
deriving via (WrappedNum CClock) instance Ring CClock
deriving via (WrappedNum CSigAtomic) instance Ring CSigAtomic
deriving via (WrappedNum CWchar) instance Ring CWchar
deriving via (WrappedNum CSize) instance Ring CSize
deriving via (WrappedNum CPtrdiff) instance Ring CPtrdiff
deriving via (WrappedNum CDouble) instance Ring CDouble
deriving via (WrappedNum CFloat) instance Ring CFloat
deriving via (WrappedNum CULLong) instance Ring CULLong
deriving via (WrappedNum CLLong) instance Ring CLLong
deriving via (WrappedNum CULong) instance Ring CULong
deriving via (WrappedNum CLong) instance Ring CLong
deriving via (WrappedNum CUInt) instance Ring CUInt
deriving via (WrappedNum CInt) instance Ring CInt
deriving via (WrappedNum CUShort) instance Ring CUShort
deriving via (WrappedNum CShort) instance Ring CShort
deriving via (WrappedNum CUChar) instance Ring CUChar
deriving via (WrappedNum CSChar) instance Ring CSChar
deriving via (WrappedNum CChar) instance Ring CChar
deriving via (WrappedNum IntPtr) instance Ring IntPtr
deriving via (WrappedNum WordPtr) instance Ring WordPtr
#if !HOST_OS_WINDOWS
deriving via (WrappedNum CCc) instance Ring CCc
deriving via (WrappedNum CDev) instance Ring CDev
deriving via (WrappedNum CGid) instance Ring CGid
deriving via (WrappedNum CIno) instance Ring CIno
deriving via (WrappedNum CMode) instance Ring CMode
deriving via (WrappedNum CNlink) instance Ring CNlink
deriving via (WrappedNum COff) instance Ring COff
deriving via (WrappedNum CPid) instance Ring CPid
deriving via (WrappedNum CRLim) instance Ring CRLim
deriving via (WrappedNum CSpeed) instance Ring CSpeed
deriving via (WrappedNum CSsize) instance Ring CSsize
deriving via (WrappedNum CTcflag) instance Ring CTcflag
deriving via (WrappedNum CUid) instance Ring CUid
deriving via (WrappedNum Fd) instance Ring Fd
#endif
#else
$(let
deriveRing :: Q Type -> Q [Dec]
deriveRing ty = [d|
instance Ring $ty where
negate = Num.negate
{-# INLINE negate #-}
|]
in P.concat P.<$> P.traverse deriveRing
[[t|Int|]
,[t|Int8|]
,[t|Int16|]
,[t|Int32|]
,[t|Int64|]
,[t|Integer|]
,[t|Word|]
,[t|Word8|]
,[t|Word16|]
,[t|Word32|]
,[t|Word64|]
,[t|Float|]
,[t|Double|]
,[t|CUIntMax|]
,[t|CIntMax|]
,[t|CUIntPtr|]
,[t|CIntPtr|]
,[t|CSUSeconds|]
,[t|CUSeconds|]
,[t|CTime|]
,[t|CClock|]
,[t|CSigAtomic|]
,[t|CWchar|]
,[t|CSize|]
,[t|CPtrdiff|]
,[t|CDouble|]
,[t|CFloat|]
,[t|CULLong|]
,[t|CLLong|]
,[t|CULong|]
,[t|CLong|]
,[t|CUInt|]
,[t|CInt|]
,[t|CUShort|]
,[t|CShort|]
,[t|CUChar|]
,[t|CSChar|]
,[t|CChar|]
,[t|IntPtr|]
,[t|WordPtr|]
#if !HOST_OS_WINDOWS
,[t|CCc|]
,[t|CDev|]
,[t|CGid|]
,[t|CIno|]
,[t|CMode|]
,[t|CNlink|]
,[t|COff|]
,[t|CPid|]
,[t|CRLim|]
,[t|CSpeed|]
,[t|CSsize|]
,[t|CTcflag|]
,[t|CUid|]
,[t|Fd|]
#endif
])
#endif