(* on Mappable *)
val replace : 'a t -> with:'b -> 'b t
let replace x ~with = map x ~f:(Fn.const with)
(* on Traversable with monad M *)
val replace_m : 'a t -> with:('b M.t) -> 'b t M.t
let replace_m x ~with = map_m x ~f:(M.return with)
This is simple syntactic sugar, but would make code where one is trying to use a Mappable to punch out a value in a container and replace it with a new value slightly nicer.
Add to
Mappable.SX
:This is simple syntactic sugar, but would make code where one is trying to use a
Mappable
to punch out a value in a container and replace it with a new value slightly nicer.