commutative-0.0.1.4: Commutative binary operations.

Safe HaskellNone
LanguageHaskell2010

Data.Commutative

Synopsis

Documentation

class Commutative a where #

Minimal complete definition

commute

Methods

commute :: a -> a -> a #

Instances

Commutative () # 

Methods

commute :: () -> () -> () #

Commutative All # 

Methods

commute :: All -> All -> All #

Commutative Any # 

Methods

commute :: Any -> Any -> Any #

Num a => Commutative (Sum a) # 

Methods

commute :: Sum a -> Sum a -> Sum a #

Num a => Commutative (Product a) # 

Methods

commute :: Product a -> Product a -> Product a #

Commutative (OneOf a) # 

Methods

commute :: OneOf a -> OneOf a -> OneOf a #

Commutative (CommEndo a) # 

Methods

commute :: CommEndo a -> CommEndo a -> CommEndo a #

(<~>) :: Commutative a => a -> a -> a #

class Commutative a => CommutativeId a where #

Minimal complete definition

cempty

Methods

cempty :: a #

Instances

CommutativeId () # 

Methods

cempty :: () #

CommutativeId All # 

Methods

cempty :: All #

CommutativeId Any # 

Methods

cempty :: Any #

Num a => CommutativeId (Sum a) # 

Methods

cempty :: Sum a #

Num a => CommutativeId (Product a) # 

Methods

cempty :: Product a #

CommutativeId (OneOf a) # 

Methods

cempty :: OneOf a #

CommutativeId (CommEndo a) # 

Methods

cempty :: 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.

newtype CommEndo a #

Endomorphisms commutative over composition. Warning: The Commutative instance uses unsafePerformIO to randomly pick the order.

Constructors

CommEndo 

Fields

Instances

newtype OneOf 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.

Constructors

OneOf 

Fields

Instances

Eq a => Eq (OneOf a) # 

Methods

(==) :: OneOf a -> OneOf a -> Bool #

(/=) :: OneOf a -> OneOf a -> Bool #

Show a => Show (OneOf a) # 

Methods

showsPrec :: Int -> OneOf a -> ShowS #

show :: OneOf a -> String #

showList :: [OneOf a] -> ShowS #

CommutativeId (OneOf a) # 

Methods

cempty :: OneOf a #

Commutative (OneOf a) # 

Methods

commute :: OneOf a -> OneOf a -> OneOf a #

pick1 :: a -> a -> a #