Add overloads for |> to value types that wrap functions #165
JaapWijnen
started this conversation in
Ideas
Replies: 1 comment
-
Thanks for bringing this up! This is relevant to #155, I believe. I'm going to convert to a discussion, since we probably won't address directly in this repo anytime soon, but welcome discussion for downstream users/forks. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Would it make sense to add overloads for
|>
to types likeFunc
andEndo
(Maybe others, I've mainly used these).This would clean up the call site since these types represent functions anyway. Then we don't have to call
.call
or.apply
anymoregiven:
let increment = Endo<Int> { value in value + 1 }
before:
let result = 5 |> increment.call
with overloads:
let result = 5 |> increment
This is not too bad ofcourse but it's really nice when chaining methods for example:
let result = 5 |> increment <> square <> increment
Would have to be wrapped in parentheses:
let result = 5 |> (increment <> square <> increment).call
Maybe this also applies to a few other types? I'd gladly add them if you think this would make sense :)
Maybe it also applies to
Parallel
?Beta Was this translation helpful? Give feedback.
All reactions