std:Function
lib/Function.omg
lib/Function.omg45 lines
1{- Functions on functions.
2
3 Everything here is universe polymorphic: the level arguments are implicit
4 and inferred from the types the functions are used at.
5-}
6
7let id
8 : forall {l : Level} {a : Type l} -> a -> a
9 = \x -> x
10
11let const
12 : forall {la lb : Level} {a : Type la} {b : Type lb} -> a -> b -> a
13 = \x _ -> x
14
15-- compose g f x = g (f x)
16let compose
17 : forall {la lb lc : Level} {a : Type la} {b : Type lb} {c : Type lc}
18 -> (b -> c)
19 -> (a -> b)
20 -> a
21 -> c
22 = \g f x -> g (f x)
23
24-- pipe f g x = g (f x): composition in the order the functions are applied.
25let pipe
26 : forall {la lb lc : Level} {a : Type la} {b : Type lb} {c : Type lc}
27 -> (a -> b)
28 -> (b -> c)
29 -> a
30 -> c
31 = \f g x -> g (f x)
32
33let flip
34 : forall {la lb lc : Level} {a : Type la} {b : Type lb} {c : Type lc}
35 -> (a -> b -> c)
36 -> b
37 -> a
38 -> c
39 = \f y x -> f x y
40
41let apply
42 : forall {la lb : Level} {a : Type la} {b : Type lb} -> (a -> b) -> a -> b
43 = \f x -> f x
44
45in { id, const, compose, pipe, flip, apply }