fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.
Fuzion
•
Idioms
•
Idiom # 35: First-class function : compose
Idiom # 35: First-class function : compose
See
programming-idioms.org
:
Code
Using manual function composition:
Code input
compose(f A -> B, g B -> C) A -> C => a -> g (f a)
What are effects?
Using
Unary.infix ∘
:
Code input
compose(f A -> B, g B -> C) A -> C => a -> g (f a)
What are effects?
Runnable Example
Using manual function composition:
Code input
ex35 is A(val i64) is B(val bool) is C(val String) is compose(f A -> B, g B -> C) A -> C => a -> g (f a) my_f A -> B := a -> B (a.val > 3) my_g B -> C := b -> C (if b.val then "T" else "F") fog := compose my_f my_g say (fog (A 10)).val say (fog (A 2)).val say (fog (A 0)).val
What are effects?
Using
Unary.infix ∘
:
Code input
ex35a is A(val i64) is B(val bool) is C(val String) is f A -> B := a -> B (a.val > 3) g B -> C := b -> C (if b.val then "T" else "F") fog := g ∘ f say (fog (A 10)).val say (fog (A 2)).val say (fog (A 0)).val
What are effects?
last changed: 2026-09-23
next: Idiom # 36: First-class function : generic composition