butler-0.0.1.0: At your service.
Safe HaskellSafe-Inferred
LanguageGHC2021

Butler

Description

Welcome to Butler.

This module exposes the main API.

Synopsis

Core primitive

runMain :: IO a -> IO a #

Helper to setup line-buffering and cgroup rts for container

data ProcessIO a #

Instances

Instances details
MonadFail ProcessIO # 
Instance details

Defined in Butler.Core

Methods

fail :: String -> ProcessIO a #

MonadIO ProcessIO # 
Instance details

Defined in Butler.Core

Methods

liftIO :: IO a -> ProcessIO a #

Applicative ProcessIO # 
Instance details

Defined in Butler.Core

Methods

pure :: a -> ProcessIO a #

(<*>) :: ProcessIO (a -> b) -> ProcessIO a -> ProcessIO b #

liftA2 :: (a -> b -> c) -> ProcessIO a -> ProcessIO b -> ProcessIO c #

(*>) :: ProcessIO a -> ProcessIO b -> ProcessIO b #

(<*) :: ProcessIO a -> ProcessIO b -> ProcessIO a #

Functor ProcessIO # 
Instance details

Defined in Butler.Core

Methods

fmap :: (a -> b) -> ProcessIO a -> ProcessIO b #

(<$) :: a -> ProcessIO b -> ProcessIO a #

Monad ProcessIO # 
Instance details

Defined in Butler.Core

Methods

(>>=) :: ProcessIO a -> (a -> ProcessIO b) -> ProcessIO b #

(>>) :: ProcessIO a -> ProcessIO b -> ProcessIO b #

return :: a -> ProcessIO a #

MonadUnliftIO ProcessIO # 
Instance details

Defined in Butler.Core

Methods

withRunInIO :: ((forall a. ProcessIO a -> IO a) -> IO b) -> ProcessIO b #

MonadReader ProcessEnv ProcessIO # 
Instance details

Defined in Butler.Core

spawnInitProcess :: RawFilePath -> ProcessIO a -> IO ExitReason #

Run the initial process with a given storage root directory.

Concurrency API

data Process #

A process is a killable thread.

Constructors

Process 

Fields

Instances

Instances details
ToJSON Process # 
Instance details

Defined in Butler.Core.Process

Show Process # 
Instance details

Defined in Butler.Core.Process

newtype ProgramName #

Constructors

ProgramName Text 

Instances

Instances details
FromJSON ProgramName # 
Instance details

Defined in Butler.Core.Process

ToJSON ProgramName # 
Instance details

Defined in Butler.Core.Process

IsString ProgramName # 
Instance details

Defined in Butler.Core.Process

Semigroup ProgramName # 
Instance details

Defined in Butler.Core.Process

Generic ProgramName # 
Instance details

Defined in Butler.Core.Process

Associated Types

type Rep ProgramName :: Type -> Type #

Show ProgramName # 
Instance details

Defined in Butler.Core.Process

Eq ProgramName # 
Instance details

Defined in Butler.Core.Process

Ord ProgramName # 
Instance details

Defined in Butler.Core.Process

ToHtml ProgramName # 
Instance details

Defined in Butler.Core.Process

Methods

toHtml :: forall (m :: Type -> Type). Monad m => ProgramName -> HtmlT m () #

toHtmlRaw :: forall (m :: Type -> Type). Monad m => ProgramName -> HtmlT m () #

Serialise ProgramName # 
Instance details

Defined in Butler.Core.Process

From ProgramName Text # 
Instance details

Defined in Butler.Core.Process

Methods

from :: ProgramName -> Text #

From Text ProgramName # 
Instance details

Defined in Butler.Core.Process

Methods

from :: Text -> ProgramName #

From Natural ProgramName # 
Instance details

Defined in Butler.Core.Process

Methods

from :: Natural -> ProgramName #

type Rep ProgramName # 
Instance details

Defined in Butler.Core.Process

