workflow-osx-0.0.0: a "Desktop Workflow" monad with Objective-C bindings

Safe HaskellSafe




sendTextAsKeypresses :: String -> Workflow ()

returns a sequence of SendKeyChordes.

sendTextAsKeypressesWithDelay :: Int -> String -> Workflow ()

returns a sequence of SendKeyChordes.

showWorkflow :: Show x => Workflow x -> String

shows the "static" data flow of some Workflow, by showing its primitive operations, in do-notation.


>>> :{
putStrLn . showWorkflow $ do
 sendKeyChord [Command, Shift] BKey
 delay 1000
 sendKeyChord [Command] DownArrowKey
 x1 <- currentApplication
 x2 <- getClipboard
 openURL $ "" <> x2
 setClipboard x1
 sendKeyChord ([Command,Shift]) (BKey)
 delay (1000)
 sendKeyChord ([Command]) (DownArrowKey)
 x1 <- currentApplication
 x2 <- getClipboard
 openURL ("{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.).

type Gensym = Int