Data Types¶
ImmutableContext¶
An ImmutableContext() wraps Sweet’s underlying mutable context in an immutable representation. Basically, it calls mark and reset so you don’t have to.
-
class
ImmutableContext(ctx)¶ With type parameter
A, the value returned by the underlyingcontext(currently this is always aTerm).Import the
ImmutableContext()class via:import { ImmutableContext } from '@sweet-js/helpers/parser';
Arguments: - ctx – The transformer context provided by a macro.
ImmutableContext()provides a list-like interface; call :meth:`head` to get the next value (wrapped in aMaybesince the context might be empty) and :meth:`rest` to get the rest.
Either¶
An fantasy-land compatible implementation of the Either data type.
-
class
Either()¶ With type parameters
LandRforLeft()andRight(), respectively.Import the
Either()class via:import { Either } from '@sweet-js/helpers/either';
The static methods of
Either()are:The prototype methods of
Either()are:
Maybe¶
An fantasy-land compatible implementation of the Maybe data type.
-
class
Maybe()¶ With type parameter
A.Import the
Maybe()class via:import { Maybe } from '@sweet-js/helpers/maybe';
The static methods of
Maybe()are:The prototype mehtods of
Maybe()are: