Cons

fun interface Cons<S, A>(source)

Cons provides a Prism between S and its first element A and tail S. It provides a convenient way to attach or detach elements to the left side of a structure S.

Parameters

S

source of Prism and tail of Prism focus.

A

first element of Prism focus, A is supposed to be unique for a given S.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun cons(): Prism<S, Pair<A, S>>

Provides a Prism between S and its first element A and tail S.

open infix fun A.cons(tail: S): S

Prepend an element A to the first element of S.

Link copied to clipboard
open fun firstOption(): Optional<S, A>

Provides an Optional between S and its first element A.

Link copied to clipboard
open fun tailOption(): Optional<S, S>

Provides an Optional between S and its tail S.

Link copied to clipboard
open fun S.uncons(): Pair<A, S>?

Deconstruct an S to its optional first element A and tail S.