Skip to content

Commit 04f2c2c

Browse files
committed
Clean up isSwap
1 parent 1aaae74 commit 04f2c2c

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed

res_syntax/src/res_core.ml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ let buildLongident words =
386386
let makeInfixOperator (p : Parser.t) token startPos endPos =
387387
let stringifiedToken =
388388
if token = Token.MinusGreater then
389-
if p.uncurried_config |> Res_uncurried.isSwap then "|.u" else "|."
389+
if p.uncurried_config = Legacy then "|." else "|.u"
390390
else if token = Token.PlusPlus then "^"
391391
else if token = Token.BangEqual then "<>"
392392
else if token = Token.BangEqualEqual then "!="
@@ -1558,8 +1558,7 @@ and parseEs6ArrowExpression ?(arrowAttrs = []) ?(arrowStartPos = None) ?context
15581558
| TermParameter {dotted} :: _
15591559
when p.uncurried_config |> Res_uncurried.fromDotted ~dotted && isFun ->
15601560
true
1561-
| TermParameter _ :: rest
1562-
when (not (p.uncurried_config |> Res_uncurried.isSwap)) && isFun ->
1561+
| TermParameter _ :: rest when p.uncurried_config = Legacy && isFun ->
15631562
rest
15641563
|> List.exists (function
15651564
| TermParameter {dotted} -> dotted
@@ -1594,11 +1593,7 @@ and parseEs6ArrowExpression ?(arrowAttrs = []) ?(arrowStartPos = None) ?context
15941593
let uncurried =
15951594
p.uncurried_config |> Res_uncurried.fromDotted ~dotted
15961595
in
1597-
if
1598-
uncurried
1599-
&& (termParamNum = 1
1600-
|| not (p.uncurried_config |> Res_uncurried.isSwap))
1601-
then
1596+
if uncurried && (termParamNum = 1 || p.uncurried_config = Legacy) then
16021597
(termParamNum - 1, Ast_uncurried.uncurriedFun ~loc ~arity funExpr, 1)
16031598
else (termParamNum - 1, funExpr, arity + 1)
16041599
| TypeParameter {dotted = _; attrs; locs = newtypes; pos = startPos} ->
@@ -3922,9 +3917,8 @@ and parsePolyTypeExpr p =
39223917
let returnType = parseTypExpr ~alias:false p in
39233918
let loc = mkLoc typ.Parsetree.ptyp_loc.loc_start p.prevEndPos in
39243919
let tFun = Ast_helper.Typ.arrow ~loc Asttypes.Nolabel typ returnType in
3925-
if p.uncurried_config |> Res_uncurried.isSwap then
3926-
Ast_uncurried.uncurriedType ~loc ~arity:1 tFun
3927-
else tFun
3920+
if p.uncurried_config = Legacy then tFun
3921+
else Ast_uncurried.uncurriedType ~loc ~arity:1 tFun
39283922
| _ -> Ast_helper.Typ.var ~loc:var.loc var.txt)
39293923
| _ -> assert false)
39303924
| _ -> parseTypExpr p
@@ -4252,7 +4246,7 @@ and parseEs6ArrowType ~attrs p =
42524246
let endPos = p.prevEndPos in
42534247
let returnTypeArity =
42544248
match parameters with
4255-
| _ when p.uncurried_config |> Res_uncurried.isSwap -> 0
4249+
| _ when p.uncurried_config <> Legacy -> 0
42564250
| _ ->
42574251
if parameters |> List.exists (function {dotted; typ = _} -> dotted)
42584252
then 0
@@ -4266,10 +4260,7 @@ and parseEs6ArrowType ~attrs p =
42664260
let uncurried =
42674261
p.uncurried_config |> Res_uncurried.fromDotted ~dotted
42684262
in
4269-
if
4270-
uncurried
4271-
&& (paramNum = 1 || not (p.uncurried_config |> Res_uncurried.isSwap))
4272-
then
4263+
if uncurried && (paramNum = 1 || p.uncurried_config = Legacy) then
42734264
let loc = mkLoc startPos endPos in
42744265
let tArg = Ast_helper.Typ.arrow ~loc ~attrs argLbl typ t in
42754266
(paramNum - 1, Ast_uncurried.uncurriedType ~loc ~arity tArg, 1)
@@ -4334,9 +4325,8 @@ and parseArrowTypeRest ~es6Arrow ~startPos typ p =
43344325
let returnType = parseTypExpr ~alias:false p in
43354326
let loc = mkLoc startPos p.prevEndPos in
43364327
let arrowTyp = Ast_helper.Typ.arrow ~loc Asttypes.Nolabel typ returnType in
4337-
if p.uncurried_config |> Res_uncurried.isSwap then
4338-
Ast_uncurried.uncurriedType ~loc ~arity:1 arrowTyp
4339-
else arrowTyp
4328+
if p.uncurried_config = Legacy then arrowTyp
4329+
else Ast_uncurried.uncurriedType ~loc ~arity:1 arrowTyp
43404330
| _ -> typ
43414331

43424332
and parseTypExprRegion p =

res_syntax/src/res_uncurried.ml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
let isSwap = function
2-
| Config.Legacy -> false
3-
| Swap -> true
4-
| Uncurried -> true
5-
61
(* For parsing *)
72
let fromDotted ~dotted = function
83
| Config.Legacy -> dotted

0 commit comments

Comments
 (0)