11---
22author : rescript-team
3- date : " 2025-04-05 "
3+ date : " 2025-04-11 "
44title : " Rethinking Operators: How ReScript Simplifies Arithmetic and Beyond"
55badge : roadmap
66description : |
@@ -40,9 +40,9 @@ Some operators are available only as functions. Instead of `<<` and `>>`, we use
4040ReScript has multiple "add operator" syntaxes for every primitive type.
4141
4242``` 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!"
4646```
4747
4848We 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
5252It was inconvenient because we had to shadow the definition every time.
5353
5454``` res
55- let add_bigint = {
55+ let addBigInt = {
5656 open BigInt!
5757 1n + 2n
5858}
@@ -124,8 +124,8 @@ More specifically, the following rules are added to the primitive translation pr
124124> Before handling a primitive, if the primitive operation matches the form of ` lhs -> rhs -> result ` or ` lhs -> result `
125125>
126126> 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 ` .
129129
130130It changes the type inference like
131131
0 commit comments