Want a `mod` function out of the box

I wanted to get a reminder of a number, but I just couldn’t find a proper way how to do it in ReScript. We can’t use a % and also there is no a mod operator as it was in Reason. Although it’s possible to write a function for it, I’d prefer to have it out of the box.

mod is a function in ReScript: let x = mod(5, 3)

3 Likes

Oh, you’re right, but I’ve read all the doc and haven’t been able to find any word about it.

It’s mentioned here: https://rescript-lang.org/docs/manual/latest/overview#number

I’ve forgotten about the place. I was looking at these places:

  • /rescript-lang.org/docs/manual/latest/api/belt/int
  • /rescript-lang.org/docs/manual/latest/api/belt/float
  • /rescript-lang.org/docs/manual/latest/api/js/int
  • /rescript-lang.org/docs/manual/latest/api/js/float
  • /rescript-lang.org/docs/manual/latest/primitive-types#floats
    I even tried to find it in the Math module in some reason.
    Also it was impossible to find it via doc search. Google didn’t give me anything either.

Yeah, mod is currently part of the Pervasives module, which is not yet covered in our docs. It will be part of the docs as soon as we start extracting documentation from our core modules.

1 Like

Got it :slight_smile: But for me as a newcomer tooling seems much more important. It’s extremely difficult to dive into the new type system without this https://github.com/rescript-lang/rescript-vscode/issues/12#issuecomment-717268523. It fills almost like you’re blind.

1 Like