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 : Int -> Int = \x. (add x 5)
double : Int -> Int = \x. (mul x 2)

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

(println (show (pipeline 3)))
(println (show (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