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