package preface

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Preface_stdlib.StreamSource

Implementation for Stream.t.

A Stream.t is an infinite lazy list.

Type

Sourcetype 'a t

Implementation

Functor

module Functor : Preface_specs.FUNCTOR with type 'a t = 'a t

Applicative

module Applicative : Preface_specs.APPLICATIVE with type 'a t = 'a t

Monad

module Monad : Preface_specs.MONAD with type 'a t = 'a t

Comonad

module Comonad : Preface_specs.COMONAD with type 'a t = 'a t

Invariant

module Invariant : Preface_specs.INVARIANT with type 'a t = 'a t

Additional functions

Additional functions to facilitate practical work with Stream.t.

Sourceval pure : 'a -> 'a t

Create a value from 'a to 'a t.

Sourceval repeat : 'a -> 'a t

Alias of pure. repeat x creates a stream filled with x.

Sourceval stream : 'a -> 'a t Lazy.t -> 'a t

Build a stream manually.

Sourceval cons : 'a -> 'a t -> 'a t

Alias of stream.

Sourceval hd : 'a t -> 'a

Get the head of the stream. Since Stream.t are infinite, hd can not fail (without values). For each stream, we have an head.

Sourceval tl : 'a t -> 'a t

Get the tail of the stream. Like hd, since Stream.t are infinite, the function can not fail. For each stream, we have a tail.

Sourceval at : int -> 'a t -> 'a Try.t

Get the value at given position. at 10 (naturals) gives Ok 9. The function may fail if the position if negative.

Sourceval drop : int -> 'a t -> 'a t Try.t

drop n stream drop the nth values of the stream. The function may fail if the position if negative.

Sourceval take : int -> 'a t -> 'a list Try.t

take n stream returns the firsts n elements of stream as list.

Sourceval take_while : ('a -> bool) -> 'a t -> 'a list

take_while p stream returns all first elements of stream as list satisfying the predicate p. Be careful, the function may diverge if every element of the stream are satisfying the predicate p.

Sourceval drop_while : ('a -> bool) -> 'a t -> 'a t

drop_while p stream drop all first elements of stream satisfying the predicate p. Be careful, the function may diverge if every element of the stream are satisfying the predicate p.

infix operators

Sourcemodule Infix : sig ... end
Sourceval (<:>) : 'a -> 'a t -> 'a t

Infix version of cons

Sourceval (.%[]) : 'a t -> int -> 'a Try.t

Flipped version of at.

OCaml

Innovation. Community. Security.