The pipe placeholder is really cool because it allows you to create specialised functions more quickly.
let splitAtSeparator = Js.String2.split(_, ";")
This works great! However, the next step would be to create a processing pipeline using the pipe operator, to compose functions together without having to declare a new function on the ReScript side.
let splitClean = Js.String2.split(_, ";")->Js.Array2.map(Js.String2.trim)
In theory this should work just as well, but unfortunately the compiler starts treating this as a function execution rather than as a composed function and produces the following error:
This expression should not be a function, the expected type is Js.Array2.t<'a>
The above example is a bit contrived, but it can clean up some nested code in case you're piping to things like Belt.Option.mapWithDefault which in turn would do some more nested processing. Coming up with intermediate variable names in those situations can be a chore.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
The pipe placeholder is really cool because it allows you to create specialised functions more quickly.
This works great! However, the next step would be to create a processing pipeline using the pipe operator, to compose functions together without having to declare a new function on the ReScript side.
In theory this should work just as well, but unfortunately the compiler starts treating this as a function execution rather than as a composed function and produces the following error:
The above example is a bit contrived, but it can clean up some nested code in case you're piping to things like
Belt.Option.mapWithDefault
which in turn would do some more nested processing. Coming up with intermediate variable names in those situations can be a chore.