Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- runWorkflow :: Workflow a -> IO a
- sendTextAsKeypresses :: String -> Workflow ()
- runWorkflowWithDelay :: Int -> Workflow a -> IO a
- sendTextAsKeypressesWithDelay :: Int -> String -> Workflow ()
- showWorkflow :: Show x => Workflow x -> String
- type Gensym = Int
- gensym :: State Gensym String
Documentation
runWorkflow :: Workflow a -> IO a
sendTextAsKeypresses :: String -> Workflow ()
returns a sequence of SendKeyChord
es.
runWorkflowWithDelay :: Int -> Workflow a -> IO a
sendTextAsKeypressesWithDelay :: Int -> String -> Workflow ()
returns a sequence of SendKeyChord
es.
showWorkflow :: Show x => Workflow x -> String
shows the "static" data flow of some Workflow
, by showing its primitive operations, in do-notation
.
e.g.
>>>
:{
putStrLn . showWorkflow $ do sendKeyChord [Command, Shift] BKey delay 1000 sendKeyChord [Command] DownArrowKey x1 <- currentApplication x2 <- getClipboard openURL $ "https://www.google.com/search?q=" <> x2 setClipboard x1 getClipboard :} do sendKeyChord ([Command,Shift]) (BKey) delay (1000) sendKeyChord ([Command]) (DownArrowKey) x1 <- currentApplication x2 <- getClipboard openURL ("https://www.google.com/search?q={x2}") setClipboard ("{x1}") x3 <- getClipboard return "{x3}"
(note: doesn't print variables as raw strings (cf. print
versus putStrLn
), as it doesn't "crystallize" all operations into "symbols", but gives you an idea of the data flow. however, it does correctly track the control flow, even when the variables are used non-sequentially.)
(note: the variables in the code were named to be consistent with
gensym
, for readability. but of course the bindings aren't reified,
and they could have been named anything)
basically, the monadically-bound variable x1
is shown as if it were literally "{x1}"
(rather than, the current clipboard contents). a more complicated alternative could be to purely model the state: e.g. a clipboard, with SetClipboard
and GetClipboard
working together, etc.).