glazier-0.5.0.0: Composable widgets framework

Safe HaskellNone
LanguageHaskell2010

Glazier

Description

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

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

The Elm View/Brief 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 implementations Brief and View 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 #

HasWindow (Widget s0 v0 m0 a0 c0) (Window m0 s0 v0) Source # 

Methods

window :: Lens' (Widget s0 v0 m0 a0 c0) (Window m0 s0 v0) Source #

HasWindow (Widget s0 v0 m0 a0 c0) (Window m0 s0 v0) Source # 

Methods

window :: Lens' (Widget s0 v0 m0 a0 c0) (Window m0 s0 v0) 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

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

This in conjuction with Wrapped instance 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 = _WindowT %~ f

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

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

Non polymorphic version of _WindowT

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

type family Implanted m :: * -> * Source #

Modify the state given a lens, prism or traversal. NB. This is Zoom for Notify.

Instances

type Implanted (Window m s v) Source # 
type Implanted (Window m s v) = Effect m v
type Implanted (Gadget s m a c) Source # 
type Implanted (Gadget s m a c) = Zoomed (Gadget s m a) c
type Implanted (Gadget s m a c) Source # 
type Implanted (Gadget s m a c) = Zoomed (Gadget s m a) c
type Implanted (Widget s v m a c) Source # 
type Implanted (Widget s v m a c)
type Implanted (Widget s v m a c) Source # 
type Implanted (Widget s v m a c)

class Implant m n s t | m -> s, n -> t, m t -> n, n s -> m where Source #

Minimal complete definition

implant

Methods

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

Instances

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 #

Monad m => Implant (Gadget s m a c) (Gadget t m a c) s t Source # 

Methods

implant :: LensLike' (Implanted (Gadget s m a c)) t s -> Gadget s m a c -> Gadget t m a c Source #

Monad m => Implant (Gadget s m a c) (Gadget t m a c) s t Source # 

Methods

implant :: LensLike' (Implanted (Gadget s m a c)) t s -> Gadget s m a c -> Gadget t m a c Source #

Monad m => Implant (Widget s v m a c) (Widget t v m a c) s t Source # 

Methods

implant :: LensLike' (Implanted (Widget s v m a c)) t s -> Widget s v m a c -> Widget t v m a c Source #

Monad m => Implant (Widget s v m a c) (Widget t v m a c) s t Source # 

Methods

implant :: LensLike' (Implanted (Widget s v m a c)) t s -> Widget s v m a c -> Widget t v m a c Source #

type family Dispatched m :: * -> * Source #

Instances

type Dispatched (Gadget s m a c) Source # 
type Dispatched (Gadget s m a c) = Magnified (Gadget s m a) c
type Dispatched (Gadget s m a c) Source # 
type Dispatched (Gadget s m a c) = Magnified (Gadget s m a) c
type Dispatched (Widget s v m a c) Source # 
type Dispatched (Widget s v m a c) = Dispatched (Gadget s m a c)
type Dispatched (Widget s v m a c) Source # 
type Dispatched (Widget s v m a c) = Dispatched (Gadget s m a c)

class Dispatch m n b a | m -> b, n -> a, m a -> n, n b -> m where Source #

Changes the action type given a lens, prism or traversal

Minimal complete definition

dispatch

Methods

dispatch :: LensLike' (Dispatched m) a b -> m -> n Source #

Instances

Monad m => Dispatch (Gadget s m a c) (Gadget s m b c) a b Source # 

Methods

dispatch :: LensLike' (Dispatched (Gadget s m a c)) b a -> Gadget s m a c -> Gadget s m b c Source #

Monad m => Dispatch (Gadget s m a c) (Gadget s m b c) a b Source # 

Methods

dispatch :: LensLike' (Dispatched (Gadget s m a c)) b a -> Gadget s m a c -> Gadget s m b c Source #

Monad m => Dispatch (Widget s v m a c) (Widget s v m b c) a b Source # 

Methods

dispatch :: LensLike' (Dispatched (Widget s v m a c)) b a -> Widget s v m a c -> Widget s v m b c Source #

Monad m => Dispatch (Widget s v m a c) (Widget s v m b c) a b Source # 

Methods

dispatch :: LensLike' (Dispatched (Widget s v m a c)) b a -> Widget s v m a c -> Widget s v m b c Source #