Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Welcome to Butler.
This module exposes the main API.
Synopsis
- runMain :: IO a -> IO a
- data ProcessIO a
- spawnInitProcess :: RawFilePath -> ProcessIO a -> IO ExitReason
- data Process = Process {}
- newtype ProgramName = ProgramName Text
- spawnProcess :: ProgramName -> ProcessIO () -> ProcessIO Process
- waitProcess :: MonadIO m => Process -> m ExitReason
- stopProcess :: Process -> STM Bool
- killProcess :: Pid -> ProcessIO Bool
- spawnThread_ :: ProcessIO Void -> ProcessIO ()
- spawnThread :: ProcessIO a -> ProcessIO (Thread a)
- module Butler.Core.Pipe
- logInfo :: HasCallStack => Text -> [Pair] -> ProcessIO ()
- logError :: HasCallStack => Text -> [Pair] -> ProcessIO ()
- logDebug :: HasCallStack => Text -> [Pair] -> ProcessIO ()
- data Time
- getTime :: ProcessIO Time
- data Milli
- sleep :: MonadIO m => Milli -> m ()
- data WaitResult result
- = WaitCompleted result
- | WaitTimeout
- waitTransaction :: MonadIO m => Milli -> STM result -> m (STM (WaitResult result))
- module Butler.Core.Network
- newProcessMemory :: Serialise a => StorageAddress -> ProcessIO a -> ProcessIO (a, MemoryVar a)
- module Butler.Core.Memory
- newtype StorageAddress = StorageAddress ByteString
- getPath :: StorageAddress -> ProcessIO RawFilePath
- module Butler.Core.File
- module Butler.Display.Client
- data DisplayEvent
- data App = App {
- name :: ProgramName
- tags :: Set AppTag
- title :: Text
- description :: Text
- size :: Maybe (Int, Int)
- xfiles :: [XStaticFile]
- acceptFiles :: Maybe ContentType
- start :: AppContext -> ProcessIO ()
- data AppSharedContext = AppSharedContext {
- display :: Display
- processEnv :: ProcessEnv
- appSet :: AppSet
- dynamics :: Dynamics
- apps :: Apps
- data AppContext = AppContext {
- clients :: DisplayClients
- wid :: WinID
- pipe :: Pipe AppEvent
- shared :: AppSharedContext
- defaultApp :: ProgramName -> (AppContext -> ProcessIO ()) -> App
- data AppEvent
- data GuiEvent = GuiEvent {
- client :: DisplayClient
- trigger :: TriggerName
- body :: Value
- data DataEvent = DataEvent {}
- serveApps :: DisplayApplication -> [App] -> ProcessIO Void
- serveDashboardApps :: DisplayApplication -> [App] -> ProcessIO Void
- publicDisplayApp :: PageTitle -> Maybe PageDesc -> DisplayApplication
- newtype Service = Service App
- sendHtmlOnConnect :: HtmlT STM () -> AppEvent -> ProcessIO ()
- module Butler.Display.GUI
- module Butler.Window
- module Butler.Prelude
Core primitive
Instances
MonadFail ProcessIO # | |
Defined in Butler.Core | |
MonadIO ProcessIO # | |
Defined in Butler.Core | |
Applicative ProcessIO # | |
Functor ProcessIO # | |
Monad ProcessIO # | |
MonadUnliftIO ProcessIO # | |
Defined in Butler.Core | |
MonadReader ProcessEnv ProcessIO # | |
Defined in Butler.Core ask :: ProcessIO ProcessEnv # local :: (ProcessEnv -> ProcessEnv) -> ProcessIO a -> ProcessIO a # reader :: (ProcessEnv -> a) -> ProcessIO a # |
spawnInitProcess :: RawFilePath -> ProcessIO a -> IO ExitReason #
Run the initial process with a given storage root directory.
Concurrency API
A process is a killable thread.
Process | |
|
newtype ProgramName #
Instances
spawnProcess :: ProgramName -> ProcessIO () -> ProcessIO Process #
Create a process.
waitProcess :: MonadIO m => Process -> m ExitReason #
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.
module Butler.Core.Pipe
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.
Time API
The number of milli secondes since the clock started.
Instances
ToJSON Time # | |
Defined in Butler.Core.Clock | |
Enum Time # | |
Num Time # | |
Integral Time # | |
Real Time # | |
Defined in Butler.Core.Clock toRational :: Time -> Rational # | |
Show Time # | |
Eq Time # | |
Ord Time # | |
ToHtml Time # | |
Serialise Time # | |
From Time Milli # | |
Defined in Butler.Core.Clock | |
From Time ByteString # | |
Defined in Butler.Core.Clock from :: Time -> ByteString # | |
From Time Text # | |
Defined in Butler.Core.Clock | |
From Time Natural # | |
Defined in Butler.Core.Clock | |
From Natural Time # | |
Defined in Butler.Core.Clock |
A duration in millisecond
data WaitResult result #
WaitCompleted result | |
WaitTimeout |
Instances
ToJSON result => ToJSON (WaitResult result) # | |
Defined in Butler.Core.Clock toJSON :: WaitResult result -> Value # toEncoding :: WaitResult result -> Encoding # toJSONList :: [WaitResult result] -> Value # toEncodingList :: [WaitResult result] -> Encoding # | |
Show result => Show (WaitResult result) # | |
Defined in Butler.Core.Clock 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
module Butler.Core.Network
Storage API
newProcessMemory :: Serialise a => StorageAddress -> ProcessIO a -> ProcessIO (a, MemoryVar a) #
module Butler.Core.Memory
newtype StorageAddress #
Instances
module Butler.Core.File
Display API
module Butler.Display.Client
data DisplayEvent #
Instances
App API
A graphical application definition.
App | |
|
data AppSharedContext #
AppSharedContext | |
|
data AppContext #
The application context
AppContext | |
|
defaultApp :: ProgramName -> (AppContext -> ProcessIO ()) -> App #
The type of event an app receive
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) |
Instances
ToJSON AppEvent # | |
Defined in Butler.App | |
Generic AppEvent # | |
type Rep AppEvent # | |
Defined in Butler.App type Rep AppEvent = D1 ('MetaData "AppEvent" "Butler.App" "butler-0.0.1.0-inplace" 'False) ((C1 ('MetaCons "AppDisplay" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DisplayEvent)) :+: C1 ('MetaCons "AppTrigger" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 GuiEvent))) :+: (C1 ('MetaCons "AppData" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DataEvent)) :+: C1 ('MetaCons "AppFile" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Directory) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe File))))) |
GuiEvent | |
|
Instances
ToJSON GuiEvent # | |
Defined in Butler.Display.GUI |
DataEvent | |
|
Instances
ToJSON DataEvent # | |
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.
GUI toolkit
sendHtmlOnConnect :: HtmlT STM () -> AppEvent -> ProcessIO () #
A convenient helper to mount the UI when a new user connect.
module Butler.Display.GUI
module Butler.Window
Prelude
module Butler.Prelude