kmonad-0.4.1: Advanced keyboard remapping utility

Copyright(c) David Janssen 2019
LicenseMIT
Maintainerjanssen.dhj@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

KMonad.Util

Contents

Description

Contains code for making it slighly easier to work with time, errors, and Acquire datatypes.

Synopsis

Time units and utils

 

data Milliseconds Source #

Newtype wrapper around Int to add type safety to our time values

Instances
Enum Milliseconds Source # 
Instance details

Defined in KMonad.Util

Eq Milliseconds Source # 
Instance details

Defined in KMonad.Util

Integral Milliseconds Source # 
Instance details

Defined in KMonad.Util

Num Milliseconds Source # 
Instance details

Defined in KMonad.Util

Ord Milliseconds Source # 
Instance details

Defined in KMonad.Util

Read Milliseconds Source # 
Instance details

Defined in KMonad.Util

Real Milliseconds Source # 
Instance details

Defined in KMonad.Util

Show Milliseconds Source # 
Instance details

Defined in KMonad.Util

Generic Milliseconds Source # 
Instance details

Defined in KMonad.Util

Associated Types

type Rep Milliseconds :: Type -> Type #

Display Milliseconds Source # 
Instance details

Defined in KMonad.Util

type Rep Milliseconds Source # 
Instance details

Defined in KMonad.Util

type Rep Milliseconds = D1 (MetaData "Milliseconds" "KMonad.Util" "kmonad-0.4.1-FPseCbFTtIEC38tuwaAvvU" True) (C1 (MetaCons "Milliseconds" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)))

tDiff Source #

Arguments

:: SystemTime

The earlier timepoint

-> SystemTime

The later timepoint

-> Milliseconds

The time in milliseconds between the two

Calculate how much time has elapsed between 2 time points

Random utility helpers that have no better home

onErr :: (MonadUnliftIO m, Exception e) => m Int -> e -> m () Source #

A helper function that helps to throw errors when a return code is -1. Easiest when used as infix like this:

someFFIcall `onErr` MyCallFailedError someData

using :: Acquire a -> ContT r (RIO e) a Source #

Embed the action of using an Acquire in a continuation monad

logRethrow Source #

Arguments

:: HasLogFunc e 
=> Text 
-> SomeException

The error to throw

-> RIO e a 

Log an error message and then rethrow the error

Particularly useful as a suffix using catch. i.e.

doSomething `catch` logRethrow "I caught something"

Some helpers to launch background process

withLaunch Source #

Arguments

:: HasLogFunc e 
=> Text

The name of this process (for logging)

-> RIO e a

The action to repeat forever

-> (Async a -> RIO e b)

The foreground action to run

-> RIO e b

The resulting action

Launch a process that repeats an action indefinitely. If an error ever occurs, print it and rethrow it. Ensure the process is cleaned up upon error and/or shutdown.

withLaunch_ Source #

Arguments

:: HasLogFunc e 
=> Text

The name of this process (for logging)

-> RIO e a

The action to repeat forever

-> RIO e b

The foreground action to run

-> RIO e b

The resulting action

Like withLaunch, but without ever needing access to the async process

launch Source #

Arguments

:: HasLogFunc e 
=> Text

The name of this process (for logging)

-> RIO e a

The action to repeat forever

-> ContT r (RIO e) (Async a) 

Like withLaunch, but in the ContT monad

launch_ Source #

Arguments

:: HasLogFunc e 
=> Text

The name of this process (for logging)

-> RIO e a

The action to repeat forever

-> ContT r (RIO e) () 

Like withLaunch_, but in the ContT monad