Lambda Discipline

Examples

Annotated higher-order functions

tests/golden/programs/complex_typing.lbd

pipe : (a -> b) -> (b -> c) -> a -> c = \f. \g. \x. (g (f x))
twice : (a -> a) -> a -> a = \f: (a -> a). \x: a. (f (f x))

addFive : Number -> Number = \x. (add x 5)
double : Number -> Number = \x. (mul x 2)

pipeline : Number -> Number = (pipe addFive double)
quadruple : Number -> Number = (twice double)

(println (pipeline 3))
(println (quadruple 3))
(println ((pipe show (concat "value: ")) 7))

Output

16
12
value: 7

Run it yourself from the repository root: lbd run tests/golden/programs/complex_typing.lbd