glazier-0.6.2.0: Composable widgets framework

Safe HaskellNone
LanguageHaskell2010

Glazier.Example

Description

This contains examples of general widget transformation functions.

Synopsis

Documentation

newtype Action a Source #

Constructors

Action 

Fields

Instances

class AsAction s a | s -> a where Source #

Methods

_Action :: Prism' s (Action a) Source #

Instances

newtype ConsAction a Source #

Constructors

ConsAction 

Fields

class AsConsAction s a | s -> a where Source #

data Reset Source #

Constructors

Reset 

class AsReset s where Source #

Methods

_Reset :: Prism' s Reset Source #

data Tail Source #

Constructors

Tail 

Instances

class AsTail s where Source #

Methods

_Tail :: Prism' s Tail Source #

Instances

newtype Set a Source #

Constructors

Set 

Fields

Instances

AsSet (Set a) a Source # 

Methods

_Set :: Prism' (Set a) (Set a) Source #

class AsSet s a | s -> a where Source #

Methods

_Set :: Prism' s (Set a) Source #

Instances

AsSet (Set a) a Source # 

Methods

_Set :: Prism' (Set a) (Set a) Source #

optionalExample :: (Monoid v, Monoid c, Semigroup v, Semigroup c, AsSet a s, AsReset a, AsAction a (Maybe s -> Maybe s), Monad m) => Prism' a a' -> Widget s v m a' c -> Widget (Maybe s) v m a c Source #

Transforms a widget into an optional widget. This wraps the original model inside a Maybe. The new action is now a sum type that contains the additional actions: * A Reset action * A Set action * A mapping action * The original action The original action is wrapped using the given prism and will only modify the state if the preview of the prism is not Nothing. The view will be mempty if the model is Nothing. Widget was a w s m c v Widget s v m a c

listExample :: (Monoid v, Monoid c, Semigroup v, Semigroup c, AsTail a, AsConsAction a s, AsAction a ([s] -> [s]), Monad m) => Prism' b a -> Widget s v m a c -> Widget [s] v m b c Source #

Transforms a widget into an list widget. Given a separator rendering widget, and a widget, this wraps the original model inside a list. The new action is now a sum type that contains the additional actions: * A Tail action * A Cons action * A mapping action * The original action The original action is wrapped using the given prism and will only modify the state of the head. The view will be mempty if Nil.

indexedExample :: (Monoid v, Monoid c, Field2 b b a a, Field1 b b (Index (t s)) (Index (t s)), Ixed (t s), Semigroup v, Semigroup c, AsAction b (t s -> t s), IxValue (t s) ~ s, Monad m, Traversable t) => Widget s v m a c -> Widget (t s) v m b c Source #

Transforms a widget into an dictionary widget. Given a ordering function, a key function, and a separator rendering function, allows a dictionary of k to Widget. The new action is now a sum type that contains the additional actions: * A mapping action * A tuple of (key, original action) The original action is now a tuple with an additional key, which will act on the widget if the key exists in the map.