Safe Haskell | None |
---|---|
Language | Haskell2010 |
Documentation
isSimpleWorkflow :: Workflow x -> Maybe [Workflow_] Source #
downcasts a monad to a list of functors.
e.g.
>>>
isSimpleWorkflow $ getClipboard >>= sendText
Nothing
>>>
isSimpleWorkflow $ setClipboard "copying..." >> sendKeyChord [HyperModifier] CKey
Just [SetClipboard "copying..." (),SendKeyChord [HyperModifier] CKey ()]
TODO When Just
:
isSimpleWorkflow
>>> fromJust >>>fromWorkflow_
===id
showWorkflow :: Show x => Workflow x -> String Source #
shows (an inaccurate approximation of) 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.).
TODO would be complicated by SendTextTo; unless unit consuctors are distinguished (as sendTextTo =<< currentApplication is kinda Applicative).