No matching definitions.

tur/fix

stdlib/fix.tur

Fix type: the fixed-point of a functor, with cata and ana.

Since: Phase B1

defdata

Fix

(defdata Fix [^f] (Roll))

the fixed-point type of a functor.

defn

roll

(roll [layer : int])

wrap one layer of f into a Fix value.

layera value of type (f (Fix f))

A Fix value wrapping layer.

(roll my-layer)  ; => (Roll my-layer)

Since: Phase RF2

defn

unroll

(unroll [fix : int])

unwrap one layer of Fix to expose the inner functor value.

fixa Fix value

The inner f (Fix f) value.

(unroll (roll x))  ; => x

Since: Phase RF2

defn

cata

(cata [alg : fn fix : int] :)

catamorphism: fold a Fix value using an F-algebra.

alga typed fat-closure (function from (f a) to a) stored as :fn
fixa Fix value to fold

The result of applying alg to the unwrapped layer.

(cata my-alg leaf-fix)

Since: Phase RF2

defn

ana

(ana [coalg : fn seed : int] :)

anamorphism: unfold a seed value into a Fix value using a co-algebra.

coalga typed fat-closure (function from a to (f a)) stored as :fn
seedthe initial seed value

A Fix value built by applying coalg to seed.

(ana my-coalg seed-value)

Since: Phase RF2