śĪ.włf
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdeportableprovisionalEdward Kmett <ekmett@gmail.com>
Safe-Inferred2< 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 f instead of
$ a new seed value, the stream ends.
( efficiently turns a normal list into a stream,
producing f 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.
g"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 h%, 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]
00 f x produces the infinite sequence
of repeated applications of f to x.
' iterate f x = x :| [f x, f (f x), ..]
11 xs$ returns the infinite repetition of xs:
& cycle [1,2,3] = 1 :| [2,3,1,2,3,...]
22 a finite NonEmpty stream.
33 x3 returns a constant stream, where all elements are
equal to x.
44 n xs returns the first n
elements of xs.
55 n xs drops the first n elements off the front of
the sequence xs.
66 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
77 p xs* returns the longest prefix of the stream
xs for which the predicate p holds.
88 p xs$ returns the suffix remaining after
7 p xs.
99 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
:The : p function is equivalent to 9
(not . p).
;; 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 i.
?? operates like =", but uses the knowledge that its
< input is non-empty to produce guaranteed non-empty output.
@@ is to ? as > is to =.
AThe isPrefix function returns True if the first argument is
a prefix of the second.
Bxs !! 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.
CThe C4 function takes two streams and returns a stream of
corresponding pairs.
DThe D function generalizes C. Rather than tupling
< the elements, the elements are combined using the function
passed as the first argument.
EThe E function is the inverse of the C function.
FThe F/ 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.
GThe G% function is an inverse operation to F. It
% joins words with separating spaces.
Beware: the input ("" :| []) will cause an error.
HThe H6 function breaks a stream of characters into a stream
@ of strings at newline characters. The resulting strings do not
contain newlines.
IThe I% function is an inverse operation to H. It
= joins lines, after appending a terminating newline to each.
JThe J5 function removes duplicate elements from a list. In
@ particular, it keeps only the first occurence of each element.
(The name J means 'essence'.)
It is a special case of K!, which allows the programmer to
# supply their own inequality test.
KThe K function behaves just like J, except it uses a
< user-supplied equality predicate instead of the overloaded i
function.
< !"#$%&g'()*+,-./0123456789:;<=>?@ABCDEFGHIJKjklmn6 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJK6'/+,-. !"#$2()031*456789:;<=>?@AJKBCDEFGHI%&; !"#$%&g'()*+,-./0123456789:;<=>?@ABCDEFGHIJKjklmnportableprovisionalEdward Kmett <ekmett@gmail.com>TrustworthyLOption is effectively o with a better instance of , built off of an underlying ^
instead of an underlying F. Ideally, this type would not exist at all and we would just fix the intance of o
O-Provide a Semigroup for an arbitrary Monoid.
RUse L (R a) to get the behavior of from Data.Monoid
UUse L (U a) to get the behavior of from Data.Monoid.
_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.
aRepeat 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.
bA generalization of to an arbitrary ^.
; May fail to terminate for some values in some semigroups.
cRepeat a value n times.
9 times n a = a <> a <> ... <> a -- using <> (n-1) times
Implemented using a.
dFold an L case-wise, just like p.
e@This lets you use a difference list of a Semigroup as a Monoid.
JLMNOPQRSTUVWXYZ[\]^_`abcdeqrstuvwxyz{|}~
0
LMNOPQRSTUVWXYZ[\]^_`abcde0^_`a[\]XYZUVWRSTOPQc
LMNdeb;LMNOPQRSTUVWXYZ[\]^_`abcdeqrstuvwxyz{|}~
”
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNNOPQRSTUUVWWXYZ[\]^_`abcdefghijklmanaopqrstuvwxyz{|}~
semigroups-0.11Data.SemigroupData.List.NonEmptyData.MonoidLastFirst Data.ListcyclebasemconcatmappendmemptyMonoidgetDualDualappEndoEndogetAllAllgetAnyAnygetSumSum
getProductProductNonEmpty:|lengthxorunfoldnonEmptyunconsunfoldrheadtaillastinit<|conssortfromListtoListmapinitstailsinsertscanlscanrscanl1scanr1intersperseiteratereverserepeattakedropsplitAt takeWhile dropWhilespanbreakfilter partitiongroupgroupBygroup1groupBy1
isPrefixOf!!zipzipWithunzipwordsunwordslinesunlinesnubnubByOption getOption
WrappedMonoid
WrapMonoidunwrapMonoidgetLastgetFirstMaxgetMaxMingetMin Semigroup<>sconcattimes1pcycle1timesNoptiondiff
Data.MaybeNothinglift
Data.Foldablefoldlghc-primGHC.Classes==$fFoldableNonEmpty$fTraversableNonEmpty$fMonadNonEmpty$fApplicativeNonEmpty$fFunctorNonEmptyMaybemaybe$fSemigroupMap$fSemigroupIntMap$fSemigroupSet$fSemigroupIntSet$fSemigroupSeq$fMonoidOption$fSemigroupOption$fTraversableOption$fFoldableOption$fMonadFixOption$fMonadPlusOption$fAlternativeOption
$fMonadOption$fApplicativeOption$fFunctorOption$fMonoidWrappedMonoid$fSemigroupWrappedMonoid$fSemigroupHashSet$fSemigroupHashMap$fSemigroupText$fSemigroupText0$fSemigroupByteString$fSemigroupByteString0$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()