Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data WorkflowF k
- = SendKeyChord [Modifier] Key k
- | SendText String k
- | SendMouseClick [Modifier] Natural MouseButton k
- | SendMouseScroll [Modifier] MouseScroll Natural k
- | GetClipboard (Clipboard -> k)
- | SetClipboard Clipboard k
- | CurrentApplication (Application -> k)
- | OpenApplication Application k
- | OpenURL URL k
- | Delay MilliSeconds k
- data Workflow_
- type MonadWorkflow m = (MonadFree WorkflowF m, MonadThrow m)
- type MonadWorkflow_ = MonadFree WorkflowF
- type WorkflowT = FreeT WorkflowF
- type Workflow = Free WorkflowF
- type Clipboard = String
- type Application = String
- type URL = String
- type MilliSeconds = Int
- data MouseButton
- data MouseScroll
- type KeySequence = [KeyChord]
- type KeyChord = ([Modifier], Key)
- pattern KeyChord :: [Modifier] -> Key -> KeyChord
- pattern SimpleKeyChord :: Key -> KeyChord
- data Modifier
- data Key
- = MetaKey
- | HyperKey
- | ControlKey
- | CapsLockKey
- | ShiftKey
- | OptionKey
- | FunctionKey
- | GraveKey
- | MinusKey
- | EqualKey
- | DeleteKey
- | ForwardDeleteKey
- | LeftBracketKey
- | RightBracketKey
- | BackslashKey
- | SemicolonKey
- | QuoteKey
- | CommaKey
- | PeriodKey
- | SlashKey
- | TabKey
- | SpaceKey
- | ReturnKey
- | LeftArrowKey
- | RightArrowKey
- | DownArrowKey
- | UpArrowKey
- | AKey
- | BKey
- | CKey
- | DKey
- | EKey
- | FKey
- | GKey
- | HKey
- | IKey
- | JKey
- | KKey
- | LKey
- | MKey
- | NKey
- | OKey
- | PKey
- | QKey
- | RKey
- | SKey
- | TKey
- | UKey
- | VKey
- | WKey
- | XKey
- | YKey
- | ZKey
- | ZeroKey
- | OneKey
- | TwoKey
- | ThreeKey
- | FourKey
- | FiveKey
- | SixKey
- | SevenKey
- | EightKey
- | NineKey
- | EscapeKey
- | F1Key
- | F2Key
- | F3Key
- | F4Key
- | F5Key
- | F6Key
- | F7Key
- | F8Key
- | F9Key
- | F10Key
- | F11Key
- | F12Key
- | F13Key
- | F14Key
- | F15Key
- | F16Key
- | F17Key
- | F18Key
- | F19Key
- | F20Key
- modifier2key :: Modifier -> Key
- delay :: forall m. MonadFree WorkflowF m => MilliSeconds -> m ()
- openURL :: forall m. MonadFree WorkflowF m => URL -> m ()
- openApplication :: forall m. MonadFree WorkflowF m => Application -> m ()
- currentApplication :: forall m. MonadFree WorkflowF m => m Application
- setClipboard :: forall m. MonadFree WorkflowF m => Clipboard -> m ()
- getClipboard :: forall m. MonadFree WorkflowF m => m Clipboard
- sendMouseScroll :: forall m. MonadFree WorkflowF m => [Modifier] -> MouseScroll -> Natural -> m ()
- sendMouseClick :: forall m. MonadFree WorkflowF m => [Modifier] -> Natural -> MouseButton -> m ()
- sendText :: forall m. MonadFree WorkflowF m => String -> m ()
- sendKeyChord :: forall m. MonadFree WorkflowF m => [Modifier] -> Key -> m ()
- sendKeySequence :: MonadWorkflow m => KeySequence -> m ()
- sendKeyChord' :: MonadWorkflow m => KeyChord -> m ()
- fromWorkflows_ :: MonadWorkflow m => [Workflow_] -> m ()
- fromWorkflow_ :: Workflow_ -> WorkflowF ()
- data CoWorkflowF k = CoWorkflowF {
- _SendKeyChord :: [Modifier] -> Key -> k
- _SendText :: String -> k
- _SendMouseClick :: [Modifier] -> Natural -> MouseButton -> k
- _SendMouseScroll :: [Modifier] -> MouseScroll -> Natural -> k
- _GetClipboard :: (Clipboard, k)
- _SetClipboard :: Clipboard -> k
- _CurrentApplication :: (Application, k)
- _OpenApplication :: Application -> k
- _OpenURL :: URL -> k
- _Delay :: MilliSeconds -> k
- type CoWorkflowT = CofreeT CoWorkflowF
- type CoWorkflow = Cofree CoWorkflowF
Documentation
WorkflowF
platform-agnostic workflows, which can be interpreted by platform-specific bindings.
Naming: WorkflowF for "Workflow Functor".
NOTE: currently, no error codes are returned (only ()
)).
this (1) simplifies bindings and
(2) saves the user from explicitly ignoring action results (e.g. _ <- getClipboard
).
later, they can be supported,
alongside wrappers that return ()
and throw SomeException
and provide the same simple API.
since the intented usage of workflows are as user-facing
(often user-written) scripts, and
the monad that satisifes MonadWorkflow will often satisify MonadIO too,
convenient partial functions that throw a helpful error message to stdout
(the error codes should be converted to their error messages) should suffice.
and either way, is strictly better for the user than ignoring,
as the exceptions can always be caught, or not displayed.
SendKeyChord [Modifier] Key k | press the |
SendText String k | a logical grouping for: (1) unicode support (2) efficiency and (3) debugging. sent to the current application. |
SendMouseClick [Modifier] Natural MouseButton k | click the button, some number of times, holding down the modifiers derived, make method, not constructor. sent to the current application. |
SendMouseScroll [Modifier] MouseScroll Natural k | spin the wheel, some number of units*, holding down the modifiers |
GetClipboard (Clipboard -> k) | |
SetClipboard Clipboard k | |
CurrentApplication (Application -> k) | like getter |
OpenApplication Application k | like setter |
OpenURL URL k | |
Delay MilliSeconds k | interpreted as |
the non-monadic subset of WorkflowF
.
i.e. all cases that return ()
, preserving the previous continuation.
Naming: "unit workflow", like "traverse_".
type MonadWorkflow m = (MonadFree WorkflowF m, MonadThrow m) Source #
abstract interface.
a monad constraint for "workflow effects"
(just like MonadState
is for "state effects").
Can be used in any monad transformer stack that handles them.
WorkflowF
holds the effects.
MonadThrow
supports:
press
, if the user's syntax is wrong- error messages from the underlying system calls (TODO e.g. Win32's
GetLastError()
)
type MonadWorkflow_ = MonadFree WorkflowF Source #
(without failability)
type Application = String Source #
type MilliSeconds = Int Source #
data MouseButton Source #
Operating systems always (?) support at least these mouse events.
Most mice have these three buttons, trackpads have left/right.
data MouseScroll Source #
Mouse wheel scrolling, vertically and horizontally.
- scrolls up when "natural scrolling" is disabled
- scrolls down when "natural scrolling" is enabled
TODO check
type KeySequence = [KeyChord] Source #
a sequence of key chords make up a keyboard shortcut
type KeyChord = ([Modifier], Key) Source #
represents joitly holding down all the modifiers while individually press each key down and back up.
pattern SimpleKeyChord :: Key -> KeyChord Source #
modifier keys are keys that can be "held".
NOTE the escape key tends to be "pressed", not "held", it seems. (possibly explains its behavior in your terminal emulator?)
alt
is OptionModifier
.
MetaModifier | fake modifier: Alt on Linux/Windows, Command on OSX |
HyperModifier | fake modifier: Control on Linux/Windows, Command on OSX |
ControlModifier | |
OptionModifier | |
ShiftModifier | |
FunctionModifier |
a "cross-platform" keyboard, that has:
- all keys that exist on standard keyboards.
- plus,
MetaKey
andHyperKey
: virtual modifiers to abstract over common keyboard shortcuts.
(let me know if you want a type to support cross-platform international keyboards,
i haven't looked into it. you can still use the
platform-specific virtual-key-codes in the dependent packages:
workflow-linux
, workflow-osx
, and workflow-windows
)
MetaKey | fake key: Alt on Linux/Windows, Command on OSX |
HyperKey | fake key: Control on Linux/Windows, Command on OSX Control/Command both have C/O/N |
ControlKey | |
CapsLockKey | |
ShiftKey | |
OptionKey | |
FunctionKey | |
GraveKey | |
MinusKey | |
EqualKey | |
DeleteKey | |
ForwardDeleteKey | |
LeftBracketKey | |
RightBracketKey | |
BackslashKey | |
SemicolonKey | |
QuoteKey | |
CommaKey | |
PeriodKey | |
SlashKey | |
TabKey | |
SpaceKey | |
ReturnKey | |
LeftArrowKey | |
RightArrowKey | |
DownArrowKey | |
UpArrowKey | |
AKey | |
BKey | |
CKey | |
DKey | |
EKey | |
FKey | |
GKey | |
HKey | |
IKey | |
JKey | |
KKey | |
LKey | |
MKey | |
NKey | |
OKey | |
PKey | |
QKey | |
RKey | |
SKey | |
TKey | |
UKey | |
VKey | |
WKey | |
XKey | |
YKey | |
ZKey | |
ZeroKey | |
OneKey | |
TwoKey | |
ThreeKey | |
FourKey | |
FiveKey | |
SixKey | |
SevenKey | |
EightKey | |
NineKey | |
EscapeKey | |
F1Key | |
F2Key | |
F3Key | |
F4Key | |
F5Key | |
F6Key | |
F7Key | |
F8Key | |
F9Key | |
F10Key | |
F11Key | |
F12Key | |
F13Key | |
F14Key | |
F15Key | |
F16Key | |
F17Key | |
F18Key | |
F19Key | |
F20Key |
modifier2key :: Modifier -> Key Source #
All modifiers are keys.
openApplication :: forall m. MonadFree WorkflowF m => Application -> m () Source #
currentApplication :: forall m. MonadFree WorkflowF m => m Application Source #
sendMouseScroll :: forall m. MonadFree WorkflowF m => [Modifier] -> MouseScroll -> Natural -> m () Source #
sendMouseClick :: forall m. MonadFree WorkflowF m => [Modifier] -> Natural -> MouseButton -> m () Source #
sendKeySequence :: MonadWorkflow m => KeySequence -> m () Source #
sendKeyChord' :: MonadWorkflow m => KeyChord -> m () Source #
uncurried sendKeyChord
fromWorkflows_ :: MonadWorkflow m => [Workflow_] -> m () Source #
fromWorkflow_ :: Workflow_ -> WorkflowF () Source #
CoWorkflowF
provides generic helper functions for defining interpreters.
data CoWorkflowF k Source #
Naming: induces a CoMonad
, see
http://dlaing.org/cofun/posts/free_and_cofree.html
WorkflowF
, CoWorkflowF
, and runWorkflowWithT
are analogous to:
Either (a -> c) (b,c)
, "get ana
, or set ab
"((a,c), (b -> c))
, "a handler for the getting of ana
, and a handler for the setting of ab
"- @ handle :: ((a,c), (b -> c))
- > (Either (a -> c) (b,c))
- > c handle (aHasBeenGotten, bHasBeenSet) = either TODO @
background: see http://dlaing.org/cofun/posts/free_and_cofree.html
CoWorkflowF | |
|
type CoWorkflowT = CofreeT CoWorkflowF Source #
e.g.
@ expansion:
CoWorkflowT w a ~ CofreeT CoWorkflowF w a ~ w (CofreeF CoWorkflowF a (CofreeT CoWorkflowF w a)) ~ w (a, CoWorkflowF (CofreeT CoWorkflowF w a)) @
since:
data CofreeT f w a = w (CofreeF f a (CofreeT f w a))
type CoWorkflow = Cofree CoWorkflowF Source #
expansion:
CoWorkflow a ~ Cofree CoWorkflowF a ~ (a, CoWorkflow (Cofree CoWorkflowF a))
since:
data Cofree f a = a :< f (Cofree f a)