type Rep ProgramName = D1 ('MetaData "ProgramName" "Butler.Core.Process" "butler-0.0.1.0-inplace" 'True) (C1 ('MetaCons "ProgramName" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

spawnProcess :: ProgramName -> ProcessIO () -> ProcessIO Process #

Create a process.

stopProcess :: Process -> STM Bool #

Stop a process, returns False if the process did not received the message.

killProcess :: Pid -> ProcessIO Bool #

Lookup and kill the pid. Use stopProcess instead.

spawnThread_ :: ProcessIO Void -> ProcessIO () #

Create a child thread that never exit, for example to handle messages. If the thread crash, the whole process is terminated.

spawnThread :: ProcessIO a -> ProcessIO (Thread a) #

Create a child thread.

Logging API

logInfo :: HasCallStack => Text -> [Pair] -> ProcessIO () #

Use logInfo for nominal but important event.

logError :: HasCallStack => Text -> [Pair] -> ProcessIO () #

Use logError for unexpected mal-functions.

logDebug :: HasCallStack => Text -> [Pair] -> ProcessIO () #

Use logDebug for the rest.

Time API

data Time #

The number of milli secondes since the clock started.

Instances

Instances details
ToJSON Time # 
Instance details

Defined in Butler.Core.Clock

Enum Time # 
Instance details

Defined in Butler.Core.Clock

Methods

succ :: Time -> Time #

pred :: Time -> Time #

toEnum :: Int -> Time #

fromEnum :: Time -> Int #

enumFrom :: Time -> [Time] #

enumFromThen :: Time -> Time -> [Time] #

enumFromTo :: Time -> Time -> [Time] #

enumFromThenTo :: Time -> Time -> Time -> [Time] #

Num Time # 
Instance details

Defined in Butler.Core.Clock

Methods

(+) :: Time -> Time -> Time #

(-) :: Time -> Time -> Time #

(*) :: Time -> Time -> Time #

negate :: Time -> Time #

abs :: Time -> Time #

signum :: Time -> Time #

fromInteger :: Integer -> Time #

Integral Time # 
Instance details

Defined in Butler.Core.Clock

Methods

quot :: Time -> Time -> Time #

rem :: Time -> Time -> Time #

div :: Time -> Time -> Time #

mod :: Time -> Time -> Time #

quotRem :: Time -> Time -> (Time, Time) #

divMod :: Time -> Time -> (Time, Time) #

toInteger :: Time -> Integer #

Real Time # 
Instance details

Defined in Butler.Core.Clock

Methods

toRational :: Time -> Rational #

Show Time # 
Instance details

Defined in Butler.Core.Clock

Methods

showsPrec :: Int -> Time -> ShowS #

show :: Time -> String #

showList :: [Time] -> ShowS #

Eq Time # 
Instance details

Defined in Butler.Core.Clock

Methods

(==) :: Time -> Time -> Bool #

(/=) :: Time -> Time -> Bool #

Ord Time # 
Instance details

Defined in Butler.Core.Clock

Methods

compare :: Time -> Time -> Ordering #

(<) :: Time -> Time -> Bool #

(<=) :: Time -> Time -> Bool #

(>) :: Time -> Time -> Bool #

(>=) :: Time -> Time -> Bool #

max :: Time -> Time -> Time #

min :: Time -> Time -> Time #

ToHtml Time # 
Instance details

Defined in Butler.Core.Clock

Methods

toHtml :: forall (m :: Type -> Type). Monad m => Time -> HtmlT m () #

toHtmlRaw :: forall (m :: Type -> Type). Monad m => Time -> HtmlT m () #

Serialise Time # 
Instance details

Defined in Butler.Core.Clock

From Time Milli # 
Instance details

Defined in Butler.Core.Clock

Methods

from :: Time -> Milli #

From Time ByteString # 
Instance details

Defined in Butler.Core.Clock

Methods

from :: Time -> ByteString #

From Time Text # 
Instance details

Defined in Butler.Core.Clock

Methods

from :: Time -> Text #

From Time Natural # 
Instance details

Defined in Butler.Core.Clock

Methods

from :: Time -> Natural #

From Natural Time # 
Instance details

Defined in Butler.Core.Clock

Methods

from :: Natural -> Time #

data Milli #

A duration in millisecond

Instances

Instances details
Enum Milli # 
Instance details

Defined in Butler.Core.Clock

Num Milli # 
Instance details

Defined in Butler.Core.Clock

Show Milli # 
Instance details

Defined in Butler.Core.Clock

Methods

showsPrec :: Int -> Milli -> ShowS #

show :: Milli -> String #

showList :: [Milli] -> ShowS #

Eq Milli # 
Instance details

Defined in Butler.Core.Clock

Methods

(==) :: Milli -> Milli -> Bool #

(/=) :: Milli -> Milli -> Bool #

Ord Milli # 
Instance details

Defined in Butler.Core.Clock

Methods

compare :: Milli -> Milli -> Ordering #

(<) :: Milli -> Milli -> Bool #

(<=) :: Milli -> Milli -> Bool #

(>) :: Milli -> Milli -> Bool #

(>=) :: Milli -> Milli -> Bool #

max :: Milli -> Milli -> Milli #

min :: Milli -> Milli -> Milli #

From Time Milli # 
Instance details

Defined in Butler.Core.Clock

Methods

from :: Time -> Milli #

sleep :: MonadIO m => Milli -> m () #

Pause the execution.

data WaitResult result #

Constructors

WaitCompleted result 
WaitTimeout 

Instances

Instances details
ToJSON result => ToJSON (WaitResult result) # 
Instance details

Defined in Butler.Core.Clock

Methods

toJSON :: WaitResult result -> Value #

toEncoding :: WaitResult result -> Encoding #

toJSONList :: [WaitResult result] -> Value #

toEncodingList :: [WaitResult result] -> Encoding #

Show result => Show (WaitResult result) # 
Instance details

Defined in Butler.Core.Clock

Methods

showsPrec :: Int -> WaitResult result -> ShowS #

show :: WaitResult result -> String #

showList :: [WaitResult result] -> ShowS #

waitTransaction :: MonadIO m => Milli -> STM result -> m (STM (WaitResult result)) #

Wait for a transaction with a timeout.

Network API

Storage API

newtype StorageAddress #

Instances

Instances details
IsString StorageAddress # 
Instance details

Defined in Butler.Core.Storage

Semigroup StorageAddress # 
Instance details

Defined in Butler.Core.Storage

Show StorageAddress # 
Instance details

Defined in Butler.Core.Storage

Eq StorageAddress # 
Instance details

Defined in Butler.Core.Storage

Ord StorageAddress # 
Instance details

Defined in Butler.Core.Storage

Serialise StorageAddress # 
Instance details

Defined in Butler.Core.Storage

From SessionID StorageAddress # 
Instance details

Defined in Butler.Display.Session

From Workspace StorageAddress # 
Instance details

Defined in Butler.Display.WebSocket

From Text StorageAddress # 
Instance details

Defined in Butler.Core.Storage

Methods

from :: Text -> StorageAddress #

Display API

data DisplayEvent #

App API

data App #

A graphical application definition.

Constructors

App 

Fields

data AppContext #

The application context

Constructors

AppContext 

Fields

  • clients :: DisplayClients

    the list of all the connected clients. To send update, app should uses `sendsHtml clients ""`

  • wid :: WinID

    the instance identifier. The app should mount its UI with `with div_ [wid_ wid] "body"`, and the trigger must container the WinID suffix too.

  • pipe :: Pipe AppEvent

    the channel to receive events.

  • shared :: AppSharedContext
     

data AppEvent #

The type of event an app receive

Constructors

AppDisplay DisplayEvent

A display event (e.g. to mount the UI)

AppTrigger GuiEvent

A trigger event (e.g. onclick)

AppData DataEvent

A data event (e.g. for raw data)

AppFile Directory (Maybe File)

A file event (e.g. a new file opened)

data GuiEvent #

Constructors

GuiEvent 

Instances

Instances details
ToJSON GuiEvent # 
Instance details

Defined in Butler.Display.GUI

data DataEvent #

Constructors

DataEvent 

Fields

Instances

Instances details
ToJSON DataEvent # 
Instance details

Defined in Butler.Frame

serveApps :: DisplayApplication -> [App] -> ProcessIO Void #

Serve applications with one instance per client.

serveDashboardApps :: DisplayApplication -> [App] -> ProcessIO Void #

Serve applications with one instance for all clients.

newtype Service #

Constructors

Service App 

GUI toolkit

sendHtmlOnConnect :: HtmlT STM () -> AppEvent -> ProcessIO () #

A convenient helper to mount the UI when a new user connect.

Prelude