-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kleisli Composition Operator and Apply_or Added #455
Conversation
Added the Kleisli composition operator for Option, Result, and CCFun.
Gave up on k_compose for CCFun. Unclear with how to translate function signature into CPS.
Added apply_or for chaining processing functions.
Updated PR to remove CCFun changes, added slight documentation to CCFun, and added a new apply_or function. |
@@ -111,6 +116,13 @@ let get_or ~default x = | |||
| None -> default | |||
| Some y -> y | |||
|
|||
let apply_or f x = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't that fold
? edit: oh, no, same default value…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was motivated mostly by seeing places where CCString functions were being stringed together, combined with repeated CCOption's get_or
to reset back to the original string if the string functions failed. Particularly the operator form would concisely shrink down that sort of pipeline to just the string functions.
Formatting had to be done manually due to mismatching ocamlformat installations.
CHANGES: - predicate combinators: `and_pred` and `or_pred` - feat `pp`: add a bunch of extensions - Kleisli Composition Operator and Apply_or for option/result/fun (c-cube/ocaml-containers#455) - add `CCByte_buffer.to_slice` - add a byte slice type `CCByte_slice` - add `cons_when` to `CCListLabels` - add `(|||>)` and `||>` to `CCFun` - `CCVector`: Add function foldi - add `containers.pvec`, a persistent vector type. - perf: use a monomorphic impl for `CCMonomorphic.{min,max}`
Added the Kleisli composition operator for Option, Result, and CCFun.