Skip to content

Commit ff6002d

Browse files
committed
Prelude: + Fresh.map{,2}
the name is somewhat meh
1 parent ac7d140 commit ff6002d

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

prelude.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ struct
3535
let project_list = id
3636
let compare = T.compare
3737
let equal a b = T.compare a b = 0
38+
let map f x = inject @@ f @@ project x
39+
let map2 f x y = inject @@ f (project x) (project y)
3840
end
3941

4042
let (+=) a b = a := !a + b

prelude.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ sig
6161
val project_list : t list -> T.t list
6262
val compare : t -> t -> int
6363
val equal : t -> t -> bool
64+
val map : (T.t -> T.t) -> t -> t
65+
val map2 : (T.t -> T.t -> T.t) -> t -> t -> t
6466
end
6567

6668
val tuck : 'a list ref -> 'a -> unit

0 commit comments

Comments
 (0)