| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Commutative
- class Commutative a where
- commute :: a -> a -> a
- (<~>) :: Commutative a => a -> a -> a
- class Commutative a => CommutativeId a where
- cempty :: a
- 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 Source
Methods
Instances
| Commutative () Source | |
| Commutative All Source | |
| Commutative Any Source | |
| Num a => Commutative (Sum a) Source | |
| Num a => Commutative (Product a) Source | |
| Commutative (OneOf a) Source | |
| Commutative (CommEndo a) Source |
(<~>) :: Commutative a => a -> a -> a Source
class Commutative a => CommutativeId a where Source
Instances
| CommutativeId () Source | |
| CommutativeId All Source | |
| CommutativeId Any Source | |
| Num a => CommutativeId (Sum a) Source | |
| Num a => CommutativeId (Product a) Source | |
| CommutativeId (OneOf a) Source | |
| CommutativeId (CommEndo a) Source |
commuteVia :: Bool -> (a -> a -> a) -> a -> a -> a Source
flip when False - simple & pure "predicative" commute.
commuteViaF :: Functor f => f Bool -> (a -> a -> a) -> a -> a -> f a Source
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) Source | |
| Commutative (CommEndo a) Source |
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.