glazier-0.8.0.0: Composable widgets framework

Safe HaskellNone
LanguageHaskell2010

Glazier.Window

Description

Functional version of (Elm View/Update & startApp architecture) enabling composable widgets, and a FRP-like framework.

This framework makes it easier to modularize the Elm architecture idea of View/Update: based on the deprecated Elm Architecture version of Jan 2016 https://github.com/evancz/elm-architecture-tutorial/tree/de5682a5a8e4459aed4637533adb25e462f8a2ae

The Elm View/Update is basically as follows:

data Model = Blah....
data Action = DoThis | DoThat deriving Show

-- | update is fired from an event processing loop
update :: Action -> Model -> Model

-- | The widget from view knows how to send Action to a mailbox
view :: Signal Address -> Model -> Html

This module uses isomorphic Window and Gadget resulting in instances can be be composed together into larger Widgets. Original inspiration from https://arianvp.me/lenses-and-prisms-for-modular-clientside-apps/

This framework provides three main combinators: * Semigroup and Monoid instances for concatenating widgets. * dispatch is used to re-route the action type. * implant is used to modify the model type.

Synopsis

Documentation

newtype Window m s v Source #

The Elm view function is basically view :: model -> html NB. elm-html is actually view :: Signal.Address action -> model -> html where Signal.Address action is the Pipes.Concurrent.Output that is sent actions (eg. when html button is clicked). This address argument is not required in the general case, and is only required for specific widgets on an as needed basis. Therefore, using the fundamental type of view :: model -> html This is be ehanced with monadic effects with ReaderT. This is named Window instead of View to avoid confusion with view from Control.Lens

Constructors

Window 

Fields

Instances

Monad m => MonadReader s (Window m s) Source # 

Methods

ask :: Window m s s #

local :: (s -> s) -> Window m s a -> Window m s a #

reader :: (s -> a) -> Window m s a #

Monad m => Arrow (Window m) Source # 

Methods

arr :: (b -> c) -> Window m b c #

first :: Window m b c -> Window m (b, d) (c, d) #

second :: Window m b c -> Window m (d, b) (d, c) #

(***) :: Window m b c -> Window m b' c' -> Window m (b, b') (c, c') #

(&&&) :: Window m b c -> Window m b c' -> Window m b (c, c') #

MonadPlus m => ArrowZero (Window m) Source # 

Methods

zeroArrow :: Window m b c #

MonadPlus m => ArrowPlus (Window m) Source # 

Methods

(<+>) :: Window m b c -> Window m b c -> Window m b c #

Monad m => ArrowChoice (Window m) Source # 

Methods

left :: Window m b c -> Window m (Either b d) (Either c d) #

right :: Window m b c -> Window m (Either d b) (Either d c) #

(+++) :: Window m b c -> Window m b' c' -> Window m (Either b b') (Either c c') #

(|||) :: Window m b d -> Window m c d -> Window m (Either b c) d #

Monad m => ArrowApply (Window m) Source # 

Methods

app :: Window m (Window m b c, b) c #

Monad m => Profunctor (Window m) Source # 

Methods

dimap :: (a -> b) -> (c -> d) -> Window m b c -> Window m a d #

lmap :: (a -> b) -> Window m b c -> Window m a c #

rmap :: (b -> c) -> Window m a b -> Window m a c #

