git.iko.soy/rowtype-yoga/purescript-lunapark
on main help sign in
Add `Interpreter` newtype
commite772fe3a0541579fead6c8071d36d2e6bdb634b2 authorGary Burgess <gary.burgess@gmail.com> dateThu 6 Dec 2018, 12:41 (8 years ago) parent780f320
2 files changed+9−4
src/Lunapark.purs+1−1 src/Lunapark/API.purs+8−3
src/Lunapark.purs+1−1
@@ -6,7 +6,7 @@ module Lunapark
66 ) where
77
88
9−import Lunapark.API (BaseRun, HandleLunaparkInput, Lunapark, handleLunapark, init, interpret, interpretW3CActions, jsonWireActions, runLunapark, runLunaparkActions, w3cActions)
9+import Lunapark.API (Interpreter(..), runInterpreter, BaseRun, HandleLunaparkInput, Lunapark, handleLunapark, init, interpret, interpretW3CActions, jsonWireActions, runLunapark, runLunaparkActions, w3cActions)
1010import Lunapark.Error (Error, ErrorType(..), fromJson, fromStringCode, toStringCode, unknownError)
1111import Lunapark.ActionF (ActionF(..), LUNAPARK_ACTIONS, TouchF(..), WithAction, _lunaparkActions, buttonDown, buttonUp, click, doubleClick, doubleTap, flick, liftAction, longTap, moveTo, pause, scroll, sendKeys, tap, touchDown, touchUp)
1212import Lunapark.LunaparkF (ElementF(..), LUNAPARK, LunaparkF(..), WithLunapark, _lunapark, acceptAlert, addCookie, back, childElement, childElements, clearElement, clickElement, closeWindow, deleteAllCookies, deleteCookie, dismissAlert, elementScreenshot, executeScript, executeScriptAsync, findElement, findElements, forward, fullscreenWindow, getAlertText, getAllCookies, getAttribute, getCookie, getCss, getProperty, getRectangle, getTagName, getText, getTimeouts, getTitle, getUrl, getWindowHandle, getWindowHandles, getWindowRectangle, go, isDisplayed, isEnabled, isSelected, liftLunapark, maximizeWindow, minimizeWindow, performActions, quit, refresh, releaseActions, screenshot, sendAlertText, sendKeysElement, setTimeouts, setWindowRectangle, status, submitElement, switchToFrame, switchToParentFrame, switchToWindow)
src/Lunapark/API.purs+8−3
@@ -33,13 +33,18 @@ import Node.FS.Aff as FS
3333import Run as R
3434import Run.Except (EXCEPT)
3535
36+newtype Interpreter r = Interpreter (Lunapark r ~> BaseRun r)
37+
38+runInterpreter ∷ ∀ r. Interpreter r → Lunapark r ~> BaseRun r
39+runInterpreter (Interpreter f) = f
40+
3641init
37− ∷ ∀ m r a
42+ ∷ ∀ m r
3843 . MonadAff m
3944 ⇒ MonadRec m
4045 ⇒ String
4146 → LT.CapabilitiesRequest
42− → m (Either LE.Error (Lunapark r a → BaseRun r a))
47+ → m (Either LE.Error (Interpreter r))
4348init uri caps = do
4449 res ←
4550 liftAff
@@ -78,7 +83,7 @@ init uri caps = do
7883 , actionsEnabled
7984 }
8085
81− pure $ interpret input
86+ pure $ Interpreter (interpret input)
8287
8388interpret
8489 ∷ ∀ r