difference-monoid-0.1.0.0

Data.Monoid.Diff.Internal

Synopsis

# Documentation

data Diff a Source #

The Difference Monoid.

Constructors

 !a :-: !a infixl 6

Instances

 Source # Methods(>>=) :: Diff a -> (a -> Diff b) -> Diff b #(>>) :: Diff a -> Diff b -> Diff b #return :: a -> Diff a #fail :: String -> Diff a # Source # Methodsfmap :: (a -> b) -> Diff a -> Diff b #(<$) :: a -> Diff b -> Diff a # Source # Methodsmfix :: (a -> Diff a) -> Diff a # Source # Methodspure :: a -> Diff a #(<*>) :: Diff (a -> b) -> Diff a -> Diff b #liftA2 :: (a -> b -> c) -> Diff a -> Diff b -> Diff c #(*>) :: Diff a -> Diff b -> Diff b #(<*) :: Diff a -> Diff b -> Diff a # Source # Methodsfold :: Monoid m => Diff m -> m #foldMap :: Monoid m => (a -> m) -> Diff a -> m #foldr :: (a -> b -> b) -> b -> Diff a -> b #foldr' :: (a -> b -> b) -> b -> Diff a -> b #foldl :: (b -> a -> b) -> b -> Diff a -> b #foldl' :: (b -> a -> b) -> b -> Diff a -> b #foldr1 :: (a -> a -> a) -> Diff a -> a #foldl1 :: (a -> a -> a) -> Diff a -> a #toList :: Diff a -> [a] #null :: Diff a -> Bool #length :: Diff a -> Int #elem :: Eq a => a -> Diff a -> Bool #maximum :: Ord a => Diff a -> a #minimum :: Ord a => Diff a -> a #sum :: Num a => Diff a -> a #product :: Num a => Diff a -> a # Source # Methodstraverse :: Applicative f => (a -> f b) -> Diff a -> f (Diff b) #sequenceA :: Applicative f => Diff (f a) -> f (Diff a) #mapM :: Monad m => (a -> m b) -> Diff a -> m (Diff b) #sequence :: Monad m => Diff (m a) -> m (Diff a) # Source # Methodsdistribute :: Functor f => f (Diff a) -> Diff (f a) #collect :: Functor f => (a -> Diff b) -> f a -> Diff (f b) #distributeM :: Monad m => m (Diff a) -> Diff (m a) #collectM :: Monad m => (a -> Diff b) -> m a -> Diff (m b) # Source # Associated Typestype Rep (Diff :: * -> *) :: * # Methodstabulate :: (Rep Diff -> a) -> Diff a #index :: Diff a -> Rep Diff -> a # Source # MethodsliftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Diff a) #liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Diff a] #liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Diff a) #liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Diff a] # Source # MethodsliftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Diff a -> ShowS #liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Diff a] -> ShowS # Source # Methodsmzip :: Diff a -> Diff b -> Diff (a, b) #mzipWith :: (a -> b -> c) -> Diff a -> Diff b -> Diff c #munzip :: Diff (a, b) -> (Diff a, Diff b) # Source # Methodsextract :: Diff a -> a #duplicate :: Diff a -> Diff (Diff a) #extend :: (Diff a -> b) -> Diff a -> Diff b # Source # Methods(<@>) :: Diff (a -> b) -> Diff a -> Diff b #(@>) :: Diff a -> Diff b -> Diff b #(<@) :: Diff a -> Diff b -> Diff a # Source # Methodstraverse1 :: Apply f => (a -> f b) -> Diff a -> f (Diff b) #sequence1 :: Apply f => Diff (f b) -> f (Diff b) # Source # Methodsfold1 :: Semigroup m => Diff m -> m #foldMap1 :: Semigroup m => (a -> m) -> Diff a -> m #toNonEmpty :: Diff a -> NonEmpty a # Source # Methods(<.>) :: Diff (a -> b) -> Diff a -> Diff b #(.>) :: Diff a -> Diff b -> Diff b #(<.) :: Diff a -> Diff b -> Diff a #liftF2 :: (a -> b -> c) -> Diff a -> Diff b -> Diff c # Source # Methods(>>-) :: Diff a -> (a -> Diff b) -> Diff b #join :: Diff (Diff a) -> Diff a # Source # Methodsduplicated :: Diff a -> Diff (Diff a) #extended :: (Diff a -> b) -> Diff a -> Diff b # Source # Methodsunit :: a -> Diff (Parity a) #counit :: Parity (Diff a) -> a #leftAdjunct :: (Parity a -> b) -> a -> Diff b #rightAdjunct :: (a -> Diff b) -> Parity a -> b # Bounded a => Bounded (Diff a) Source # Methods (Eq a, Semigroup a) => Eq (Diff a) Source # Methods(==) :: Diff a -> Diff a -> Bool #(/=) :: Diff a -> Diff a -> Bool # Data a => Data (Diff a) Source # Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Diff a -> c (Diff a) #gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Diff a) #toConstr :: Diff a -> Constr #dataTypeOf :: Diff a -> DataType #dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (Diff a)) #dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Diff a)) #gmapT :: (forall b. Data b => b -> b) -> Diff a -> Diff a #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Diff a -> r #gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Diff a -> r #gmapQ :: (forall d. Data d => d -> u) -> Diff a -> [u] #gmapQi :: Int -> (forall d. Data d => d -> u) -> Diff a -> u #gmapM :: Monad m => (forall d. Data d => d -> m d) -> Diff a -> m (Diff a) #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Diff a -> m (Diff a) #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Diff a -> m (Diff a) # (Ord a, Semigroup a) => Ord (Diff a) Source # Methodscompare :: Diff a -> Diff a -> Ordering #(<) :: Diff a -> Diff a -> Bool #(<=) :: Diff a -> Diff a -> Bool #(>) :: Diff a -> Diff a -> Bool #(>=) :: Diff a -> Diff a -> Bool #max :: Diff a -> Diff a -> Diff a #min :: Diff a -> Diff a -> Diff a # Read a => Read (Diff a) Source # MethodsreadsPrec :: Int -> ReadS (Diff a) #readList :: ReadS [Diff a] # Show a => Show (Diff a) Source # MethodsshowsPrec :: Int -> Diff a -> ShowS #show :: Diff a -> String #showList :: [Diff a] -> ShowS # Generic (Diff a) Source # Associated Typestype Rep (Diff a) :: * -> * # Methodsfrom :: Diff a -> Rep (Diff a) x #to :: Rep (Diff a) x -> Diff a # Semigroup a => Semigroup (Diff a) Source # Methods(<>) :: Diff a -> Diff a -> Diff a #sconcat :: NonEmpty (Diff a) -> Diff a #stimes :: Integral b => b -> Diff a -> Diff a # Monoid a => Monoid (Diff a) Source # Methodsmempty :: Diff a #mappend :: Diff a -> Diff a -> Diff a #mconcat :: [Diff a] -> Diff a # NFData a => NFData (Diff a) Source # Methodsrnf :: Diff a -> () # Monoid a => Group (Diff a) Source # Methodsinvert :: Diff a -> Diff a #pow :: Integral x => Diff a -> x -> Diff a # Source # Associated Typestype Rep1 Diff (f :: Diff -> *) :: k -> * # Methodsfrom1 :: f a -> Rep1 Diff f a #to1 :: Rep1 Diff f a -> f a # type Rep Diff Source # type Rep Diff = Bool type Rep (Diff a) Source # type Rep (Diff a) = D1 * (MetaData "Diff" "Data.Monoid.Diff.Internal" "difference-monoid-0.1.0.0-6GZ7n3SsUmUHrUzugzcGeo" False) (C1 * (MetaCons ":-:" (InfixI LeftAssociative 6) False) ((:*:) * (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 * a)) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 * a)))) type Rep1 * Diff Source # type Rep1 * Diff = D1 * (MetaData "Diff" "Data.Monoid.Diff.Internal" "difference-monoid-0.1.0.0-6GZ7n3SsUmUHrUzugzcGeo" False) (C1 * (MetaCons ":-:" (InfixI LeftAssociative 6) False) ((:*:) * (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) Par1) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) Par1))) diff :: Monoid a => a -> Diff a Source # Lift a monoid into the difference monoid. >>> diff (Sum 1) Sum {getSum = 1} :-: Sum {getSum = 0} retract :: Group a => Diff a -> a Source # The inverse of diff. retract . diff = id foldDiff :: Group b => (a -> b) -> Diff a -> b Source # A group homomorphism given a monoid homomorphism. normalize :: (a -> a -> (a, a)) -> Diff a -> Diff a Source # Given a "normalizing" function, try simplify the representation. For instance, one such normalizing function may be to take the numeric difference of two types: >>> let sumNorm x y = if x >= y then (x - y, 0) else (0, y - x) >>> normalize sumNorm ((foldMap (diff.Sum) [1..10]) <> (invert (foldMap (diff.Sum) [1..5]))) Sum {getSum = 40} :-: Sum {getSum = 0} runDiff :: (a -> a -> b) -> Diff a -> b Source # Interpret the difference using a subtraction function. newtype Parity a Source # The Parity Comonad. It is left-adjunct to Diff. Constructors  Parity FieldsrunParity :: (Odd, a) Instances  Source # Methods(>>=) :: Parity a -> (a -> Parity b) -> Parity b #(>>) :: Parity a -> Parity b -> Parity b #return :: a -> Parity a #fail :: String -> Parity a # Source # Methodsfmap :: (a -> b) -> Parity a -> Parity b #(<$) :: a -> Parity b -> Parity a # Source # Methodsmfix :: (a -> Parity a) -> Parity a # Source # Methodspure :: a -> Parity a #(<*>) :: Parity (a -> b) -> Parity a -> Parity b #liftA2 :: (a -> b -> c) -> Parity a -> Parity b -> Parity c #(*>) :: Parity a -> Parity b -> Parity b #(<*) :: Parity a -> Parity b -> Parity a # Source # Methodsfold :: Monoid m => Parity m -> m #foldMap :: Monoid m => (a -> m) -> Parity a -> m #foldr :: (a -> b -> b) -> b -> Parity a -> b #foldr' :: (a -> b -> b) -> b -> Parity a -> b #foldl :: (b -> a -> b) -> b -> Parity a -> b #foldl' :: (b -> a -> b) -> b -> Parity a -> b #foldr1 :: (a -> a -> a) -> Parity a -> a #foldl1 :: (a -> a -> a) -> Parity a -> a #toList :: Parity a -> [a] #null :: Parity a -> Bool #length :: Parity a -> Int #elem :: Eq a => a -> Parity a -> Bool #maximum :: Ord a => Parity a -> a #minimum :: Ord a => Parity a -> a #sum :: Num a => Parity a -> a #product :: Num a => Parity a -> a # Source # Methodstraverse :: Applicative f => (a -> f b) -> Parity a -> f (Parity b) #sequenceA :: Applicative f => Parity (f a) -> f (Parity a) #mapM :: Monad m => (a -> m b) -> Parity a -> m (Parity b) #sequence :: Monad m => Parity (m a) -> m (Parity a) # Source # Methodsextract :: Parity a -> a #duplicate :: Parity a -> Parity (Parity a) #extend :: (Parity a -> b) -> Parity a -> Parity b # Source # Methods(<@>) :: Parity (a -> b) -> Parity a -> Parity b #(@>) :: Parity a -> Parity b -> Parity b #(<@) :: Parity a -> Parity b -> Parity a # Source # Methodstraverse1 :: Apply f => (a -> f b) -> Parity a -> f (Parity b) #sequence1 :: Apply f => Parity (f b) -> f (Parity b) # Source # Methodsfold1 :: Semigroup m => Parity m -> m #foldMap1 :: Semigroup m => (a -> m) -> Parity a -> m #toNonEmpty :: Parity a -> NonEmpty a # Source # Methods(<.>) :: Parity (a -> b) -> Parity a -> Parity b #(.>) :: Parity a -> Parity b -> Parity b #(<.) :: Parity a -> Parity b -> Parity a #liftF2 :: (a -> b -> c) -> Parity a -> Parity b -> Parity c # Source # Methods(>>-) :: Parity a -> (a -> Parity b) -> Parity b #join :: Parity (Parity a) -> Parity a # Source # Methodsduplicated :: Parity a -> Parity (Parity a) #extended :: (Parity a -> b) -> Parity a -> Parity b # Source # Methodsunit :: a -> Diff (Parity a) #counit :: Parity (Diff a) -> a #leftAdjunct :: (Parity a -> b) -> a -> Diff b #rightAdjunct :: (a -> Diff b) -> Parity a -> b # Source # Methodsask :: Parity a -> Odd # Bounded a => Bounded (Parity a) Source # Methods Eq a => Eq (Parity a) Source # Methods(==) :: Parity a -> Parity a -> Bool #(/=) :: Parity a -> Parity a -> Bool # Ord a => Ord (Parity a) Source # Methodscompare :: Parity a -> Parity a -> Ordering #(<) :: Parity a -> Parity a -> Bool #(<=) :: Parity a -> Parity a -> Bool #(>) :: Parity a -> Parity a -> Bool #(>=) :: Parity a -> Parity a -> Bool #max :: Parity a -> Parity a -> Parity a #min :: Parity a -> Parity a -> Parity a # Read a => Read (Parity a) Source # MethodsreadsPrec :: Int -> ReadS (Parity a) #readList :: ReadS [Parity a] # Show a => Show (Parity a) Source # MethodsshowsPrec :: Int -> Parity a -> ShowS #show :: Parity a -> String #showList :: [Parity a] -> ShowS # Ix a => Ix (Parity a) Source # Methodsrange :: (Parity a, Parity a) -> [Parity a] #index :: (Parity a, Parity a) -> Parity a -> Int #unsafeIndex :: (Parity a, Parity a) -> Parity a -> IntinRange :: (Parity a, Parity a) -> Parity a -> Bool #rangeSize :: (Parity a, Parity a) -> Int #unsafeRangeSize :: (Parity a, Parity a) -> Int Semigroup a => Semigroup (Parity a) Source # Methods(<>) :: Parity a -> Parity a -> Parity a #sconcat :: NonEmpty (Parity a) -> Parity a #stimes :: Integral b => b -> Parity a -> Parity a # Monoid a => Monoid (Parity a) Source # Methodsmappend :: Parity a -> Parity a -> Parity a #mconcat :: [Parity a] -> Parity a # NFData a => NFData (Parity a) Source # Methodsrnf :: Parity a -> () #
>>> import Data.Monoid hiding (diff, (<>))