ReScript function composition

Hi, is there any other function composition operators except -> ?
For example, I’m looking for >> operator (like in F#)

Could you please provide more function composition examples?
Thnaks a lot!


There’s no function composition operator in rescript.
You can define your own if you use legacy syntax but custom infix ops are not supported by rescript.

this is reason syntax for example:
let (>>) = (f,g,x) => g(f(x));
note that there’s a runtime cost when you use this. I think it’s better to stick with -> which is a syntax transform.


Thanks for clarification!

Wasn’t a subset of infix operators going to be supported? If so, >> is a pretty common one so maybe it will be included.


The cost comes from the composition of high order function and curried by default – (the compiler can not infer the arity of f, g since we don’t see the source).
If you use uncurried style, the cost is affordable.

let (>>) = (. f,g,x) => g(. f(. x));

This doesn’t seem to work:

let succ2 = succ >> succ;


This is an uncurried BuckleScript function. It must be applied with a dot.

Like this: foo(. a, b)
Not like this: foo(a, b)

But admittedly I’m checking in the Reason Playground. Perhaps this has been fixed in the latest ReScript?

indeed. the closet thing is

let (>>) = ( f,g,x) => g(. f(. x));

let u = ((.x)=> x+1)>>((.x)=>x + 1);