-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Commutative binary operations.
--
-- This package provides a trivial class for abelian binary operations,
-- and an analogue to Data.Foldable.
@package commutative
@version 0.0.1.2
module Data.Commutative
class Commutative a
commute :: Commutative a => a -> a -> a
(<~>) :: Commutative a => a -> a -> a
class Commutative a => CommutativeId a
cempty :: CommutativeId a => a
-- | flip when False - simple & pure "predicative"
-- commute.
commuteVia :: Bool -> (a -> a -> a) -> a -> a -> a
-- | Lifted predicative behaviour.
commuteViaF :: Functor f => f Bool -> (a -> a -> a) -> a -> a -> f a
-- | Endomorphisms commutative over composition. Warning: The
-- Commutative instance uses unsafePerformIO to
-- randomly pick the order.
newtype CommEndo a
CommEndo :: (a -> a) -> CommEndo a
[appCommEndo] :: CommEndo a -> a -> 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.
newtype OneOf a
OneOf :: Maybe a -> OneOf a
[getOneOf] :: OneOf a -> Maybe a
pick1 :: a -> a -> a
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Commutative.OneOf a)
instance GHC.Show.Show a => GHC.Show.Show (Data.Commutative.OneOf a)
instance Data.Commutative.Commutative ()
instance Data.Commutative.CommutativeId ()
instance Data.Commutative.Commutative (Data.Commutative.CommEndo a)
instance Data.Commutative.CommutativeId (Data.Commutative.CommEndo a)
instance Data.Commutative.Commutative Data.Monoid.Any
instance Data.Commutative.CommutativeId Data.Monoid.Any
instance Data.Commutative.Commutative Data.Monoid.All
instance Data.Commutative.CommutativeId Data.Monoid.All
instance Data.Commutative.Commutative (Data.Commutative.OneOf a)
instance Data.Commutative.CommutativeId (Data.Commutative.OneOf a)
instance GHC.Num.Num a => Data.Commutative.Commutative (Data.Monoid.Sum a)
instance GHC.Num.Num a => Data.Commutative.CommutativeId (Data.Monoid.Sum a)
instance GHC.Num.Num a => Data.Commutative.Commutative (Data.Monoid.Product a)
instance GHC.Num.Num a => Data.Commutative.CommutativeId (Data.Monoid.Product a)
module Data.Mergeable
class Mergeable t where mergeMap f = merge (commute . f) cempty merge f i xs = appCommEndo (mergeMap (CommEndo . f) xs) i
mergeMap :: (Mergeable t, CommutativeId m) => (a -> m) -> t a -> m
merge :: Mergeable t => (a -> b -> b) -> b -> t a -> b
class Functor t => Mergeable1 t where mergeMap1 f = merge1 . fmap f merge1 = mergeMap1 id
mergeMap1 :: (Mergeable1 t, Commutative m) => (a -> m) -> t a -> m
merge1 :: (Mergeable1 t, Commutative m) => t m -> m
instance Data.Mergeable.Mergeable []
instance Data.Mergeable.Mergeable1 Data.List.NonEmpty.NonEmpty