wpb      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`aportable provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred0< produces a new stream by repeatedly applying the unfolding : function to the seed value to produce an element of type b and a new 2 seed value. When the unfolding function returns b instead of $ a new seed value, the stream ends. ( efficiently turns a normal list into a  stream,  producing b if the input is empty. ? produces the first element of the stream, and a stream of the  remaining elements, if any. )Extract the first element of the stream. /Extract the possibly-empty tail of the stream. (Extract the last element of the stream. :Extract everything except the last element of the stream. "Prepend an element to the stream. ! Synonym for  . "Sort a stream. #Converts a normal list to a  stream. (Raises an error if given an empty list. $/Convert a stream to a normal list efficiently. c"Lift list operations to work on a  stream. Beware2: If the provided function returns an empty list,  this will raise an error. %Map a function over a  stream. &The & function takes a stream xs and returns all the  finite prefixes of xs. 'The ' function takes a stream xs and returns all the  suffixes of xs. (( x xs inserts x into the last position in xs where it H is still less than or equal to the next element. In particular, if the < list is sorted beforehand, the result will also be sorted. )) is similar to d%, but returns a stream of successive  reduced values from the left:  D scanl f z [x1, x2, ...] == z :| [z `f` x1, (z `f` x1) `f` x2, ...]  Note that & last (scanl f z xs) == foldl f z xs. ** is the right-to-left dual of ).  Note that & head (scanr f z xs) == foldr f z xs. ++ is a variant of )& that has no starting value argument: F scanl1 f [x1, x2, ...] == x1 :| [x1 `f` x2, x1 `f` (x2 `f` x3), ...] ,, is a variant of *& that has no starting value argument. -'intersperse x xs'0 alternates elements of the list with copies of x. . intersperse 0 (1 :| [2,3]) == 1 :| [0,2,0,3] .. f x produces the infinite sequence  of repeated applications of f to x. ' iterate f x = x :| [f x, f (f x), ..] // xs$ returns the infinite repetition of xs: & cycle [1,2,3] = 1 :| [2,3,1,2,3,...] 00 a finite NonEmpty stream. 11 x3 returns a constant stream, where all elements are  equal to x. 22 n xs returns the first n elements of xs. 33 n xs drops the first n elements off the front of  the sequence xs. 44 n xs, returns a pair consisting of the prefix of xs  of length n= and the remaining stream immediately following this prefix. . 'splitAt' n xs == ('take' n xs, 'drop' n xs) 0 xs == ys ++ zs where (ys, zs) = 'splitAt' n xs 55 p xs* returns the longest prefix of the stream  xs for which the predicate p holds. 66 p xs$ returns the suffix remaining after  5 p xs. 77 p xs returns the longest prefix of xs that satisfies  p-, together with the remainder of the stream. 5 'span' p xs == ('takeWhile' p xs, 'dropWhile' p xs) - xs == ys ++ zs where (ys, zs) = 'span' p xs 8The 8 p function is equivalent to 7 (not . p). 99 p xs removes any elements from xs that do not satisfy p. :The : function takes a predicate p and a stream  xsA, and returns a pair of lists. The first list corresponds to the  elements of xs for which p& holds; the second corresponds to the  elements of xs for which p does not hold. ; 'partition' p xs = ('filter' p xs, 'filter' (not . p) xs) ;The ;/ function takes a stream and returns a list of A streams such that flattening the resulting list is equal to the 8 argument. Moreover, each stream in the resulting list ? contains only equal elements. For example, in list notation: f 'group' $ 'cycle' "Mississippi" = "M" : "i" : "ss" : "i" : "ss" : "i" : "pp" : "i" : "M" : "i" : ... << operates like ;!, but uses the provided equality  predicate instead of e. == operates like ;", but uses the knowledge that its < input is non-empty to produce guaranteed non-empty output. >> is to = as < is to ;. ?The isPrefix function returns True if the first argument is  a prefix of the second. @xs !! n# returns the element of the stream xs at index  n0. Note that the head of the stream has index 0. Beware9: a negative or out-of-bounds index will cause an error. AThe A4 function takes two streams and returns a stream of  corresponding pairs. BThe B function generalizes A. Rather than tupling < the elements, the elements are combined using the function  passed as the first argument. CThe C function is the inverse of the A function. DThe D/ function breaks a stream of characters into a 7 stream of words, which were delimited by white space. Beware3: if the input contains no words (i.e. is entirely ( whitespace), this will cause an error. EThe E% function is an inverse operation to D. It % joins words with separating spaces. Beware : the input ("" :| []) will cause an error. FThe F6 function breaks a stream of characters into a stream @ of strings at newline characters. The resulting strings do not  contain newlines. GThe G% function is an inverse operation to F. It = joins lines, after appending a terminating newline to each. 8 !"#$c%&'()*+,-./0123456789:;<=>?@ABCDEFGfghij2 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFG2%-)*+, !"0&'.1/(23456789:;<=>?@ABCDEFG#$7 !"#$c%&'()*+,-./0123456789:;<=>?@ABCDEFGfghijportable provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred HOption is effectively k with a better instance of , built off of an underlying Z  instead of an underlying F. Ideally, this type would not exist at all and we would just fix the  intance of k K-Provide a Semigroup for an arbitrary Monoid. NUse H (N a) -- to get the behavior of  QUse H (Q a) -- to get the behavior of  [An associative operation.   (a <> b) <> c = a <> (b <> c) If a is also a  we further require  (<>) = mappend \Reduce a non-empty list with <> XThe default definition should be sufficient, but this can be overridden for efficiency. ]Repeat a value (n + 1) times.  7 times1p n a = a <> a <> ... <> a -- using <> n times UThe default definition uses peasant multiplication, exploiting associativity to only  require O(log n) uses of <>.  See also times. ^A generalization of  to an arbitrary Z. ; May fail to terminate for some values in some semigroups. _Repeat a value n times.  9 times n a = a <> a <> ... <> a -- using <> (n-1) times Implemented using ]. a@This lets you use a difference list of a Semigroup as a Monoid. DHIJKLMNOPQRSTUVWXYZ[\]^_`almnopqrstuvwxyz{|}~0 HIJKLMNOPQRSTUVWXYZ[\]^_`a0Z[\]WXYTUVQRSNOPKLM_   HIJ`a^5HIJKLMNOPQRSTUVWXYZ[\]^_`almnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJJKLMNOPQQRSSTUVWXYZ[\]^_`abcdefghi]jklmnopqrstuvwxyz{|}~semigroups-0.9.2Data.SemigroupData.List.NonEmpty Data.MonoidLastFirst Data.ListcyclebasemconcatmappendmemptyMonoidgetDualDualappEndoEndogetAllAllgetAnyAnygetSumSum getProductProductNonEmpty:|xorunfoldnonEmptyunconsheadtaillastinit<|conssortfromListtoListmapinitstailsinsertscanlscanrscanl1scanr1 intersperseiteratereverserepeattakedropsplitAt takeWhile dropWhilespanbreakfilter partitiongroupgroupBygroup1groupBy1 isPrefixOf!!zipzipWithunzipwordsunwordslinesunlinesOption getOption WrappedMonoid WrapMonoid unwrapMonoidgetLastgetFirstMaxgetMaxMingetMin Semigroup<>sconcattimes1pcycle1timesNoptiondiff Data.MaybeNothinglift Data.Foldablefoldlghc-prim GHC.Classes==$fFoldableNonEmpty$fTraversableNonEmpty$fMonadNonEmpty$fApplicativeNonEmpty$fFunctorNonEmptyMaybe$fSemigroupMap$fSemigroupIntMap$fSemigroupSet$fSemigroupIntSet$fSemigroupSeq$fMonoidOption$fSemigroupOption$fTraversableOption$fFoldableOption$fMonadFixOption$fMonadPlusOption$fAlternativeOption $fMonadOption$fApplicativeOption$fFunctorOption$fMonoidWrappedMonoid$fSemigroupWrappedMonoid$fSemigroupLast$fSemigroupFirst $fMonoidMax$fSemigroupMax $fMonoidMin$fSemigroupMin$fSemigroupNonEmpty$fSemigroupLast0$fSemigroupFirst0$fSemigroupProduct$fSemigroupSum$fSemigroupAny$fSemigroupAll$fSemigroupEndo$fSemigroupDual$fSemigroupOrdering$fSemigroup(,,,,)$fSemigroup(,,,)$fSemigroup(,,)$fSemigroup(,)$fSemigroupEither$fSemigroupMaybe $fSemigroup[]$fSemigroup(->) $fSemigroup()