Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data.Commutative
- class Commutative a where
- (<~>) :: Commutative a => a -> a -> a
- class Commutative a => CommutativeId a where
- commuteVia :: Bool -> (a -> a -> a) -> a -> a -> a
- commuteViaF :: Functor f => f Bool -> (a -> a -> a) -> a -> a -> f a
- newtype CommEndo a = CommEndo {
- appCommEndo :: a -> a
- newtype OneOf a = OneOf {}
- pick1 :: a -> a -> a
Documentation
class Commutative a where #
Minimal complete definition
Instances
Commutative () # | |
Commutative All # | |
Commutative Any # | |
Num a => Commutative (Sum a) # | |
Num a => Commutative (Product a) # | |
Commutative (OneOf a) # | |
Commutative (CommEndo a) # | |
(<~>) :: Commutative a => a -> a -> a #
class Commutative a => CommutativeId a where #
Minimal complete definition
Instances
CommutativeId () # | |
CommutativeId All # | |
CommutativeId Any # | |
Num a => CommutativeId (Sum a) # | |
Num a => CommutativeId (Product a) # | |
CommutativeId (OneOf a) # | |
CommutativeId (CommEndo a) # | |
commuteVia :: Bool -> (a -> a -> a) -> a -> a -> a #
flip
when False
- simple & pure "predicative" commute.
commuteViaF :: Functor f => f Bool -> (a -> a -> a) -> a -> a -> f a #
Lifted predicative behaviour.
Endomorphisms commutative over composition.
Warning: The Commutative
instance uses unsafePerformIO
to randomly pick the order.
Constructors
CommEndo | |
Fields
|
Instances
CommutativeId (CommEndo a) # | |
Commutative (CommEndo a) # | |
In the case of two Just
values, the commutative instance randomly chooses one of them.
Warning: The Commutative
instance uses unsafePerformIO
to randomly pick the order.