Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
Control.Reference.Predefined
Contents
Description
- self :: Lens a b a b
- emptyRef :: Simple RefPlus s a
- traverse :: Traversable t => Traversal (t a) (t b) a b
- iso :: (a -> b) -> (b -> a) -> Lens a a b b
- lens :: (s -> a) -> (b -> s -> t) -> Lens s t a b
- partial :: (s -> Either t (a, b -> t)) -> Partial s t a b
- simplePartial :: (s -> Maybe (a, a -> s)) -> Partial s s a a
- fromLens :: (forall f. Functor f => (a -> f b) -> s -> f t) -> Lens s t a b
- fromTraversal :: (forall f. Applicative f => (a -> f b) -> s -> f t) -> Traversal s t a b
- filtered :: (a -> Bool) -> Simple RefPlus a a
- just :: Partial (Maybe a) (Maybe b) a b
- right :: Partial (Either a b) (Either a c) b c
- left :: Partial (Either a c) (Either b c) a b
- anyway :: Lens (Either a a) (Either b b) a b
- both :: Traversal (a, a) (b, b) a b
- _head :: Simple Partial [a] a
- _tail :: Simple Partial [a] [a]
- class Association e where
- type AssocIndex e :: *
- type AssocElem e :: *
- element :: AssocIndex e -> Simple Partial e (AssocElem e)
- data Console = Console
- consoleLine :: Simple IOLens Console String
- mvar :: (Functor w, Applicative w, Monad w, MMorph IO w, MonadBaseControl IO w, Functor r, Applicative r, Monad r, MMorph IO r) => Simple (Reference w r) (MVar a) a
- chan :: Simple IOLens (Chan a) a
- ioref :: Simple IOLens (IORef a) a
- state :: forall s m a. Monad m => Simple (StateLens s m) a s
Trivial references
emptyRef :: Simple RefPlus s a
An empty reference that do not traverse anything
emptyRef &+& a = a &+& emptyRef = a
a & emptyRef = emptyRef & a = emptyRef
Reference generators
traverse :: Traversable t => Traversal (t a) (t b) a b
Generates a traversal for any Traversable
Functor
simplePartial :: (s -> Maybe (a, a -> s)) -> Partial s s a a
Creates a simple partial lens
fromLens :: (forall f. Functor f => (a -> f b) -> s -> f t) -> Lens s t a b
Clones a lens from Control.Lens
fromTraversal :: (forall f. Applicative f => (a -> f b) -> s -> f t) -> Traversal s t a b
Clones a traversal from Control.Lens
filtered :: (a -> Bool) -> Simple RefPlus a a
Filters the traversed elements with a given predicate. Has specific versions for traversals and partial lenses.
References for simple data structures
right :: Partial (Either a b) (Either a c) b c
A partial lens to access the right option of an Either
anyway :: Lens (Either a a) (Either b b) a b
Access the value that is in the left or right state of an Either
class Association e where
Lenses for given values in a data structure that is indexed by keys.
Methods
element :: AssocIndex e -> Simple Partial e (AssocElem e)
Instances
Association [a] | |
Ord k => Association (Map k v) |
Stateful references
consoleLine :: Simple IOLens Console String
Interacts with a line of text on the console. Values set are printed, getting is reading from the console.
mvar :: (Functor w, Applicative w, Monad w, MMorph IO w, MonadBaseControl IO w, Functor r, Applicative r, Monad r, MMorph IO r) => Simple (Reference w r) (MVar a) a
Access a value inside an MVar. Setting is not atomic. If there is two supplier that may set the accessed value, one may block and can corrupt the following updates.
Reads and updates are done in sequence, always using consistent data.