/ #      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ Safe-InferredMaybe to monoid conversion>Convert a monoid value into a maybe value (Nothing if mempty). #monoidToMaybe = monoid Nothing JustExtracts the element out of a 5 and throws an error if its argument take the form  _.Using  Control.Lens:  x "a x^?!_Left fromLeft' (Left 12)12Extracts the element out of a 4 and throws an error if its argument take the form  _.Using  Control.Lens:  x "a x^?!_Right fromRight' (Right 12)12The U function takes two functions and applies the first if iff the value takes the form  _, and the second if the value takes the form  _.Using Data.Bifunctor:  = bimap Using  Control.Arrow:  = () mapBoth (*2) (*3) (Left 4)Left 8mapBoth (*2) (*3) (Right 4)Right 12The [ function takes a function and applies it to an Either value iff the value takes the form  _.Using Data.Bifunctor:  = first Using  Control.Arrow:  = () Using  Control.Lens:  = over _Left mapLeft (*2) (Left 4)Left 8mapLeft (*2) (Right "hello") Right "hello"The [ function takes a function and applies it to an Either value iff the value takes the form  _.Using Data.Bifunctor:  = second Using  Control.Arrow:  = () Using  Control.Lens:  = over _Right mapRight (*2) (Left "hello") Left "hello"mapRight (*2) (Right 4)Right 8The  function takes an p value and a function which returns a monad. The monad is only executed when the given argument takes the form  _, otherwise it does nothing.Using  Control.Lens:  "a forOf_ _Left whenLeft (Left 12) print12The  function takes an p value and a function which returns a monad. The monad is only executed when the given argument takes the form  _, otherwise it does nothing.Using  Data.Foldable:  "a forM_ Using  Control.Lens:  "a forOf_ _Right whenRight (Right 12) print12  A synonym of .  A synonym of . $Extract the left value or a default.   "a   fromLeft "hello" (Right 42)"hello"fromLeft "hello" (Left "world")"world" %Extract the right value or a default.   b "a  b  !fromRight "hello" (Right "world")"world"fromRight "hello" (Left 42)"hello" Maybe get the  side of an .   "a   ( ) Using  Control.Lens:   "a preview _Left   x "a x^?_Left leftToMaybe (Left 12)Just 12leftToMaybe (Right 12)NothingMaybe get the  side of an .  "a  ( )  Using  Control.Lens:  "a preview _Right  x "a x^?_Right rightToMaybe (Left 12)NothingrightToMaybe (Right 12)Just 12BForce a right value, or otherwise fail with provided error message )fromRightNote err = either (error err) idAForce a left value, or otherwise fail with provided error message (fromLeftNote err = either id (error err)DForce a right value, providing a default value if the Either is LeftmExtract the first element of a list as a Right value, or else use the default value provided as a Left valuejExtracts the right value of an either to a singleton list, or an empty list if the Either value is a LeftNote): A Left value is lost in the convertion.The  function takes a list of !s and returns a list of all the  values.This is just an alias for  , defined in  Data.Either  =  The  function is a version of c which can throw out elements. In particular, the functional argument returns something of type  a bP. If this is 'Left a', no element is added on to the result list. If it just  b, then b! is included in the result list. mapEither f = rights . map fuConvert a Maybe value to an Either value, with the provided default used as Left value if the Maybe value is Nothing(Convert an Either value to a Maybe value?This function is provided with a different name convention on Data.Either.Combinators:  =  qeitherToMonoid extract the right sided monoid into a single monoid value, or mempty in the case of a left value. !eitherToMonoid = either mempty idUmonoidToEither extracts a non-empty value to the right side, or otherwise fills the  side with the provided value.GCase analysis for a either monoid. If the right side of the monoid is N, then the value is transformed to a left value, using the provided function.rApply a function to a non-empty list, and retrieve its result or the default provided value if the list is empty. Alias for . Alias for  .  . Yeah, it saves 3 characters. notNull = not . nullAlias for null Similar to  from Safev package However, no text is added to the provided string error, for more deterministic error messages transparency. cReturns the first value of a list if not empty, or the provided default value if the list is empty! Alias for  catMonoid."Alias for concatMap#!Insert a single value into a list singleton = returnor singleton = (:[])$Amap a value over a list of functions, and return a list of valuesSee: Ghttp://www.haskell.org/pipermail/haskell-cafe/2007-February/022694.html  Alternative 1: mapV value = map ($ value)  Alternative 2&: mapV value lst = sequence lst value %kSort and nub (remove duplicates) from a list. Specially for large lists, this is much more efficient than  nub . sort.Note: You shold probably be using Data.Set. &nubSort = Set.toAscList . Set.fromList&QSort, nub (remove duplicates) and remove initial empty value, if it exists. See %.'YLazy length: determine if a list has a given size without computing all of its elements.See ;http://www.haskell.org/haskellwiki/Haskell_programming_tips("Case evaluation for a tuple pair, reducing it to a single value)?Case evaluation for single type tuple pairs, simplification of (.*UIs the pair tuple 'valid', i.e., does it have at least one non-empty (monoid) value?+?Is the pair tuple 'invalid', i.e., are both (monoid) elements ?,Longer (??) alias for .NoteA: included just for 'consistency' with the rest of the API. Use .-Longer (??) alias for .." the two monoid elements of a pair/" the two monoid elements of a pair0listToPair grabs the two first elements of a list, and inserts them into a tuple. If not enough elements are available, raise the provided error.1cGroups the elements of a list two by two, also returning the (possible) unpaired item not grouped.2 Similar to 1,, but discards the (possible) unpaired item.33Convert a single type pair into a two elements list4: each pair in a list into a single value, and filter out  values5Applies a pair returning function to each list element, and keeps only the non-empty mappend results (between the pair elements).6Transform a pair into an either. We adopt the convention that the second value is the one of interest. It is matched against 1, and if equal the first value is returned as a  value.7.Transform a pair into an either. The same as 6,, but the first tuple element is considered.8Transform a pair into an either. Both values are checked for a valid monoid (non-empty). The first to be found is returned as a Right value. If none is found, a default value is returned.9 Transform an 9 value into a pair. This follows the same convention as 6, and thus transforms a  value into a ( value,), and a  value into a  (def, value).: Transform an 9 value into a pair. This follows the same convention as 7, and thus transforms a  value into a (,  value), and a  value into a  (value, def).;Transform a pair onto a / This function follows the same convention as 6, and thus the second value is considered the most important one, and as such will take precedence over the first if both are not empty. If you prefer the first value to take precedence, see <$. If both elements of the pair are , this function returns .Note%: the reciprocal of this function is ;. 3pairToMaybe = monoid (monoid Nothing Just a) Just b<Transform a pair onto a  If both the values are non-empty, the first one is returned wrapped in a Just. If just one value is not-empty, that value is returned, irrespectively if it is the first or second. Otherwise, this function returns Nothing.Note%: the reciprocal of this function is ;. 4pairToMaybe' = monoid (monoid Nothing Just b) Just a=BTransform the first element of a pair (if it is a monoid) into an . Reciprocal to >. "pairToMaybe' = monoitToMaybe . fst>BTransform the second element of a pair (if it is a monoid) into a . Reciprocal to =. !pairToMaybe = monoitToMaybe . snd? Transform a 9 value into a pair. This follows the same convention as ;, and thus transforms a  into a (def, ), and a  value into a  (def, value).@ Transform a 9 value into a pair. This follows the same convention as <, and thus transforms a  into a (, def), and a  value into a  (value,def).ATFinds the first non-empty monoid in a pair, and returns it. If none found, returns .Note: reciprocal to BBSFinds the last non-empty monoid in a pair, and returns it. If none found, returns .C$Case evaluation for a tuple triple, reducing it to a single valueDACase evaluation for single type tuple triples, simplification of C.EWIs the triple tuple 'valid', i.e., does it have at least one non-empty (monoid) value?F?Is the pair tuple 'invalid', i.e., are both (monoid) elements ?G'Extract the first element from a tripleH;Alias for fromFst' (extract the first element of a triple).I(Extract the second element from a tripleJ<Alias for fromSnd' (extract the second element of a triple).K'Extract the third element from a tripleL Alias for KM" the two monoid elements of a pairN& the three monoid elements of a tripleOlistToTriple grabs the two three elements of a list, and inserts them into a triple tuple. If not enough elements are available, raise the provided error.PmGroups the elements of a list three by three, also returning the (possible) remaining item(s) (not grouped).Q Similar to P0, but discards the (possible) remaining item(s).R=Convert a single type triple tuple into a three elements listS< each triple in a list into a single value, and filter out  valuesT|Apply the provided function to each list element resulting in a triple, and keep only the non-empty monoids concat results.U<Pair to Triple, inserting the missing element in first place #toFstPairToTriple x (y,z) = (x,y,z)V=Pair to Triple, inserting the missing element in second place &toSndPairToTriple y (x, z) = (x, y, z)W<Pair to Triple, inserting the missing element in third place &toTrdPairToTriple z (x, y) = (x, y, z)XAlias for toTrdPairToTripleY+Triple to pair, removing the first element. \(_,y,z) -> (y,z)Z,Triple to pair, removing the second element. \(x,_,z) -> (x,z)[+Triple to pair, removing the third element. \(x,y,_) -> (x,y)\ Alias for [.]Triple to Maybe. Analogous to ;-, it keeps the first non-empty monoid value.^Triple to Maybe. Analogous to <,, it keeps the last non-empty monoid value._Triple to Monoid. Analogous to A-, it keeps the first non-empty monoid value.`Triple to Maybe. Analogous to B,, it keeps the last non-empty monoid value.cwApply a function to a non-empty monoid, and retrieve its result or the default provided value if the monoid is mempty.d!Check that a monoid is not memptye Alias for d.fCheck it is memptygtfromNotEmptyNote keeps the monoid value if it is not empty, otherwise it raises an error with the provided message.Note: This differs from fromJust? in the sense it is not possible to extract values from monoidhofromMonoid keeps the monoid value if it is not empty, otherwise it replaces it with the provided default valueNote;: No check is made to see if default value is itself memptyNote: This differs from  fromMaybe? in the sense it is not possible to extract values from monoidNote : similar to flip | for the appropriate types.iRInfix fromMonoid. Equivalent to higher order ternary operator, similar to python if in expressionsExample usage: +let x = valueThatCanBeEmpty ?+ defaultValuej^Monoid choice operator. See (obligatory reading, even if you don't understand it at first): yhttp://stackoverflow.com/questions/13080606/confused-by-the-meaning-of-the-alternative-type-class-and-its-relationship-toThis operator implements  like choice operator to s.kxlistToMonoid extracts the first element from a monoid list into a single monoid, or returns mempty if the list is emptyNote: This differs from  listToMaybeA in the sense it is not possible to promote values into a monoid listToMonoid = headDef memptylvmonoidToList convert an empty monoid into an empty list, otherwise it creates a singleton list with the monoid insideNote: This differs from  maybeToListD in the sense it is not possible to extract the value from a monoid "monoidToList = monoid [] singletonm)Filter out all empty monoids from a list. catMonoids = filter isNotEmptyn Alias for m.ouApply a function that returns a monoid to all elements of a list and return a new list with only not mempty results.Note: This differs from mapMaybeE in the sense it is not possible to extract the value from a monoid.pAGet the first non-empty element from a list. If all elements are $, or the list is empty, it returns . Note/: A newtype based solution as done by maybe in  Data.Monoid will always be more efficient than this, so this is not really recommend. However, it might come handy in some non-critical code.q@Get the last non-empty element from a list. If all elements are $, or the list is empty, it returns . Note/: A newtype based solution as done by maybe in  Data.Monoid will always be more efficient than this, so this is not really recommend. However, it might come handy in some non-critical code.rA  that fails returning <. Gets the first element of a foldable stucture of monoids.Returns  if the structure is empty.sA  that fails returning E. Gets the last element of a foldable stucture of monoids. Returns  if the structure is empty.NoteE: this function starts by mapping the foldable structure to a list...tA '(!!)' that fails returning .NoteE: this function starts by mapping the foldable structure to a list...uInfix version of t.vfromBool is a 'if'4 rewrite following the call convention of fromMaybe.wfromBoolC is similar to v>, but it takes a condition rather than a simple boolean valuexACat bools. Filter out False values from a list. Probably useless. catBools = filter idy Ternary operator. Use like this: (i > 0) ? i $ 1Note6: this is non-idiomatic haskell. Use at your own risk.NoteE: this may require additional parenthesis, so it may not be worth it.z-Higher order ternary operator. Use like this: $(not . null) ?$ "" $ "default value"Note6: this is non-idiomatic haskell. Use at your own risk.{1Higher order ternary operator, similar to python if in expressions. Use like this: $"" ?| (not . null) $ "default value"Note6: this is non-idiomatic haskell. Use at your own risk.|DProvided a default value, apply it to a maybe if the predicate holds}.Same as boolToMaybe, but with a more familiar  'if-like' syntax~VTest a value with a function returning a Bool, and apply it to a Maybe accordingly./Same as boolCToMaybe, but with a more familiar  'if-like' syntax4Provided two values, choose amongst them based on a  value. &\l r b = if b then Right r else Left l[Provided two values, choose amongst them based on a the provided test on the second value. (\l r f = if f r then Left l else Right r-Insert the provided value into a list if the  value is ", otherwise return an empty list.DInsert the provided value into a list if the provided condition is !, otherwise return an empty list.!Use a list comprehension instead: [value | f value]Keep the provided value if the  value is ,  otherwise.Keep the provided value if the  value is ,  otherwise. Emulates and,&& and or,|| from scripting languages like python, in the sense you can mix booleans with a value to get the value when the boolean is true (or  otherwise).#However, in order to allow several g in a row, the order is not the one normally used in languages like bash, where the test comes first.Usage: !value ?&& bool1 ?&& bool2 ?&& ...Notec: this is non-idiomatic haskell. Use at your own risk. You should instead use the following code : 0if bool1 && bool2 && ... then value else memptyOr better yet: /if and [bool1,bool2,...] then value else mempty Emulates and,&& and or,|| from scripting languages like python, in the sense you can mix boolean tests with a value to get the original value when all the tests return true (or  otherwise).#However, in order to allow several ??&&g in a row, the order is not the one normally used in languages like bash, where the test comes first.Note: an easy mnemonic to remember is that operators ending in \ (lambda) imply that their parameters are functions instead of values (in this particular case, boolean tests)Usage: .value ?&&\ condition1 ?&&\ condition2 ?&&\ ...Note6: this is non-idiomatic haskell. Use at your own risk.JApply a list of boolean checks/tests to a variable, and return (True) if all of them passed.Note: See  in  Data.Monoid and  in Prelude for reference.See: Ghttp://www.haskell.org/pipermail/haskell-cafe/2007-February/022694.htmlFlipped allCond  flip allCondJApply a list of boolean checks/tests to a variable, and return (True) if any of them passed.Note: See  in  Data.Monoid and  in Prelude for reference.See: Ghttp://www.haskell.org/pipermail/haskell-cafe/2007-February/022694.htmlFlipped anyCond  flip anyCond  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~iju yz{      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ data-easy-0.6 Data.Easy Control.Arrow+++leftright maybeToMonoid monoidToMaybe fromLeft' fromRight'mapBothmapLeftmapRightwhenLeft whenRight unlessLeft unlessRightfromLeft fromRight leftToMaybe rightToMaybe fromRightNote fromLeftNote fromEither listToEither eitherToList catEithers mapEither maybeToEither eitherToMaybeeitherToMonoidmonoidToEitherjoinEitherMonoidlistisFillednotNullisNull fromHeadNotefromListcatListsmapList singletonmapVnubSortnubSort'atLeastpairpairSisPairNotEmpty isPairEmptyfromFstfromSnd fromPairNotefromPairlistToPairNote listToPairsgroup2 pairToListcatPairsmapPair pairToEither pairToEither'pairBothToEither eitherToPair eitherToPair' pairToMaybe pairToMaybe'pairFstToMaybepairSndToMaybe maybeToPair maybeToPair' pairToMonoid pairToMonoid'tripletripleSisTripleNotEmpty isTripleEmptyfromFst'fst'fromSnd'snd'fromTrd'trd'fromTripleNote fromTriplelistToTripleNote listToTriplesgroup3 tripleToList catTriples mapTripletoFstPairToTripletoSndPairToTripletoTrdPairToTriple pairToTripledropFstTripleToPairdropSndTripleToPairdropTrdTripleToPair tripleToPair tripleToMaybetripleToMaybe'tripleToMonoidtripleToMonoid'curry3uncurry3monoid isNotEmptynotEmptyisEmptyfromNotEmptyNote fromMonoid?+ listToMonoid monoidToList catMonoidsnonEmpty mapMonoid getFirst'getLast'headFlastFatF@@fromBool fromBoolCcatBools??$?| boolToMaybe ifToMaybe boolCToMaybe ifCToMaybe boolToEither boolCToEither boolToList boolCToList boolToMonoid boolCToMonoid?&&?&&\allCondallCond'anyCondanyCond'base Data.EitherLeftRightEithereitherGHC.Baseid Data.MaybeJustconstNothingrightsmap Data.Monoidmemptyghc-prim GHC.ClassesnotGHC.Listnull safe-0.3.9SafeheadNote Data.TuplefstsndmappendMaybeControl.Applicative AlternativeMonoidheadlast GHC.TypesBoolTrueAllallAnyany toEnumSafe toEnumNote toEnumDef toEnumMayfindIndexJustNotefindIndexJustDef findIndexJustelemIndexJustNoteelemIndexJustDef elemIndexJust findJustNote findJustDeffindJustlookupJustNote lookupJustDef lookupJustreadNotereadDefreadMayatNoteatDefatMayat assertNote fromJustNote fromJustDef scanl1Note scanr1Note scanl1Def scanr1Def scanl1May scanr1May foldl1Note' foldl1Note foldr1Note foldl1Def' foldl1Def foldr1Def foldl1May' foldl1May foldr1May maximumByNote minimumByNote maximumByDef minimumByDef maximumByMay minimumByMay maximumNote minimumNote maximumDef minimumDef maximumMay minimumMaylastNotelastDefheadDeflastMayheadMayinitSafeinitNoteinitDefinitMaytailSafetailNotetailDeftailMayabort