Skip to content

Commit

Permalink
Work around the last of the uncurried issues. Fixes #22.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSpyder committed Dec 18, 2023
1 parent 013c6c7 commit 443d00a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Changed-20231219-095815.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Added
body: The `Event` module now includes 2 and 3 argument variants of `fromString` and `fromSymbol`
for use ReScript 11 uncurried mode
time: 2023-12-19T09:58:15.397871+11:00
custom:
GithubIssue: "22"
3 changes: 1 addition & 2 deletions bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@
"warnings": {
"number": "A-4-40-41-42-43-44+101-102-103",
"error": "false"
},
"uncurried": false
}
}
10 changes: 9 additions & 1 deletion src/Event.res
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@
")
type t<'listener, 'ty>
external fromString: string => t<'a => 'b, 'ty> = "%identity"
external fromString2: string => t<('a, 'b) => 'c, 'ty> = "%identity"
external fromString3: string => t<('a, 'b, 'c) => 'd, 'ty> = "%identity"
external fromSymbol: Js.Types.symbol => t<'a => 'b, 'ty> = "%identity"
external fromSymbol2: Js.Types.symbol => t<('a, 'b) => 'c, 'ty> = "%identity"
external fromSymbol3: Js.Types.symbol => t<('a, 'b, 'c) => 'd, 'ty> = "%identity"
external unsafeToString: t<'a => 'b, 'ty> => string = "%identity"
external unsafeToString2: t<('a, 'b) => 'c, 'ty> => string = "%identity"
external unsafeToString3: t<('a, 'b, 'c) => 'd, 'ty> => string = "%identity"
external unsafeToSymbol: t<'a => 'b, 'ty> => Js.Types.symbol = "%identity"
external unsafeToSymbol2: t<('a, 'b) => 'c, 'ty> => Js.Types.symbol = "%identity"
external unsafeToSymbol3: t<('a, 'b, 'c) => 'd, 'ty> => Js.Types.symbol = "%identity"
type case =
| String(string)
| Symbol(Js.Types.symbol)
Expand All @@ -40,4 +48,4 @@ let eq = (event1, event2) =>
| ("string", "string") => Obj.magic(event1) === Obj.magic(event2)
| ("symbol", "symbol") => Obj.magic(event1) === Obj.magic(event2)
| _ => false
}
}
4 changes: 2 additions & 2 deletions test/module/EventEmitterTestLib.res
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ module Emitter1 = {
let symbol: Event.t<Js.Types.symbol => unit, t> = Event.fromSymbol(uniqueSymbol)
let text: Event.t<string => unit, t> = Event.fromString("text")
let integer: Event.t<int => unit, t> = Event.fromString("integer")
let textAndInteger: Event.t<(string, int) => unit, t> = Event.fromString("textAndInteger")
let textAndInteger: Event.t<(string, int) => unit, t> = Event.fromString2("textAndInteger")
}
}
}

0 comments on commit 443d00a

Please sign in to comment.