-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Dynamic key binding framework -- -- Dynamic key binding framework. See -- https://github.com/debug-ito/wild-bind @package wild-bind @version 0.1.2.7 module WildBind.Description -- | Human-readable description of an action. ActionDescription is -- used to describe the current binding to the user. type ActionDescription = Text -- | Class for something describable. class Describable d describe :: Describable d => d -> ActionDescription instance (WildBind.Description.Describable a, WildBind.Description.Describable b) => WildBind.Description.Describable (Data.Either.Either a b) -- | This module exports functions to build and manipulate Binding, -- an object binding input symbols to actions. module WildBind.Binding -- | Action done by WildBind data Action m a Action :: ActionDescription -> m a -> Action m a -- | Human-readable description of the action. [actDescription] :: Action m a -> ActionDescription -- | The actual job. [actDo] :: Action m a -> m a -- | WildBind back-end binding between inputs and actions. s is -- the front-end state type, and i is the input type. type Binding s i = Binding' () s i -- | WildBind back-end binding with both explicit and implicit states. -- bs is the explicit back-end state, fs is the -- front-end state, and i is the input type. -- -- You can make the explicit state bs implicit by -- startFrom function. data Binding' bs fs i -- | A Binding' with no bindings. It's the same as mempty, -- except noBinding requires no context. noBinding :: Binding' bs fs i -- | A monad to construct Binding'. i is the input symbol, -- and v is supposed to be the Action bound to -- i. data Binder i v a -- | Build a Binding with no explicit or implicit state. The bound -- actions are activated regardless of the back-end or front-end state. -- -- If different actions are bound to the same input, the latter action -- wins. -- -- Result of action (r) is discarded. binds :: Ord i => Binder i (Action IO r) a -> Binding' bs fs i -- | Build a Binding' with an explicit state (but no implicit -- state). The bound actions are activated regardless of the back-end or -- front-end state. binds' :: Ord i => Binder i (Action (StateT bs IO) r) a -> Binding' bs fs i -- | Like binds, but this function allows actions to use the current -- front-end state via ReaderT. bindsF :: Ord i => Binder i (Action (ReaderT fs IO) r) a -> Binding' bs fs i -- | Like binds', but this function allows actions to use the -- current front-end state via ReaderT. bindsF' :: Ord i => Binder i (Action (StateT bs (ReaderT fs IO)) r) a -> Binding' bs fs i -- | Create a Binder that binds the action v to the input -- i. on :: i -> v -> Binder i v () -- | Transform the given action m a into an Action and -- apply the continuation to it. It discards the result of action (type -- a). Usually used as an operator. run :: Functor m => (Action m () -> b) -> m a -> b infixl 2 `run` -- | Transform the given continuation so that the ActionDescription -- is set to the Action passed to the continuation. Usually used -- as an operator. as :: (Action m a -> b) -> ActionDescription -> Action m a -> b infixl 2 `as` -- | Non-monadic version of binds. binding :: Ord i => [(i, Action IO r)] -> Binding' bs fs i -- | Non-monadic version of binds'. binding' :: Ord i => [(i, Action (StateT bs IO) r)] -> Binding' bs fs i -- | Non-monadic version of bindsF. bindingF :: Ord i => [(i, Action (ReaderT fs IO) r)] -> Binding' bs fs i -- | Non-monadic version of bindsF'. bindingF' :: Ord i => [(i, Action (StateT bs (ReaderT fs IO)) r)] -> Binding' bs fs i -- | Create a binding that behaves differently for different front-end -- states fs. ifFront :: (fs -> Bool) -> Binding' bs fs i -> Binding' bs fs i -> Binding' bs fs i -- | Create a binding that behaves differently for different back-end -- states bs. ifBack :: (bs -> Bool) -> Binding' bs fs i -> Binding' bs fs i -> Binding' bs fs i -- | Create a binding that behaves differently for different front-end and -- back-end states, fs and bs. ifBoth :: (bs -> fs -> Bool) -> Binding' bs fs i -> Binding' bs fs i -> Binding' bs fs i -- | Add a condition on the front-end state to Binding. whenFront :: (fs -> Bool) -> Binding' bs fs i -> Binding' bs fs i -- | Add a condition on the back-end state to Binding. whenBack :: (bs -> Bool) -> Binding' bs fs i -> Binding' bs fs i -- | Add a condition on the back-end and front-end states to -- Binding. whenBoth :: (bs -> fs -> Bool) -> Binding' bs fs i -> Binding' bs fs i -- | Convert Binding' to Binding by hiding the explicit state -- bs. startFrom :: bs -> Binding' bs fs i -> Binding fs i -- | Extend Binding to Binding'. In the result -- Binding', the explicit back-end state is just ignored and -- unmodified. extend :: Binding fs i -> Binding' bs fs i -- | Contramap the front-end state. convFront :: (fs -> fs') -> Binding' bs fs' i -> Binding' bs fs i -- | Map the front-end input. convInput :: Ord i' => (i -> i') -> Binding' bs fs i -> Binding' bs fs i' -- | Convert the back-end state. Intuitively, it converts a small state -- type bs into a bigger state type bs', which includes -- bs. -- -- For example, if you have a Lens' l, you can do -- --
-- convBack (set l) (view l) b --convBack :: (bs -> bs' -> bs') -> (bs' -> bs) -> Binding' bs fs i -> Binding' bs' fs i -- | Transform the actions in the given Binder. advice :: (v -> v') -> Binder i v a -> Binder i v' a -- | Revise (modify) actions in the given Binding'. revise :: (forall a. bs -> fs -> i -> Action IO a -> Maybe (Action IO a)) -> Binding' bs fs i -> Binding' bs fs i -- | Like revise, but this function allows revising the back-end -- state. revise' :: (forall a. bs -> fs -> i -> Action (StateT bs IO) a -> Maybe (Action (StateT bs IO) a)) -> Binding' bs fs i -> Binding' bs fs i -- | Make an Action that runs the given monadic action before the -- original Action. before :: Applicative m => m b -> Action m a -> Action m a -- | Make an Action that runs the given monadic action after the -- original Action. after :: Applicative m => m b -> Action m a -> Action m a -- | Same as before, but it returns Just. justBefore :: Applicative m => m b -> Action m a -> Maybe (Action m a) -- | Same as after, but it returns Just. justAfter :: Applicative m => m b -> Action m a -> Maybe (Action m a) -- | Get the Action bound to the specified state s and -- input i. boundAction :: Ord i => Binding s i -> s -> i -> Maybe (Action IO (Binding s i)) -- | Get the Action bound to the specified back-end state -- bs, front-end state fs and input i boundAction' :: Ord i => Binding' bs fs i -> bs -> fs -> i -> Maybe (Action IO (Binding' bs fs i, bs)) -- | Get the list of all bound inputs i and their corresponding -- actions for the specified front-end state s. boundActions :: Binding s i -> s -> [(i, Action IO (Binding s i))] -- | Get the list of all bound inputs i and their corresponding -- actions for the specified back-end state bs and front-end -- state fs. boundActions' :: Binding' bs fs i -> bs -> fs -> [(i, Action IO (Binding' bs fs i, bs))] -- | Get the list of all bound inputs i for the specified -- front-end state s. boundInputs :: Binding s i -> s -> [i] -- | Get the list of all bound inputs i for the specified -- front-end state fs and the back-end state bs. boundInputs' :: Binding' bs fs i -> bs -> fs -> [i] instance GHC.Base.Functor (WildBind.Binding.Binder i v) instance GHC.Base.Applicative (WildBind.Binding.Binder i v) instance GHC.Base.Monad (WildBind.Binding.Binder i v) instance GHC.Classes.Ord i => GHC.Base.Semigroup (WildBind.Binding.Binding' bs fs i) instance GHC.Classes.Ord i => GHC.Base.Monoid (WildBind.Binding.Binding' bs fs i) instance GHC.Show.Show (WildBind.Binding.Action m a) instance GHC.Base.Functor m => GHC.Base.Functor (WildBind.Binding.Action m) -- | Data types and type classes about front-ends. -- -- You have to look at this module if you want to create a front-end -- implementation. module WildBind.FrontEnd -- | Event from the front-end. s is the state of the front-end. -- i is the input. data FrontEvent s i -- | An event that a new input is made. FEInput :: i -> FrontEvent s i -- | An event that the front-end state is changed. FEChange :: s -> FrontEvent s i -- | Interface to the front-end. s is the state of the front-end, -- i is the input. data FrontEnd s i FrontEnd :: (i -> ActionDescription) -> (i -> IO ()) -> (i -> IO ()) -> IO (FrontEvent s i) -> FrontEnd s i -- | Default ActionDescription for inputs [frontDefaultDescription] :: FrontEnd s i -> i -> ActionDescription -- | Action to grab (or capture) the specified input symbol on the device. [frontSetGrab] :: FrontEnd s i -> i -> IO () -- | Action to release the grab for the input symbol. [frontUnsetGrab] :: FrontEnd s i -> i -> IO () -- | Action to retrieve the next event. It should block if no event is -- queued. [frontNextEvent] :: FrontEnd s i -> IO (FrontEvent s i) instance (GHC.Classes.Ord i, GHC.Classes.Ord s) => GHC.Classes.Ord (WildBind.FrontEnd.FrontEvent s i) instance (GHC.Classes.Eq i, GHC.Classes.Eq s) => GHC.Classes.Eq (WildBind.FrontEnd.FrontEvent s i) instance (GHC.Show.Show i, GHC.Show.Show s) => GHC.Show.Show (WildBind.FrontEnd.FrontEvent s i) module WildBind.Exec -- | Combines the FrontEnd and the Binding and returns the -- executable. wildBind :: Ord i => Binding s i -> FrontEnd s i -> IO () -- | Build the executable with Option. wildBind' :: Ord i => Option s i -> Binding s i -> FrontEnd s i -> IO () -- | WildBind configuration options. -- -- You can get the default value of Option by defOption -- funcion, and modify its members via accessor functions listed below. data Option s i defOption :: Option s i -- | An action executed when current binding may be changed. Default: do -- nothing. optBindingHook :: Option s i -> [(i, ActionDescription)] -> IO () -- | the handler for exceptions thrown from bound actions. Default: just -- print the SomeException to stderr and ignore it. optCatch :: Option s i -> s -> i -> SomeException -> IO () -- | Input types for number pad keys. module WildBind.Input.NumPad -- | Number pad key input with NumLock disabled. data NumPadUnlocked NumInsert :: NumPadUnlocked NumEnd :: NumPadUnlocked NumDown :: NumPadUnlocked NumPageDown :: NumPadUnlocked NumLeft :: NumPadUnlocked NumCenter :: NumPadUnlocked NumRight :: NumPadUnlocked NumHome :: NumPadUnlocked NumUp :: NumPadUnlocked NumPageUp :: NumPadUnlocked NumDivide :: NumPadUnlocked NumMulti :: NumPadUnlocked NumMinus :: NumPadUnlocked NumPlus :: NumPadUnlocked NumEnter :: NumPadUnlocked NumDelete :: NumPadUnlocked -- | Number pad key input with NumLock enabled. data NumPadLocked NumL0 :: NumPadLocked NumL1 :: NumPadLocked NumL2 :: NumPadLocked NumL3 :: NumPadLocked NumL4 :: NumPadLocked NumL5 :: NumPadLocked NumL6 :: NumPadLocked NumL7 :: NumPadLocked NumL8 :: NumPadLocked NumL9 :: NumPadLocked NumLDivide :: NumPadLocked NumLMulti :: NumPadLocked NumLMinus :: NumPadLocked NumLPlus :: NumPadLocked NumLEnter :: NumPadLocked NumLPeriod :: NumPadLocked instance GHC.Enum.Enum WildBind.Input.NumPad.NumPadUnlocked instance GHC.Enum.Bounded WildBind.Input.NumPad.NumPadUnlocked instance GHC.Show.Show WildBind.Input.NumPad.NumPadUnlocked instance GHC.Classes.Ord WildBind.Input.NumPad.NumPadUnlocked instance GHC.Classes.Eq WildBind.Input.NumPad.NumPadUnlocked instance GHC.Enum.Enum WildBind.Input.NumPad.NumPadLocked instance GHC.Enum.Bounded WildBind.Input.NumPad.NumPadLocked instance GHC.Show.Show WildBind.Input.NumPad.NumPadLocked instance GHC.Classes.Ord WildBind.Input.NumPad.NumPadLocked instance GHC.Classes.Eq WildBind.Input.NumPad.NumPadLocked instance WildBind.Description.Describable WildBind.Input.NumPad.NumPadLocked instance WildBind.Description.Describable WildBind.Input.NumPad.NumPadUnlocked module WildBind -- | This module defines convenient functions to build Bindings that -- bind actions to key sequences. -- -- For example, see WildBind.Task.X11.Seq.Example in -- wild-bind-task-x11 package. module WildBind.Seq -- | Prepend prefix keys to a Binding. In the result Binding, -- the original Binding is enabled only after you input the prefix -- input symbols in the same order. -- -- During typing prefix keys, you can cancel and reset the key sequence -- by typing the "cancel keys". This is analogous to C-g in -- Emacs. The binding of cancel keys are weak, that is, they are -- overridden by the original binding and prefix keys. -- -- Note that this function creates an independent implicit state to -- memorize prefix keys input so far. This means, -- --
-- (prefix [] [key1, key2] b) /= (prefix [] [key1] $ prefix [] [key2] b) ---- -- If you want a more composable way of building a sequence binding, try -- SeqBinding. prefix :: Ord i => [i] -> [i] -> Binding fs i -> Binding fs i -- | Intermediate type of building a Binding for key sequences. data SeqBinding fs i -- | Create a SeqBinding from Binding. The result -- SeqBinding has no prefixes yet. toSeq :: Eq i => Binding fs i -> SeqBinding fs i -- | Resolve SeqBinding to build a Binding for key sequences. fromSeq :: SeqBinding fs i -> Binding fs i -- | Prepend prefix keys to the SeqBinding. -- -- SeqBinding is composable in terms of prefixes, that is, -- --
-- (withPrefix [key1, key2] seq_b) == (withPrefix [key1] $ withPrefix [key2] seq_b) --withPrefix :: Ord i => [i] -> SeqBinding fs i -> SeqBinding fs i -- | Add cancel keys to the SeqBinding. withCancel :: Ord i => [i] -> SeqBinding fs i -> SeqBinding fs i -- | Revise actions in SeqBinding. See revise. reviseSeq :: (forall a. [i] -> fs -> i -> Action IO a -> Maybe (Action IO a)) -> SeqBinding fs i -> SeqBinding fs i instance GHC.Classes.Ord i => GHC.Base.Semigroup (WildBind.Seq.SeqBinding fs i) instance GHC.Classes.Ord i => GHC.Base.Monoid (WildBind.Seq.SeqBinding fs i)