Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- module Simple.UI.Core.UIApp
- module Simple.UI.Core.Draw
- module Simple.UI.Core.Attribute
- module Simple.UI.Core.ListenerList
- module Simple.UI.Layouts.FillLayout
- module Simple.UI.Layouts.SingleLayout
- module Simple.UI.Utils
- module Simple.UI.Widgets.Properties.Selected
- module Simple.UI.Widgets.Widget
- module Simple.UI.Widgets.Container
- module Simple.UI.Widgets.Edit
- module Simple.UI.Widgets.Label
- module Simple.UI.Widgets.TextListView
- module Simple.UI.Widgets.TextView
- module Simple.UI.Widgets.TextItem
- module Simple.UI.Widgets.StatusBar
- module Simple.UI.Widgets.Text
- module Simple.UI.Widgets.Window
- module Simple.UI.Widgets.SimpleMenuBar
- module Simple.UI.Widgets.SimpleMenuItem
- (.=) :: MonadState s m => ASetter s s a b -> b -> m ()
- assign :: MonadState s m => ASetter s s a b -> b -> m ()
- view :: MonadReader s m => Getting a s a -> m a
- (^.) :: s -> Getting a s a -> a
Documentation
module Simple.UI.Core.UIApp
module Simple.UI.Core.Draw
module Simple.UI.Core.Attribute
module Simple.UI.Core.ListenerList
module Simple.UI.Layouts.FillLayout
module Simple.UI.Utils
module Simple.UI.Widgets.Widget
module Simple.UI.Widgets.Container
module Simple.UI.Widgets.Edit
module Simple.UI.Widgets.Label
module Simple.UI.Widgets.TextView
module Simple.UI.Widgets.TextItem
module Simple.UI.Widgets.StatusBar
module Simple.UI.Widgets.Text
module Simple.UI.Widgets.Window
(.=) :: MonadState s m => ASetter s s a b -> b -> m () infix 4 #
Replace the target of a Lens
or all of the targets of a Setter
or Traversal
in our monadic state with a new value, irrespective of the
old.
This is an infix version of assign
.
>>>
execState (do _1 .= c; _2 .= d) (a,b)
(c,d)
>>>
execState (both .= c) (a,b)
(c,c)
(.=
) ::MonadState
s m =>Iso'
s a -> a -> m () (.=
) ::MonadState
s m =>Lens'
s a -> a -> m () (.=
) ::MonadState
s m =>Traversal'
s a -> a -> m () (.=
) ::MonadState
s m =>Setter'
s a -> a -> m ()
It puts the state in the monad or it gets the hose again.
assign :: MonadState s m => ASetter s s a b -> b -> m () #
Replace the target of a Lens
or all of the targets of a Setter
or Traversal
in our monadic
state with a new value, irrespective of the old.
This is an alias for (.=
).
>>>
execState (do assign _1 c; assign _2 d) (a,b)
(c,d)
>>>
execState (both .= c) (a,b)
(c,c)
assign
::MonadState
s m =>Iso'
s a -> a -> m ()assign
::MonadState
s m =>Lens'
s a -> a -> m ()assign
::MonadState
s m =>Traversal'
s a -> a -> m ()assign
::MonadState
s m =>Setter'
s a -> a -> m ()
view :: MonadReader s m => Getting a s a -> m a #
View the value pointed to by a Getter
, Iso
or
Lens
or the result of folding over all the results of a
Fold
or Traversal
that points
at a monoidal value.
view
.
to
≡id
>>>
view (to f) a
f a
>>>
view _2 (1,"hello")
"hello"
>>>
view (to succ) 5
6
>>>
view (_2._1) ("hello",("world","!!!"))
"world"
As view
is commonly used to access the target of a Getter
or obtain a monoidal summary of the targets of a Fold
,
It may be useful to think of it as having one of these more restricted signatures:
view
::Getter
s a -> s -> aview
::Monoid
m =>Fold
s m -> s -> mview
::Iso'
s a -> s -> aview
::Lens'
s a -> s -> aview
::Monoid
m =>Traversal'
s m -> s -> m
In a more general setting, such as when working with a Monad
transformer stack you can use:
view
::MonadReader
s m =>Getter
s a -> m aview
:: (MonadReader
s m,Monoid
a) =>Fold
s a -> m aview
::MonadReader
s m =>Iso'
s a -> m aview
::MonadReader
s m =>Lens'
s a -> m aview
:: (MonadReader
s m,Monoid
a) =>Traversal'
s a -> m a
(^.) :: s -> Getting a s a -> a infixl 8 #
View the value pointed to by a Getter
or Lens
or the
result of folding over all the results of a Fold
or
Traversal
that points at a monoidal values.
This is the same operation as view
with the arguments flipped.
The fixity and semantics are such that subsequent field accesses can be
performed with (.
).
>>>
(a,b)^._2
b
>>>
("hello","world")^._2
"world"
>>>
import Data.Complex
>>>
((0, 1 :+ 2), 3)^._1._2.to magnitude
2.23606797749979
(^.
) :: s ->Getter
s a -> a (^.
) ::Monoid
m => s ->Fold
s m -> m (^.
) :: s ->Iso'
s a -> a (^.
) :: s ->Lens'
s a -> a (^.
) ::Monoid
m => s ->Traversal'
s m -> m