(#.) :: Coercible * c b => (b -> c) -> Window m a b -> Window m a c #

(.#) :: Coercible * b a => Window m b c -> (a -> b) -> Window m a c #

Monad m => Choice (Window m) Source # 

Methods

left' :: Window m a b -> Window m (Either a c) (Either b c) #

right' :: Window m a b -> Window m (Either c a) (Either c b) #

Monad m => Strong (Window m) Source # 

Methods

first' :: Window m a b -> Window m (a, c) (b, c) #

second' :: Window m a b -> Window m (c, a) (c, b) #

Monad m => Category * (Window m) Source # 

Methods

id :: cat a a #

(.) :: cat b c -> cat a b -> cat a c #

Monad m => Monad (Window m s) Source # 

Methods

(>>=) :: Window m s a -> (a -> Window m s b) -> Window m s b #

(>>) :: Window m s a -> Window m s b -> Window m s b #

return :: a -> Window m s a #

fail :: String -> Window m s a #

Functor m => Functor (Window m s) Source # 

Methods

fmap :: (a -> b) -> Window m s a -> Window m s b #

(<$) :: a -> Window m s b -> Window m s a #

MonadFix m => MonadFix (Window m s) Source # 

Methods

mfix :: (a -> Window m s a) -> Window m s a #

MonadFail m => MonadFail (Window m s) Source # 

Methods

fail :: String -> Window m s a #

Applicative m => Applicative (Window m s) Source # 

Methods

pure :: a -> Window m s a #

(<*>) :: Window m s (a -> b) -> Window m s a -> Window m s b #

(*>) :: Window m s a -> Window m s b -> Window m s b #

(<*) :: Window m s a -> Window m s b -> Window m s a #

MonadZip m => MonadZip (Window m s) Source # 

Methods

mzip :: Window m s a -> Window m s b -> Window m s (a, b) #

mzipWith :: (a -> b -> c) -> Window m s a -> Window m s b -> Window m s c #

munzip :: Window m s (a, b) -> (Window m s a, Window m s b) #

MonadIO m => MonadIO (Window m s) Source # 

Methods

liftIO :: IO a -> Window m s a #

Alternative m => Alternative (Window m s) Source # 

Methods

empty :: Window m s a #

(<|>) :: Window m s a -> Window m s a -> Window m s a #

some :: Window m s a -> Window m s [a] #

many :: Window m s a -> Window m s [a] #

MonadPlus m => MonadPlus (Window m s) Source # 

Methods

mzero :: Window m s a #

mplus :: Window m s a -> Window m s a -> Window m s a #

(Applicative m, Semigroup v) => Semigroup (Window m s v) Source # 

Methods

(<>) :: Window m s v -> Window m s v -> Window m s v #

sconcat :: NonEmpty (Window m s v) -> Window m s v #

stimes :: Integral b => b -> Window m s v -> Window m s v #

(Applicative m, Monoid v) => Monoid (Window m s v) Source # 

Methods

mempty :: Window m s v #

mappend :: Window m s v -> Window m s v -> Window m s v #

mconcat :: [Window m s v] -> Window m s v #

Wrapped (Window m0 s0 v0) Source # 

Associated Types

type Unwrapped (Window m0 s0 v0) :: * #

Methods

_Wrapped' :: Iso' (Window m0 s0 v0) (Unwrapped (Window m0 s0 v0)) #

(~) * (Window m0 s0 v0) t0 => Rewrapped (Window m1 s1 v1) t0 Source # 
Monad m => Implant (Window m s v) (Window m t v) s t Source # 

Methods

implant :: LensLike' (Implanted (Window m s v)) t s -> Window m s v -> Window m t v Source #

type Unwrapped (Window m0 s0 v0) Source # 
type Unwrapped (Window m0 s0 v0) = ReaderT * s0 m0 v0
type Implanted (Window m s v) Source # 
type Implanted (Window m s v) = Effect m v

hoistWindow :: Monad m => (forall a. m a -> n a) -> Window m s v -> Window n s v Source #

NB lift can be simulated: liftWindow :: (MonadTrans t, Monad m) => Window m s v -> Window (t m) s v liftWindow = hoistWindow lift

_Window :: Iso (Window m s v) (Window m' s' v') (s -> m v) (s' -> m' v') Source #

This Iso gives the following functions:

liftWindow :: (MonadTrans t, Monad m) => Window m s v -> Window (t m) s v
liftWindow = hoistWindow lift

underWindow :: (ReaderT s m v -> ReaderT s' m' v') -> Window m s v -> Window m' s' v'
underWindow f = _Wrapping Window %~ f

overWindow :: (Window m s v -> Window m' s' v') -> ReaderT s m v -> ReaderT s' m' v'
overWindow f = _Unwrapping Window %~ f

belowWindow :: ((s -> m v) -> (s' -> m' v')) -> Window m s v -> Window m' s' v'
belowWindow f = _Window %~ f

aboveWindow :: (Window m s v -> Window m' s' v') -> (s -> m v) -> (s' -> m' v')
aboveWindow f = from _Window %~ f

mkWindow' :: (s -> m v) -> Window m s v
mkWindow' = review _Window

runWindow' :: Window m s v -> (s -> m v)
runWindow' = view _Window

_Window' :: Iso' (Window m s v) (s -> m v) Source #

Non polymorphic version of _Window