úΛЗ6      !"#$%&' ( ) * + , - . / 0 1 2 3 4 5 !diagrams-discuss@googlegroups.com Safe-InferredThe Monoid'3 class is a synonym for things which are instances  of both 6 and 7. Ideally, the 7 class $ itself will eventually include a 6 superclass and we  can get rid of this. 88!diagrams-discuss@googlegroups.com Safe-InferredA value of type  Recommend a consists of a value of type a / wrapped up in one of two constructors. The  Recommend  constructor indicates a "non-committal recommendation"---that 1 is, the given value should be used if no other/better values are  available. The Commit constructor indicates a  " commitment",---a value which should definitely be used,  overriding any  Recommend ed values. Extract the value of type a wrapped in  Recommend a. 9 overrides !. Two values wrapped in the same  constructor (both  or both ) are combined  according to the underlying  Semigroup instance. :9:9!diagrams-discuss@googlegroups.com Safe-Inferred ;< =>?@AB      ;< =>?@AB!diagrams-discuss@googlegroups.com Safe-InferredAn  in a given C is a morphism from some @ object to itself. The set of endomorphisms for a particular E object form a monoid, with composition as the combining operation 6 and the identity morphism as the identity element. DEFDEF!diagrams-discuss@googlegroups.com Safe-InferredIf m is a 7, then  Deletable m (intuitively speaking) ' adds two distinguished new elements [ and ], such that an  occurrence of [ "deletes" everything from it to the next ]. For  example,   abc[def]gh == abcgh 'This is all you really need to know to use  Deletable m = values; to understand the actual implementation, read on. >To properly deal with nesting and associativity we need to be * able to assign meanings to things like [[, ][, and so on. (We  cannot just define, say, [[ == [ , since then ([[)] == [] ==  id but [([] ) == [id == [.) Formally, elements of  Deletable  m6 are triples of the form (r, m, l) representing words ]^r m  [^l<. When combining two triples (r1, m1, l1) and (r2, m2, l2)  there are three cases: + If l1 == r2 then the [s from the left and ]s from the right 2 exactly cancel, and we are left with (r1, m1 <> m2, l2).  If l1 </ r2 then all of the [s cancel with some of the ]s, but & m1 is still inside the remaining ]s and is deleted, yielding (r1  + r2 - l1, m2, l2) 2 The remaining case is symmetric with the second. #Project the wrapped value out of a  value. Inject a value into a  wrapper. Satisfies the  property  unDelete . toDeletable === id A " left bracket"-, which causes everything between it and the % next right bracket to be deleted. A " right bracket"., denoting the end of the section that should  be deleted. GHGH!diagrams-discuss@googlegroups.com Safe-InferredA value of type Cut m is either a single m, or a pair of  m'4s separated by a divider. The divider represents a "cut  point". Cut is similar to Data.Monoid.Split, but split keeps only the D rightmost divider and accumulates all values, whereas cut always B keeps the leftmost and rightmost divider, coalescing them into 9 one and throwing away all the information in between. Split! uses the asymmetric constructor :|, and Cut the  symmetric constructor :||:&, to emphasize the inherent asymmetry  of Split and symmetry of Cut. Split keeps only the 8 rightmost split and combines everything on the left; Cut keeps ? the outermost splits and throws away everything in between. A convenient name for mempty :||: mempty, so composing with  cut' introduces a cut point. For example, Uncut a <> cut <>  Uncut b == a :||: b. IIf m is a  Semigroup, then Cut m is a semigroup which  contains m3 as a sub-semigroup, but also contains elements of  the form  m1 :||: m2. When elements of m combine with such  "cut"2 elements they are combined with the value on the " corresponding side of the cut (e.g.  (Uncut m1) <> (m1' :||:  m2) = (m1 <> m1' ) :||: m2 ). When two "cut" elements meet, the E two inside values are thrown away and only the outside values are  kept. JIJI!diagrams-discuss@googlegroups.com Safe-Inferred>Type class for monoid (and semigroup) actions, where monoidal  values of type m "act" on values of another type s. . Instances are required to satisfy the laws  act mempty = id act (m1 `K` m2) = act m1 . act m2DSemigroup instances are required to satisfy the second law but with  '( )' instead of K. Additionally, if the type s has  any algebraic structure, act m should be a homomorphism. For  example, if s! is also a monoid we should have act m mempty =  mempty and  act m (s1 `K` s2) = (act m s1) `K`  (act m s2).  By default, act = const id, so for a type M which should have / no action on anything, it suffices to write   instance Action M s  with no method implementations. .It is a bit awkward dealing with instances of Action , since it - is a multi-parameter type class but we can't add any functional D dependencies---the relationship between monoids and the types on D which they act is truly many-to-many. In practice, this library - has chosen to have instance selection for Action driven by the  first5 type parameter. That is, you should never write an  instance of the form Action m SomeType since it will overlap  with instances of the form Action SomeMonoid t . Newtype 8 wrappers can be used to (awkwardly) get around this. Convert a value of type m to an action on s values. LNothing acts as the identity; Just m acts as m. LL!diagrams-discuss@googlegroups.com Safe-Inferred m :+: n is the coproduct of monoids m and n . Values of  type m :+: n! consist of alternating lists of m and n D values. The empty list is the identity, and composition is list B concatenation, with appropriate combining of adjacent elements  when possible. 1Injection from the left monoid into a coproduct. !2Injection from the right monoid into a coproduct. "&Prepend a value from the left monoid. #'Prepend a value from the right monoid. $killR7 takes a value in a coproduct monoid and sends all the 1 values from the right monoid to the identity. %killL7 takes a value in a coproduct monoid and sends all the 0 values from the left monoid to the identity. &BTake a value from a coproduct monoid where the left monoid has an  action on the right, and "untangle" it into a pair of values. In  particular,  ) m1 <> n1 <> m2 <> n2 <> m3 <> n3 <> ...  is sent to  a (m1 <> m2 <> m3 <> ..., (act m1 n1) <> (act (m1 <> m2) n2) <> (act (m1 <> m2 <> m3) n3) <> ...) That is, before combining n values, every n value is acted on  by all the m values to its left. M@Coproducts act on other things by having each of the components  act individually. N1The coproduct of two monoids is itself a monoid. OP !"#$%&MNQ !"#$%& !"#%$& OP !"#$%&MNQ !diagrams-discuss@googlegroups.comNone'SM, an abbreviation for " single monoid" (as opposed to a C heterogeneous list of monoids), is only used internally to help 8 guide instance selection when defining the action of / heterogeneous monoidal lists on each other. ) The relation l :>: a holds when a is the type of an element  in l. For example, '(Char ::: Int ::: Bool ::: Nil) :>: Int. *;Inject a value into an otherwise empty heterogeneous list. +Get the value of type a% from a heterogeneous list, if there  is one. ,Alter the value of type a' by applying the given function to it. -BType class for heterogeneous monoidal lists, with a single method + allowing construction of an empty list. .The empty heterogeneous list of type l . Of course, empty  == R , but unlike R, empty does not require  7$ constraints on all the elements of l. '()*+,-./0STUVWXYZ '()*+,-./0 /0-.)*+,'( '()*+,-./0STUVWXYZ !diagrams-discuss@googlegroups.com Safe-Inferred1A value of type Split m is either a single m, or a pair of  m'"s separated by a divider. Single m's combine as usual;  single m'2s combine with split values by combining with the B value on the appropriate side; when two split values meet only C the rightmost split is kept, with both the values from the left @ split combining with the left-hand value of the right split. Data.Monoid.Cut- is similar, but uses a different scheme for  composition. Split! uses the asymmetric constructor :|, and  Cut the symmetric constructor :||:, to emphasize the inherent  asymmetry of Split and symmetry of Cut. Split keeps only < the rightmost split and combines everything on the left; Cut E keeps the outermost splits and throws away everything in between. 4A convenient name for mempty :| mempty, so M a <> split <>  M b == a :| b. 5"Unsplit"5 a split monoid value, combining the two values into = one (or returning the single value if there is no split). [<By default, the action of a split monoid is the same as for 8 the underlying monoid, as if the split were removed. \If m is a  Semigroup, then Split m is a semigroup which ? combines values on either side of a split, keeping only the  rightmost split. 12345[]\123451324513245[]\^     !"#$%&'()*+,-. / / 0 1 2 3 4 5 6 7 8 9 : ; <=>?@ABCDEFGHIJKLM@NOPQRSTUV@AWXYZ[\]@A^ _ ` a b c d e f g h ijmonoid-extras-0.3.2.2Data.Monoid.WithSemigroupData.Monoid.RecommendData.Monoid.InfData.Monoid.EndomorphismData.Monoid.DeletableData.Monoid.CutData.Monoid.ActionData.Monoid.CoproductData.Monoid.MListData.Monoid.SplitMonoid' RecommendCommit getRecommendNegInfPosInfInfFiniteInfinityminimummaximumposInftynegInfty posFinite negFinite EndomorphismgetEndomorphism DeletableunDelete toDeletabledeleteLdeleteRCut:||:UncutcutActionact:+:inLinRmappendLmappendRkillRkillLuntangleSM:>:injgetaltMListempty:::*:Split:|Msplitunsplitsemigroups-0.11Data.Semigroup Semigroupbase Data.MonoidMonoid $fMonoid'm$fSemigroupRecommend$fMonoidRecommendNegPos $fMonoidInf $fMonoidInf0$fSemigroupInf$fSemigroupInf0$fOrdInf $fOrdInf0Control.CategoryCategory$fGroupEndomorphism$fMonoidEndomorphism$fSemigroupEndomorphism$fMonoidDeletable$fSemigroupDeletable$fSemigroupCut $fMonoidCutmappend$fActionOptions $fAction:+:r $fMonoid:+:MCounMCo$fSemigroup:+:mempty $fActionSM(,) $fActionSM() $fAction(,)l2 $fAction()l $f:>:(,)a $f:>:(,)a0 $fMList(,) $fMList()$fActionSplitn$fSemigroupSplit $fMonoidSplit