No matching definitions.

tur/typeclass-alternative

stdlib/typeclass-alternative.tur

minimal Alternative typeclass stub.

Loaded by schema.tur (and loadable directly) so a module can declare (definstance Alternative [...] ...) without importing the full typeclass.tur. The full typeclass.tur (with every typeclass) is still available on demand via (load "stdlib/typeclass.tur").

Since: Phase SC7

defclass

Alternative

(defclass Alternative [^f] [(Applicative f)])

an Applicative with a failure value and a first-success choice.

^fthe container's type constructor (kind * -> *)
(empty [a] :(f a))

the failing/empty value -- none for Option. a only picks the instance; it is not read.

(alt-or [x :(f a) y :(f a)] :(f a))

x if it succeeded, else y -- the first some, the first parse that matched.

(alt-or (empty w) x)        = x
(alt-or x (empty w))        = x
(alt-or (alt-or x y) z)     = (alt-or x (alt-or y z))
(unwrap-or (alt-or (none) (some 7)) 0)   ; => 7

Superclass: Applicative.

Since: Phase HKT H7