1
1
---
2
2
author : rescript-team
3
- date : " 2025-04-05 "
3
+ date : " 2025-04-11 "
4
4
title : " Rethinking Operators: How ReScript Simplifies Arithmetic and Beyond"
5
5
badge : roadmap
6
6
description : |
@@ -40,9 +40,9 @@ Some operators are available only as functions. Instead of `<<` and `>>`, we use
40
40
ReScript has multiple "add operator" syntaxes for every primitive type.
41
41
42
42
``` res
43
- let add_int = 1 + 2
44
- let add_float = 1.0 +. 2.0
45
- let concat_string = "Hello" ++ ", World!"
43
+ let addInt = 1 + 2
44
+ let addFloat = 1.0 +. 2.0
45
+ let concatString = "Hello" ++ ", World!"
46
46
```
47
47
48
48
We ran into the same issue again when we added ` bigint ` support.
@@ -52,7 +52,7 @@ What other operator syntax could we introduce to add two bigint values? There we
52
52
It was inconvenient because we had to shadow the definition every time.
53
53
54
54
``` res
55
- let add_bigint = {
55
+ let addBigInt = {
56
56
open BigInt!
57
57
1n + 2n
58
58
}
@@ -124,8 +124,8 @@ More specifically, the following rules are added to the primitive translation pr
124
124
> Before handling a primitive, if the primitive operation matches the form of ` lhs -> rhs -> result ` or ` lhs -> result `
125
125
>
126
126
> 1 . If the ` lhs ` type is a primitive type, unify the ` rhs ` and the ` result ` type to the ` lhs ` type.
127
- > 2 . If the ` lhs ` type is not a primitive type but the ` rhs ` type is, unify ` lhs ` and the ` result ` type to the ` rhs ` type.
128
- > 3 . If both ` lhs ` type and ` rhs ` type is not a primitive type, unify the whole types to the ` int ` .
127
+ > 2 . If the ` lhs ` type is not a primitive type but the ` rhs ` type is, unify ` lhs ` and the ` result ` type to the ` rhs ` type.
128
+ > 3 . If both ` lhs ` type and ` rhs ` type is not a primitive type, unify the whole types to the ` int ` .
129
129
130
130
It changes the type inference like
131
131
0 commit comments