std.stream
Lazy stream type.
Types
Values
Takes the first n
elements of xs
.
let { ? } = import! std.effect
let stream @ { take, repeat, empty, ? } = import! std.stream
let { assert_eq, ? } = import! std.test
seq assert_eq (take 0 (repeat "abc")) empty
assert_eq (take 3 (repeat 1)) (stream.of [1, 1, 1])
Checks if the stream is empty
let stream = import! std.stream
let { assert_eq } = import! std.test
assert_eq (stream.is_empty stream.empty) True
Converts the Stream
to a List
let stream = import! std.stream
let list @ { ? } = import! std.list
let { assert_eq } = import! std.test
assert_eq (stream.to_list (stream.of ["a", "b"])) (list.of ["a", "b"])
Eq a
defines equality (==) on a
Ord a
defines an ordering on a
Show a
represents a conversion function from a
to a readable string.
A Functor
represents an action on a parameterized type which does not
change the structure with the mapped type.
The following laws should hold:
map id == id
map (f << g) == map f << map g
Operations over a data structure that can be folded which means that a functions gets called on
each element to reduce the structure to a single value (Array
, List
and Map
are all Foldable
)
Monoid a
represents an semigroup an which has an identity. This means
the following additional laws must hold:
forall x . append x empty == x
forall x . append empty x == x
Semigroup a
represents an associative operation on a
.
This means the following laws must hold:
forall x . append x (append y z) == append (append x y) z