std.stream

Lazy stream type.

Types

type Stream a = Lazy (std.stream.Stream_ a)

Values

let empty : forall a . std.stream.Stream a

let from f : forall a . (Int -> std.types.Option a) -> std.stream.Stream a

let of xs : forall a . Array a -> std.stream.Stream a

let repeat x : forall a . a -> std.stream.Stream a

let take n xs : forall a . Int -> std.stream.Stream a -> std.stream.Stream a

Takes the first n elements of xs.

let stream @ { take, repeat, empty, ? } = import! std.stream
let { assert } = import! std.test

assert (take 0 (repeat "abc") == empty)
assert (take 3 (repeat 1) == stream.of [1, 1, 1])

let next stream : forall a . std.stream.Stream a -> std.types.Option a

let is_empty stream : forall a . std.stream.Stream a -> std.types.Bool

Checks if the stream is empty

let stream = import! std.stream
let { assert } = import! std.test

assert (stream.is_empty stream.empty)

let to_list : forall a . std.stream.Stream a -> std.list.List a

Converts the Stream to a List

let stream = import! std.stream
let list @ { ? } = import! std.list
let { assert } = import! std.test

assert (stream.to_list (stream.of ["a", "b"]) == list.of ["a", "b"])

let zip_with f xs ys : forall a a0 a1 .
    (a -> a0 -> a1)
        -> std.stream.Stream a
        -> std.stream.Stream a0
        -> std.stream.Stream a1

let eq ?eq : forall a . [std.cmp.Eq a] -> std.cmp.Eq (std.stream.Stream a)

Eq a defines equality (==) on a

let ord ?ord : forall a . [std.cmp.Ord a] -> std.cmp.Ord (std.stream.Stream a)

Ord a defines an ordering on a

let show ?d : forall a . [std.show.Show a] -> std.show.Show (std.stream.Stream a)

Show a represents a conversion function from a to a readable string.

let functor : std.functor.Functor std.stream.Stream

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

let foldable : std.foldable.Foldable std.stream.Stream

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)

let monoid : forall a . std.monoid.Monoid (std.stream.Stream a)

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

let semigroup : forall a . std.semigroup.Semigroup (std.stream.Stream a)

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