!"# $ %&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\ ]^_ ` abcdef ghijklm n o p q r s t u v w x y z { | } ~                            ! "#$%&'()*+,-./0123456789:; < = > ? @ ABCD E F G H I J K L M N O P Q R S TUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      None)6:,-. +*)('&%$#",-. +*)('&%$#",-.,-.Safe)6/LA class which represents things that can be converted from integer literals /012345678,-.//0/00,-./ /0012345678Safe)6Safe)6067067Safe)6Safe)639:39:Safe)69Used for desugaring if expressions.ifThenElse True 1 01ifThenElse False 1 00: Fold over a +. bool 1 0 True1bool 1 0 False09: +589: +58:99:Safe)6[Z            Safe)6!mnopqrustxwvzy|{}~.utstsxwvrqponzyy|{{~}~}m Safe)6;A flipped version of .<2Arrow-like operator. Useful for chaining with the  and   combinators.=2Arrow-like operator. Useful for chaining with the  and  ! combinators.;<= $;<= $;<=;<=;1<1=1 Safe)6>The > function is analogous to "4, except that its result is encapsulated in a monad. # foldlM f a1 [x1, x2, ..., xm]== P do a2 <- f a1 x1 a3 <- f a2 x2 ... f am xm?Like >, but discards the result.@Like , but discards the result.>?@# \_`>?@# `_>?@\ >?@Safe)6YVWXYXWVXWVSafe)6AA n act performs the action n times, gathering the results.BLike A, but discards the result.C This generalizes the list-based # function.ABC&]^ihglkjABC&ihglkj^]ABCABC None)69;DEFGHIJKLMNOPQRS !DEFGHIKJLMGHIJKDEF!ML  DEFGHIJKLMNOPQRSNone)6TIt may be better to use (T) instead of ( $)W to avoid potential efficiency problems relating to #7542. The problem, in a nutshell:If N is a newtype constructor, then N x. will always have the same representation as xG (something similar applies for a newtype deconstructor). However, if f is a function, N  $ f = x -> N (f x)This looks almost the same as f4, but the eta expansion lifts it--the lhs could be _|_, but the rhs never is. This can lead to very inefficient code. Thus we steal a technique from Shachaf and Edward Kmett and adapt it to the current (rather clean) setting. Instead of using N  $ f , we use N .# f, which is just  f `%& (N  $ f) That is, we just *pretend* that f2 has the right type, and thanks to the safety of y, the type checker guarantees that nothing really goes wrong. We still have to be a bit careful, though: remember that T4 completely ignores the *value* of its left operand.T4T4TTT9 Safe)6UA  &https://en.wikipedia.org/wiki/SemiringSemiring% is like the the combination of two 's. The first is called Y; it has the identity element W/, and it is commutative. The second is called X; it has identity element V, and it must distribute over Y.LawsNormal ' laws (a Y b) Y c = a Y (b Y c) W Y a = a Y W = a (a X b) X c = a X (b X c) V X a = a X V = aCommutativity of Y a Y b = b Y aDistribution of X over Y aX(b Y c) = (aXb) Y (aXc) (a Y b)Xc = (aXc) Y (bXc)HAnother useful law, annihilation, may be deduced from the axioms above: W X a = a X W = WVThe identity of X.WThe identity of Y.X8An associative binary operation, which distributes over Y.Y-An associative, commutative binary operation.UVWXYZ[\]^_`abcUXYWVUVWXYVWYXcba`_^]\[Z UVWXYVWYXZ[\]^_`abcX7Y6Safe)6d2An integral domain. Members of this class must be Us with commutative X. a X b = b X a (a f b) X b Y (a g b) = a (a'+'k'*'b) g b = a g b W g b = WeThe divisor and modulofInteger divisiongModulo defghijklmdfegdefgdefghijklmf7g7Safe)6)C?@ABFEDIHGLKJONMRQP)CCB@A?LKJONMFEDIHGRQPSafe)6nA n is a U% with an additive inverse, such that:  " r. r " n " i. r o i = WoA binary operation such that:  " r. r " n " i. r o i = W nopqrstuvwno noowvutsrqp noopqrstuvwo6Safe)6% 1;<=% 1;<=Safe)6xO(log n). Add an element to a set. If the set already contains an element equal to the given value, it is replaced with the new value.yO(log n). Remove an element from a set.xyxyxyxyNone)56IzMonoid under multiplication.}Monoid under addition.z{|}~*>UTSz{|}~*}~z{|UTS>z{|}~Safe)6" " Safe)6applyN (2+) 2 046Apply a function until it no longer changes its input.converge tail xs === []""Blackbird" operator. For example: aggregate f xs = sum (map f xs) aggregate = sum .: map  8None)6 is the dual of  , similar to ?. It can be quite useful as a kind of lightweight state-thing:6let toDigs b = unfoldl (ensure (>0) >-> flip divMod b) toDigs 10 123[1,2,3] toDigs 2 5[1,0,1]bExtract the elements after the head of a list. If the given list is empty, returns an empty list. tail [1,2,3][2,3]tail [][]jReturn all the elements of a list except the last one. If the given list is empty, returns an empty list. init [1,2,3][1,2]init [][] O(n*log n). The  function removes duplicate elements from a list. In particular, it keeps only the first occurrence of each element. (The name  means `essence'.)nub [1,2,3,2,3,4,1,2,5,2,3] [1,2,3,4,5]take 5 (nub [1..]) [1,2,3,4,5]take 5 (nub [10,9..]) [10,9,8,7,6]**Safe)6TRead a file and return its contents as a string. The file is read lazily, as with .WWrite a string to a file. The file is truncated to zero length before writing begins.!Write a string the end of a file.The # function takes a function of type  Text -> Text as its argument. The entire input from the standard input device is passed (lazily) to this function as its argument, and the resulting string is output on the standard output device.Lazily read all user input on stdin as a single string.&Read a single line of user input from stdin.Write a string to stdout.Write a string to stdout, followed by a newline. 2[Z 2[ZZNone)6QUsed for tracing a message along with a pure value. For debugging purposes only.7Used to fill in holes in code for later implementation.KPrints a value to stdout when it's evaluated. For debugging purposes only.None)69A Scott-ish encoding of a zip. Possibly very inefficient.%Left-associative fold of a structure.In the case of lists, , when applied to a binary operator, a starting value (typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right: Efoldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xnyNote that to produce the outermost application of the operator the entire input list must be traversed. This means that ) will diverge if given an infinite list.1This version is strict, in contrast to Prelude's .This ensures that each step of the fold is forced to weak head normal form before being applied, avoiding the collection of thunks that would otherwise occur. This is often what you want to strictly reduce a finite list to a single, monolithic result (e.g. ).For a lazy version, use .For a general '5 structure this should be semantically identical to,  foldl f z = (" f z . PLeft-associative fold of a structure but with lazy application of the operator.HNote that if you want an efficient left-fold, you probably want to use  instead of O. The reason for this is that latter does not force the "inner" results (e.g. z f x1F in the above example) before applying them to the operator (e.g. to (f x2)"). This results in a thunk chain O(n)B elements long, which then must be evaluated from the outside-in.For a general '5 structure this should be semantically identical to, foldlLazy f z = (" f z .  A variant of % that has no base case, and returns 6 for empty structures.  f = () f .  A variant of % that has no base case, and returns 6 for empty structures.  f = (* f . Fold over two ' s at once.5zip xs ys === foldr2 (\x y zs -> (x,y) : zs) [] xs ysFold over three ' s at once.@zip3 ws xs ys === foldr3 (\w x y zs -> (w,x,y) : zs) [] ws xs ys[The largest element of a structure with respect to the given comparison function. Returns 6 on an empty input..maximum (xs :: [Int]) === maximumBy compare xsYThe least element of a structure with respect to the given comparison function. Returns 6 on an empty input..minimum (xs :: [Int]) === minimumBy compare xs,The largest element of a structure. Returns 6 on empty structures.maximum [1,2,3]Just 3 maximum []Nothing*The least element of a structure. Returns 6 on empty structures.minimum [1,2,3]Just 1 minimum []NothingThe 9 function computes the sum of the numbers of a structure.(sum (xs :: [Integer]) === foldl (+) 0 xsThe > function computes the product of the numbers of a structure.,product (xs :: [Integer]) === foldl (*) 1 xs%The first element of a structure, or 6 if it's empty. head [1,2,3]Just 1head []Nothinghead xs === last (reverse xs)$The last element of a structure, or 6 if it's empty. last [1,2,3]Just 3last []Nothinglast xs === head (reverse xs)5Index (subscript) operator, starting from 0. Returns 6 for out-of-range indices. [1,2,3] !! 0Just 1[1,2,3] !! (-1)Nothing [1,2,3] !! 3Nothing '('9 None)6A generalized version of filter+, which works on anything which is both a # and .-\(Blind p) xs -> filter p xs === afilter p xs. allows you to attach a condition to something" is especially useful for parsers. Convert any ' to an aMap a function over a monad, and concat the results. This is a generalized form of the function +,. ffNone)6OT?A Scott-encoding of a list. This probably isn't very efficient.Evaluate each action in the structure from left to right, and and collect the results. For a version that ignores the results see .Evaluate each action in the structure from left to right, and ignore the results. For a version that doesn't ignore the results see .>Zip two structures together, preserving the shape of the left.0zipInto const (xs :: [Int]) (ys :: [Int]) === xs  (deabc (ededcbaSafe)6 ! !  -A fun-ish Prelude replacementMITmail@doisinkidney.com experimentalNone)6 ! " # $% &'(ed)C*+58,-./0671;<=239:4>?@ABFEDIHGLKJONMRQPUTSYWVX[Z\]^_`abcfihglkjmnopqrutsxwvzy|{}~      !+*)('&%$#",-./09:;<=>?@ABCDEFGHIKJLMTUXYWVdfegnoxyz{|}~./#./0.12.13.45.46789.:;.:<.:=.:>7?@7?A.4B.4C.4D.4E.4F.GH.GI.GJ.GK.LM.NO.PQ.RS.4T.4U.4V.4W.4X.4Y.:Z.:[7?\.4].4^7?_.4`.ab.cd.Re.4'7fg7fh7fi7fjklm.4n7fo7fp.qr7fs7ft.4u.4v7fw.qx.qy7fz7f{7f|.R}.R~.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.......N.N.N.N .N!.c.c.c.c.c........G.G.G.G.G.G.G.G.G.G.G.G.G.G.G.G.G.G.G.G.G.G.G.G...$......a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a........q.q.q..........................:.:.:.:.:.:././././ ./ ./ ./ ./ ./././././././././././././.+.+.1.1.1.4 .4!.4".4#.4$.4%.4&.4'.4(.4).4*.4+.4,.-.7?/7?07?17?27?37?47?57?67?77?89:;<=><?@<?A<?B<CD<CEFGHFGIFGJFGKFGLFGMFGNOPQOPQOPROPSOPTOPUOPVOPWOPXYZ[YZ\YZ]YZ^YZ_YZ`YZaYZbYZcYZdYZeYZfYZgYZhYijklmklnkloklpklqklrklskltkluklvwxyz{|}~                      ")*       .  .  OO.a"(SS(U(precursor-0.1.0.0-CLpG2xMRVfMB9mhHgiVbN4Precursor.Data.ListPrecursor.Data.TuplePrecursor.Data.BoolPrecursor.FunctionPrecursor.CoercePrecursor.Algebra.EnumPrecursor.Algebra.EqPrecursor.Algebra.OrdPrecursor.Control.MonadPrecursor.Control.FunctorPrecursor.Control.CategoryPrecursor.Text.TextPrecursor.Control.AlternativePrecursor.Algebra.SemigroupPrecursor.Algebra.MonoidPrecursor.Control.ApplicativePrecursor.Structure.FoldablePrecursor.Structure.TraversablePrecursor.Numeric.NumPrecursor.Data.MaybePrecursor.System.IOPrecursor.Data.EitherPrecursor.Control.BifunctorPrecursor.Numeric.IntegralPrecursor.DebugPrecursor.Data.MapPrecursor.Data.SetPrecursor.Control.StatePrecursor.Text.ShowPrecursor.Algebra.SemiringPrecursor.Algebra.Ring<=<>=>foldlfilter.Prelude asTypeOf'MonoidListfoldr1foldl1 Data.MaybemapMaybe PrecursorbaseGHC.Listzip Data.TuplefstsndGHC.Base otherwise$ghc-primGHC.PrimcoerceGHC.EnumenumFrom enumFromThen enumFromToenumFromThenTo GHC.Classes==>=fail>>=>>fmapreturn Control.Arrowarrapp|||loop Data.String fromString Control.MonadguardGHC.ExtsfromListData.Semigroup<>memptymappendjoin<*>pure*>BoundedEnumEqMonadFunctorOrd Applicative Data.FoldableFoldableData.Traversable Traversable Semigroup GHC.TypesBoolDoubleFloatInt integer-gmpGHC.Integer.TypeIntegerMaybeOrderingIO Data.EitherEither CoercibleFalseNothingJustTrueLeftRightLTEQGToption mtimesDefaultstimesIdempotentstimesIdempotentMonoid stimesMonoidsconcatgetMinMingetMaxMaxgetFirstFirstgetLastLast unwrapMonoid WrapMonoid WrappedMonoid getOptionOptionData.Bifunctorsecondfirstbimap BifunctorControl.Monad.IO.ClassliftIOMonadIO<$!>unlessforever mapAccumR mapAccumLfor sequenceAtraverseControl.Applicativeoptional unwrapArrow WrapArrow WrappedArrow getZipListZipListleftApp^<<<<^>>^^>>returnA&&&***Arrow runKleisliKleisli zeroArrow ArrowZero<+> ArrowPlus+++rightleft ArrowChoice ArrowApply ArrowMonad ArrowLoopControl.Category>>><<<idCategoryData.Functor.ConstgetConstConstfindnotElemallanyorand concatMapconcatasumfor_ traverse_foldrMelemlengthnulltoListfoldr'foldrfoldMapfold Data.MonoidgetDualDualappEndoEndoGHC.IOFilePathpartitionEithersrightslefts Data.OldListunfoldrsortOnsortBysort permutations subsequencestailsinitsgroupBygroup partition transpose intercalate intersperseData.Ord comparingDown Data.Function&onfix Data.Functorvoid$><$>GHC.RealoddevenmaxBoundminBoundfromEnumtoEnumpredsuccunzip3unzipzipWith3zipWithzip3reversesplitAtdroptake dropWhile takeWhilecycle replicaterepeatiteratescanr1scanrscanl'scanl1scanluncons fromMaybemaybeswapuncurrycurryflipconstwhen=<<liftA2<**><$<*manysome<|>empty AlternativeGHC.Err undefined/=compare<=&&||not<>maxminbytestring-0.10.8.1Data.ByteString.Lazy.Internal ByteStringcontainers-0.5.7.1Data.Map.Strictinsert Data.Map.BasedeletelookupMap Data.Set.BasememberSet mtl-2.2.1-6qsR1PHUy5lL47Hpoa4jCMControl.Monad.State.Classgetsmodify'modifystateputget MonadStatetransformers-0.5.2.0Control.Monad.Trans.State.LazyStateT runStateTStaterunState evalState execState evalStateT execStateT#text-1.2.2.1-9Yh8rJoh8fO2JMLWffT3QsData.Text.Lazy isInfixOf isSuffixOf isPrefixOfunwordsunlineswordslinestoTitletoUppertoLower toCaseFoldtoChunks fromChunks singletonData.Text.Internal.LazyText&text-show-3.4.1-E2ELspw7mPT1trV8bXpZVgTextShow.Classes showtlListshowtl showtlPrec showtListshowt showtPrec showbListshowb showbPrecTextShowshow gShowPrecprintNum fromInteger $fNumFloat $fNumDouble $fNumInt64 $fNumInt32 $fNumInt16 $fNumInt8$fNumInt $fNumInteger ifThenElsebool<&><-<>->foldlMfoldlM_foldrM_ replicateA replicateA_filterAIsBytes fromBytes fromBytes'IsTextfromText fromText' readBytes' readBytesStrictByteString StrictText$fIsBytesByteString$fIsBytesByteString0$fIsTextByteString$fIsTextByteString0 $fIsTextText $fIsTextText0#.Semiringonezero*+$fSemiring(->)$fSemiringBool$fSemiringDouble$fSemiringFloat$fSemiringInteger$fSemiringInt64$fSemiringInt32$fSemiringInt16$fSemiringInt8 $fSemiringIntIntegraldivMod//%$fIntegralInteger$fIntegralInt64$fIntegralInt32$fIntegralInt16$fIntegralInt8 $fIntegralIntRing- $fRingDouble $fRingFloat $fRingInteger $fRingInt64 $fRingInt32 $fRingInt16 $fRingInt8 $fRingIntaddremoveProduct getProductSumgetSum$fMonadProduct$fApplicativeProduct$fFunctorProduct$fMonoidProduct$fSemigroupProduct$fTextShowProduct $fMonadSum$fApplicativeSum $fFunctorSum $fMonoidSum$fSemigroupSum $fTextShowSum$fEqSum$fOrdSum $fBoundedSum $fGenericSum $fGeneric1Sum$fNumSum $fEqProduct $fOrdProduct$fBoundedProduct$fGenericProduct$fGeneric1Product $fNumProductapplyNconverge.:unfoldltailinitnubreadFile writeFile appendFileinteract getContentsgetLineputStrputStrLntracenotImplemented traceShow foldlLazyfoldr2foldr3 maximumBy minimumBymaximumminimumsumproductheadlast!! $fMonoidMin $fMonoidMaxafilterensureeitherAtoAltmapAltsequence sequence_zipInto$fApplicativeState$fFunctorStateControl.Monad.FixMonadFixmfixControl.Monad.Trans.Class MonadTransliftScottZip