garden
Safe HaskellSafe-Inferred
LanguageHaskell2010

UI

Synopsis

Documentation

data UI a Source #

DSL based on Termbox2 for UI drawing operations The decisions to not derive MonadIO or export the constructor are deliberate.

Instances

Instances details
Applicative UI Source # 
Instance details

Defined in UI

Methods

pure :: a -> UI a Source #

(<*>) :: UI (a -> b) -> UI a -> UI b Source #

liftA2 :: (a -> b -> c) -> UI a -> UI b -> UI c Source #

(*>) :: UI a -> UI b -> UI b Source #

(<*) :: UI a -> UI b -> UI a Source #

Functor UI Source # 
Instance details

Defined in UI

Methods

fmap :: (a -> b) -> UI a -> UI b Source #

(<$) :: a -> UI b -> UI a Source #

Monad UI Source # 
Instance details

Defined in UI

Methods

(>>=) :: UI a -> (a -> UI b) -> UI b Source #

(>>) :: UI a -> UI b -> UI b Source #

return :: a -> UI a Source #

mkUI :: Termbox2 a -> UI a Source #

runUI :: UI a -> IO a Source #

newtype Action space effect a Source #

Constructors

Action 

Fields

  • work :: forall r. space (a -> effect r) -> effect r
     

Instances

Instances details
Comonad w => MonadTrans (Action w) Source # 
Instance details

Defined in UI

Methods

lift :: Monad m => m a -> Action w m a Source #

(Comonad w, MonadIO m) => MonadIO (Action w m) Source # 
Instance details

Defined in UI

Methods

liftIO :: IO a -> Action w m a Source #

Comonad w => Applicative (Action w m) Source # 
Instance details

Defined in UI

Methods

pure :: a -> Action w m a Source #

(<*>) :: Action w m (a -> b) -> Action w m a -> Action w m b Source #

liftA2 :: (a -> b -> c) -> Action w m a -> Action w m b -> Action w m c Source #

(*>) :: Action w m a -> Action w m b -> Action w m b Source #

(<*) :: Action w m a -> Action w m b -> Action w m a Source #

Functor space => Functor (Action space effect) Source # 
Instance details

Defined in UI

Methods

fmap :: (a -> b) -> Action space effect a -> Action space effect b Source #

(<$) :: a -> Action space effect b -> Action space effect a Source #

Comonad w => Monad (Action w m) Source # 
Instance details

Defined in UI

Methods

(>>=) :: Action w m a -> (a -> Action w m b) -> Action w m b Source #

(>>) :: Action w m a -> Action w m b -> Action w m b Source #

return :: a -> Action w m a Source #

nil :: Comonad f => Action f m () Source #

Alias for the universal do-nothing Action.

mount :: Comonad w => Component IO w (Action w) Console -> IO () Source #

Sets up a component for execution and catches exceptions.

type BehaviorOf = Cofree Source #

Cofree does exactly what we want but has an unintuitive name.

behavior :: Functor f => (a -> f a) -> a -> BehaviorOf f a Source #

coiter does exactly what we want but has an unintuitive name. concept: instead of coiter, use Representable and index

unwrap :: ComonadCofree f w => w a -> f (w a) #

type Screen w m = Component m w (Action w) Console Source #

Legible alias for a common component type.

screen Source #

Arguments

:: t 
-> (t -> UI ())

render

-> (Event -> a)

update

-> Store t ((a -> IO ()) -> Console) 

Construct a screen component with a given behavior.

modify :: ComonadStore s w => (s -> s) -> Action w m () Source #

put :: ComonadStore s w => s -> Action w m () Source #

get :: ComonadStore s w => Action w m s Source #

data Event Source #

Constructors

Resize Int Int 
KeyboardInput Int 

Instances

Instances details
Show Event Source # 
Instance details

Defined in UI

Eq Event Source # 
Instance details

Defined in UI

Methods

(==) :: Event -> Event -> Bool Source #

(/=) :: Event -> Event -> Bool Source #

type With = Day Source #

Day does exactly what we want but has an unintuitive name.

(<->) :: f x -> g y -> With f g (x, y) Source #

drawBlock :: Int -> Int -> UI () Source #

drawRect :: Int -> Int -> Int -> Int -> UI () Source #

type Callback base action = action base () -> base () Source #

type Interaction base action view = Callback base action -> view Source #

type Component base space action view = space (Interaction base action view) Source #

data Console Source #

A console view.

Constructors

Console 

Fields

  • (UI ())

    Renders output when called.

  • (Event -> IO ())

    Awaits incoming events.

move :: Functor w => (a -> b -> m r) -> Action w m a -> w b -> m r Source #

type Store s = StoreT s Identity #

store :: (s -> a) -> s -> Store s a #

runStore :: Store s a -> (s -> a, s) #