No matching definitions.

tur/typeclass-functor

stdlib/typeclass-functor.tur

minimal Functor typeclass stub for typed-collection definstances.

Auto-loaded so list, vec, and other typed-collection modules can declare (definstance Functor [...] ...) without importing typeclass.tur.

Since: Phase TS5

defclass

Functor

(defclass Functor [^f])

map a function over every element of a container, keeping its shape.

^fthe container's type constructor (kind * -> *): Option, Cons,
(Result _ B), Parser, ...
(fmap [container :(f a) g :(fn [a] b)] :(f b))

a container of the same shape as container with g applied to each element. g is a :fn carrier (tur_poly_fn_t), so a capturing closure can be passed directly.

(fmap c (fn [x] x))      = c
(fmap (fmap c g) h)      = (fmap c (fn [x] (h (g x))))
(unwrap-or (fmap (some 20) (fn [x : int] : int (+ x 1))) 0)   ; => 21

Since: Phase CCL