wrap

class pythonic_fp.gadgets.wrap.Wrap(item: T)

Immutablely wrap exactly one value of a given type.

Tip

Wrap objects can be used in Python match statements.

__init__(item: T) None
__repr__() str

Return repr(self).

__eq__(other: object) bool

Efficiently compare to another object.

Parameters:

other – The object to be compared with,

Returns:

True if other is of type Wrap and wraps an object which compares as equal to the wrapped object, otherwise False.

map(f: Callable[[T], U]) Wrap

Map function f over contents.

Parameters:

f – Mapping function.

Returns:

A new instance.

bind(f: Callable[[T], Wrap]) Wrap

Flatmap the Wrap with function f.

Parameters:

f – Binding function.

Returns:

A new instance.

class pythonic_fp.gadgets.wrap.HWrap(item: T)

Immutablely wrap exactly one hashable value of a given type.

Tip

HWrap objects can be used in Python match statements.

Tip

HWrap objects are hashable..

__init__(item: T) None
__hash__() int

Return hash(self).

__repr__() str

Return repr(self).

__eq__(other: object) bool

Efficiently compare to another object.

Parameters:

other – The object to be compared with,

Returns:

True if other is of type HWrap and wraps an object which compares as equal to the wrapped object, otherwise False.

map(f: Callable[[T], U]) HWrap

Map function f over contents.

Parameters:

f – Mapping function.

Returns:

A new instance.

bind(f: Callable[[T], HWrap]) HWrap

Flatmap the Wrap with function f.

Parameters:

f – Binding function.

Returns:

A new instance.