Safe Haskell | None |
---|---|
Language | Haskell2010 |
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.
- newtype WindowT s v m r = WindowT {
- runWindowT :: ReaderT s (StateT v m) r
- type Window s v = WindowT s v Identity
- _WindowT :: Iso (WindowT s v m r) (WindowT s' v' m' r') (s -> v -> m (r, v)) (s' -> v' -> m' (r', v'))
- _WindowT' :: Iso' (WindowT s v m r) (s -> v -> m (r, v))
- mkWindowT' :: (s -> v -> m (r, v)) -> WindowT s v m r
- runWindowT' :: WindowT s v m r -> s -> v -> m (r, v)
- belowWindowT :: ((s -> v -> m (r, v)) -> s' -> v' -> m' (r', v')) -> WindowT s v m r -> WindowT s' v' m' r'
- underWindowT :: (ReaderT s (StateT v m) r -> ReaderT s' (StateT v' m') r') -> WindowT s v m r -> WindowT s' v' m' r'
- overWindowT :: (WindowT s v m r -> WindowT s' v' m' r') -> ReaderT s (StateT v m) r -> ReaderT s' (StateT v' m') r'
- aboveWindowT :: (WindowT s v m r -> WindowT s' v' m' r') -> (s -> v -> m (r, v)) -> s' -> v' -> m' (r', v')
Documentation
newtype WindowT s v m r Source #
The Elm view function is basically view :: model -> html
This is be ehanced with monadic effects with ReaderT.
The render output can be wrapped in a WriterT to make it more composable.
We use a CPS-style WriterT (ie a StateT) to avoid space leaks.
This is named Window instead of View to avoid confusion with view from Control.Lens
NB. This is the same formulation as GadgetT
.
The only difference is WindowT
only has Implant
instance.
WindowT | |
|
_WindowT :: Iso (WindowT s v m r) (WindowT s' v' m' r') (s -> v -> m (r, v)) (s' -> v' -> m' (r', v')) Source #
mkWindowT' :: (s -> v -> m (r, v)) -> WindowT s v m r Source #
runWindowT' :: WindowT s v m r -> s -> v -> m (r, v) Source #
belowWindowT :: ((s -> v -> m (r, v)) -> s' -> v' -> m' (r', v')) -> WindowT s v m r -> WindowT s' v' m' r' Source #
underWindowT :: (ReaderT s (StateT v m) r -> ReaderT s' (StateT v' m') r') -> WindowT s v m r -> WindowT s' v' m' r' Source #
overWindowT :: (WindowT s v m r -> WindowT s' v' m' r') -> ReaderT s (StateT v m) r -> ReaderT s' (StateT v' m') r' Source #
aboveWindowT :: (WindowT s v m r -> WindowT s' v' m' r') -> (s -> v -> m (r, v)) -> s' -> v' -> m' (r', v') Source #