git.iko.soy/rowtype-yoga/purescript-lunapark
on main help sign in
Add `Interpreter` newtype
e772fe3Gary Burgess
src/Lunapark.purs+1−1
@@ -6,7 +6,7 @@ module Lunapark
6 ) where
6 ) where
7
7
8
8
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)
10import Lunapark.Error (Error, ErrorType(..), fromJson, fromStringCode, toStringCode, unknownError)
10import Lunapark.Error (Error, ErrorType(..), fromJson, fromStringCode, toStringCode, unknownError)
11import Lunapark.ActionF (ActionF(..), LUNAPARK_ACTIONS, TouchF(..), WithAction, _lunaparkActions, buttonDown, buttonUp, click, doubleClick, doubleTap, flick, liftAction, longTap, moveTo, pause, scroll, sendKeys, tap, touchDown, touchUp)
11import Lunapark.ActionF (ActionF(..), LUNAPARK_ACTIONS, TouchF(..), WithAction, _lunaparkActions, buttonDown, buttonUp, click, doubleClick, doubleTap, flick, liftAction, longTap, moveTo, pause, scroll, sendKeys, tap, touchDown, touchUp)
12import 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)
12import 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
33import Run as R
33import Run as R
34import Run.Except (EXCEPT)
34import Run.Except (EXCEPT)
35
35
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+
36init
41init
37− ∷ ∀ m r a
42+ ∷ ∀ m r
38 . MonadAff m
43 . MonadAff m
39 ⇒ MonadRec m
44 ⇒ MonadRec m
40 ⇒ String
45 ⇒ String
41 → LT.CapabilitiesRequest
46 → LT.CapabilitiesRequest
42− → m (Either LE.Error (Lunapark r a → BaseRun r a))
47+ → m (Either LE.Error (Interpreter r))
43init uri caps = do
48init uri caps = do
44 res ←
49 res ←
45 liftAff
50 liftAff
@@ -78,7 +83,7 @@ init uri caps = do
78 , actionsEnabled
83 , actionsEnabled
79 }
84 }
80
85
81− pure $ interpret input
86+ pure $ Interpreter (interpret input)
82
87
83interpret
88interpret
84 ∷ ∀ r
89 ∷ ∀ r