git.iko.soy/rowtype-yoga/purescript-playwright
on main help sign in
Fix bug in countArgs
commit37f1daa71013782d620f16a87c85be807ccdb0f4 authorVladimir Kalnitsky <klntsky@gmail.com> dateSun 1 Nov 2020, 13:46 (6 years ago) parent1bbb8d6
3 files changed+7−26
src/Playwright.purs+4−6 src/Playwright/Internal.js−1 src/Playwright/Internal.purs+3−19
src/Playwright.purs+4−6
@@ -51,17 +51,15 @@ launch
5151 :: forall o
5252 . Coercible o LaunchOptions
5353 => BrowserType -> o -> Aff Browser
54−launch bt opts =
55− affCall "launch" typeInfo bt opts
56− where
57− typeInfo _ = launch
54+launch =
55+ affCall "launch" \_ -> launch
5856
5957close
6058 :: forall x
6159 . Coercible x (Browser |+| BrowserContext |+| Page)
6260 => x -> Aff Unit
63−close x =
64− affCall "close" (\_ -> close) x
61+close =
62+ affCall "close" \_ -> close
6563
6664contexts :: Browser -> Effect (Array BrowserContext)
6765contexts =
src/Playwright/Internal.js−1
@@ -36,7 +36,6 @@ function effectfulGetter (property, n) {
3636
3737function affectfulGetter (property, argsCount, toAffE) {
3838 var args = [];
39−
4039 return function (object) {
4140 function effectRunner () {
4241 return object[property].apply(object, args);
src/Playwright/Internal.purs+3−19
@@ -16,24 +16,8 @@ import Control.Promise
1616class NumberOfArgs x where
1717 numberOfArgs :: Proxy x -> Int
1818
19−-- More may be added later...
20−instance numberOfArgsFunction6 :: NumberOfArgs (a -> b -> c -> d -> e -> f -> g) where
21− numberOfArgs _ = 6
22−
23−else instance numberOfArgsFunction5 :: NumberOfArgs (a -> b -> c -> d -> e -> f) where
24− numberOfArgs _ = 5
25−
26−else instance numberOfArgsFunction4 :: NumberOfArgs (a -> b -> c -> d -> e) where
27− numberOfArgs _ = 4
28−
29−else instance numberOfArgsFunction3 :: NumberOfArgs (a -> b -> c -> d) where
30− numberOfArgs _ = 3
31−
32−else instance numberOfArgsFunction2 :: NumberOfArgs (a -> b -> c) where
33− numberOfArgs _ = 2
34−
35−else instance numberOfArgsFunction1 :: NumberOfArgs (a -> b) where
36− numberOfArgs _ = 1
19+instance numberOfArgsFunction1 :: NumberOfArgs b => NumberOfArgs (a -> b) where
20+ numberOfArgs _ = numberOfArgs (Proxy :: Proxy b) + 1
3721
3822else instance numberOfArgsFunction0 :: NumberOfArgs a where
3923 numberOfArgs _ = 0
@@ -49,7 +33,7 @@ else instance numberOfArgsFunction0 :: NumberOfArgs a where
4933-- |
5034-- | Thus we can guarantee type safety at least in the number of arguments.
5135countArgs :: forall a. NumberOfArgs a => (Unit -> a) -> Int
52−countArgs f = numberOfArgs (proxyOf (f unit)) - 1
36+countArgs f = numberOfArgs (proxyOf f) - 2
5337 where
5438 proxyOf :: forall a. a -> Proxy a
5539 proxyOf _ = Proxy :: Proxy a