Copyright | (C) 2012-16 Edward Kmett |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | provisional |
Portability | Rank2Types |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Control.Lens.Getter
Description
A
is just any function Getter
s a(s -> a)
, which we've flipped
into continuation passing style, (a -> r) -> s -> r
and decorated
with Const
to obtain:
typeGetting
r s a = (a ->Const
r a) -> s ->Const
r s
If we restrict access to knowledge about the type r
, we could get:
typeGetter
s a = forall r.Getting
r s a
However, for Getter
(but not for Getting
) we actually permit any
functor f
which is an instance of both Functor
and Contravariant
:
typeGetter
s a = forall f. (Contravariant
f,Functor
f) => (a -> f a) -> s -> f s
Everything you can do with a function, you can do with a Getter
, but
note that because of the continuation passing style (.
) composes them
in the opposite order.
Since it is only a function, every Getter
obviously only retrieves a
single value for a given input.
A common question is whether you can combine multiple Getter
s to
retrieve multiple values. Recall that all Getter
s are Fold
s and that
we have a
instance to play
with. Knowing this, we can use Monoid
m => Applicative
(Const
m)
to glue <>
Fold
s
together:
>>>
(1, 2, 3, 4, 5) ^.. (_2 <> _3 <> _5)
[2,3,5]
Synopsis
- type Getter s a = forall f. (Contravariant f, Functor f) => (a -> f a) -> s -> f s
- type IndexedGetter i s a = forall p f. (Indexable i p, Contravariant f, Functor f) => p a (f a) -> s -> f s
- type Getting r s a = (a -> Const r a) -> s -> Const r s
- type IndexedGetting i m s a = Indexed i a (Const m a) -> s -> Const m s
- type Accessing p m s a = p a (Const m a) -> s -> Const m s
- to :: (Profunctor p, Contravariant f) => (s -> a) -> Optic' p f s a
- ito :: (Indexable i p, Contravariant f) => (s -> (i, a)) -> Over' p f s a
- like :: (Profunctor p, Contravariant f, Functor f) => a -> Optic' p f s a
- ilike :: (Indexable i p, Contravariant f, Functor f) => i -> a -> Over' p f s a
- (^.) :: s -> Getting a s a -> a
- view :: MonadReader s m => Getting a s a -> m a
- views :: MonadReader s m => LensLike' (Const r) s a -> (a -> r) -> m r
- use :: MonadState s m => Getting a s a -> m a
- uses :: MonadState s m => LensLike' (Const r) s a -> (a -> r) -> m r
- listening :: MonadWriter w m => Getting u w u -> m a -> m (a, u)
- listenings :: MonadWriter w m => Getting v w u -> (u -> v) -> m a -> m (a, v)
- (^@.) :: s -> IndexedGetting i (i, a) s a -> (i, a)
- iview :: MonadReader s m => IndexedGetting i (i, a) s a -> m (i, a)
- iviews :: MonadReader s m => IndexedGetting i r s a -> (i -> a -> r) -> m r
- iuse :: MonadState s m => IndexedGetting i (i, a) s a -> m (i, a)
- iuses :: MonadState s m => IndexedGetting i r s a -> (i -> a -> r) -> m r
- ilistening :: MonadWriter w m => IndexedGetting i (i, u) w u -> m a -> m (a, (i, u))
- ilistenings :: MonadWriter w m => IndexedGetting i v w u -> (i -> u -> v) -> m a -> m (a, v)
- class Contravariant (f :: Type -> Type) where
- getting :: (Profunctor p, Profunctor q, Functor f, Contravariant f) => Optical p q f s t a b -> Optical' p q f s a
- newtype Const a (b :: k) = Const {
- getConst :: a
Getters
type Getter s a = forall f. (Contravariant f, Functor f) => (a -> f a) -> s -> f s Source #
A Getter
describes how to retrieve a single value in a way that can be
composed with other LensLike
constructions.
Unlike a Lens
a Getter
is read-only. Since a Getter
cannot be used to write back there are no Lens
laws that can be applied to
it. In fact, it is isomorphic to an arbitrary function from (s -> a)
.
Moreover, a Getter
can be used directly as a Fold
,
since it just ignores the Applicative
.
type IndexedGetter i s a = forall p f. (Indexable i p, Contravariant f, Functor f) => p a (f a) -> s -> f s Source #
Every IndexedGetter
is a valid IndexedFold
and can be used for Getting
like a Getter
.
type Getting r s a = (a -> Const r a) -> s -> Const r s Source #
When you see this in a type signature it indicates that you can
pass the function a Lens
, Getter
,
Traversal
, Fold
,
Prism
, Iso
, or one of
the indexed variants, and it will just "do the right thing".
Most Getter
combinators are able to be used with both a Getter
or a
Fold
in limited situations, to do so, they need to be
monomorphic in what we are going to extract with Const
. To be compatible
with Lens
, Traversal
and
Iso
we also restricted choices of the irrelevant t
and
b
parameters.
If a function accepts a
, then when Getting
r s ar
is a Monoid
, then
you can pass a Fold
(or
Traversal
), otherwise you can only pass this a
Getter
or Lens
.
type IndexedGetting i m s a = Indexed i a (Const m a) -> s -> Const m s Source #
Used to consume an IndexedFold
.
type Accessing p m s a = p a (Const m a) -> s -> Const m s Source #
This is a convenient alias used when consuming (indexed) getters and (indexed) folds in a highly general fashion.
Building Getters
to :: (Profunctor p, Contravariant f) => (s -> a) -> Optic' p f s a Source #
ito :: (Indexable i p, Contravariant f) => (s -> (i, a)) -> Over' p f s a Source #
ito
:: (s -> (i, a)) ->IndexedGetter
i s a
like :: (Profunctor p, Contravariant f, Functor f) => a -> Optic' p f s a Source #
ilike :: (Indexable i p, Contravariant f, Functor f) => i -> a -> Over' p f s a Source #
ilike
:: i -> a ->IndexedGetter
i s a
Combinators for Getters and Folds
(^.) :: s -> Getting a s a -> a infixl 8 Source #
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
view :: MonadReader s m => Getting a s a -> m a Source #
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
views :: MonadReader s m => LensLike' (Const r) s a -> (a -> r) -> m r Source #
View a function of the value pointed to by a Getter
or Lens
or the result of
folding over the result of mapping the targets of a Fold
or
Traversal
.
views
l f ≡view
(l.
to
f)
>>>
views (to f) g a
g (f a)
>>>
views _2 length (1,"hello")
5
As views
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:
views
::Getter
s a -> (a -> r) -> s -> rviews
::Monoid
m =>Fold
s a -> (a -> m) -> s -> mviews
::Iso'
s a -> (a -> r) -> s -> rviews
::Lens'
s a -> (a -> r) -> s -> rviews
::Monoid
m =>Traversal'
s a -> (a -> m) -> s -> m
In a more general setting, such as when working with a Monad
transformer stack you can use:
views
::MonadReader
s m =>Getter
s a -> (a -> r) -> m rviews
:: (MonadReader
s m,Monoid
r) =>Fold
s a -> (a -> r) -> m rviews
::MonadReader
s m =>Iso'
s a -> (a -> r) -> m rviews
::MonadReader
s m =>Lens'
s a -> (a -> r) -> m rviews
:: (MonadReader
s m,Monoid
r) =>Traversal'
s a -> (a -> r) -> m r
views
::MonadReader
s m =>Getting
r s a -> (a -> r) -> m r
use :: MonadState s m => Getting a s a -> m a Source #
Use the target of a Lens
, Iso
, or
Getter
in the current state, or use a summary of a
Fold
or Traversal
that points
to a monoidal value.
>>>
evalState (use _1) (a,b)
a
>>>
evalState (use _1) ("hello","world")
"hello"
use
::MonadState
s m =>Getter
s a -> m ause
:: (MonadState
s m,Monoid
r) =>Fold
s r -> m ruse
::MonadState
s m =>Iso'
s a -> m ause
::MonadState
s m =>Lens'
s a -> m ause
:: (MonadState
s m,Monoid
r) =>Traversal'
s r -> m r
uses :: MonadState s m => LensLike' (Const r) s a -> (a -> r) -> m r Source #
Use the target of a Lens
, Iso
or
Getter
in the current state, or use a summary of a
Fold
or Traversal
that
points to a monoidal value.
>>>
evalState (uses _1 length) ("hello","world")
5
uses
::MonadState
s m =>Getter
s a -> (a -> r) -> m ruses
:: (MonadState
s m,Monoid
r) =>Fold
s a -> (a -> r) -> m ruses
::MonadState
s m =>Lens'
s a -> (a -> r) -> m ruses
::MonadState
s m =>Iso'
s a -> (a -> r) -> m ruses
:: (MonadState
s m,Monoid
r) =>Traversal'
s a -> (a -> r) -> m r
uses
::MonadState
s m =>Getting
r s t a b -> (a -> r) -> m r
listening :: MonadWriter w m => Getting u w u -> m a -> m (a, u) Source #
This is a generalized form of listen
that only extracts the portion of
the log that is focused on by a Getter
. If given a Fold
or a Traversal
then a monoidal summary of the parts of the log that are visited will be
returned.
listening
::MonadWriter
w m =>Getter
w u -> m a -> m (a, u)listening
::MonadWriter
w m =>Lens'
w u -> m a -> m (a, u)listening
::MonadWriter
w m =>Iso'
w u -> m a -> m (a, u)listening
:: (MonadWriter
w m,Monoid
u) =>Fold
w u -> m a -> m (a, u)listening
:: (MonadWriter
w m,Monoid
u) =>Traversal'
w u -> m a -> m (a, u)listening
:: (MonadWriter
w m,Monoid
u) =>Prism'
w u -> m a -> m (a, u)
listenings :: MonadWriter w m => Getting v w u -> (u -> v) -> m a -> m (a, v) Source #
This is a generalized form of listen
that only extracts the portion of
the log that is focused on by a Getter
. If given a Fold
or a Traversal
then a monoidal summary of the parts of the log that are visited will be
returned.
listenings
::MonadWriter
w m =>Getter
w u -> (u -> v) -> m a -> m (a, v)listenings
::MonadWriter
w m =>Lens'
w u -> (u -> v) -> m a -> m (a, v)listenings
::MonadWriter
w m =>Iso'
w u -> (u -> v) -> m a -> m (a, v)listenings
:: (MonadWriter
w m,Monoid
v) =>Fold
w u -> (u -> v) -> m a -> m (a, v)listenings
:: (MonadWriter
w m,Monoid
v) =>Traversal'
w u -> (u -> v) -> m a -> m (a, v)listenings
:: (MonadWriter
w m,Monoid
v) =>Prism'
w u -> (u -> v) -> m a -> m (a, v)
Indexed Getters
Indexed Getter Combinators
(^@.) :: s -> IndexedGetting i (i, a) s a -> (i, a) infixl 8 Source #
View the index and value of an IndexedGetter
or IndexedLens
.
This is the same operation as iview
with the arguments flipped.
The fixity and semantics are such that subsequent field accesses can be
performed with (.
).
(^@.
) :: s ->IndexedGetter
i s a -> (i, a) (^@.
) :: s ->IndexedLens'
i s a -> (i, a)
The result probably doesn't have much meaning when applied to an IndexedFold
.
iview :: MonadReader s m => IndexedGetting i (i, a) s a -> m (i, a) Source #
View the index and value of an IndexedGetter
into the current environment as a pair.
When applied to an IndexedFold
the result will most likely be a nonsensical monoidal summary of
the indices tupled with a monoidal summary of the values and probably not whatever it is you wanted.
iviews :: MonadReader s m => IndexedGetting i r s a -> (i -> a -> r) -> m r Source #
View a function of the index and value of an IndexedGetter
into the current environment.
When applied to an IndexedFold
the result will be a monoidal summary instead of a single answer.
iviews
≡ifoldMapOf
iuse :: MonadState s m => IndexedGetting i (i, a) s a -> m (i, a) Source #
Use the index and value of an IndexedGetter
into the current state as a pair.
When applied to an IndexedFold
the result will most likely be a nonsensical monoidal summary of
the indices tupled with a monoidal summary of the values and probably not whatever it is you wanted.
iuses :: MonadState s m => IndexedGetting i r s a -> (i -> a -> r) -> m r Source #
Use a function of the index and value of an IndexedGetter
into the current state.
When applied to an IndexedFold
the result will be a monoidal summary instead of a single answer.
ilistening :: MonadWriter w m => IndexedGetting i (i, u) w u -> m a -> m (a, (i, u)) Source #
This is a generalized form of listen
that only extracts the portion of
the log that is focused on by a Getter
. If given a Fold
or a Traversal
then a monoidal summary of the parts of the log that are visited will be
returned.
ilistening
::MonadWriter
w m =>IndexedGetter
i w u -> m a -> m (a, (i, u))ilistening
::MonadWriter
w m =>IndexedLens'
i w u -> m a -> m (a, (i, u))ilistening
:: (MonadWriter
w m,Monoid
u) =>IndexedFold
i w u -> m a -> m (a, (i, u))ilistening
:: (MonadWriter
w m,Monoid
u) =>IndexedTraversal'
i w u -> m a -> m (a, (i, u))
ilistenings :: MonadWriter w m => IndexedGetting i v w u -> (i -> u -> v) -> m a -> m (a, v) Source #
This is a generalized form of listen
that only extracts the portion of
the log that is focused on by a Getter
. If given a Fold
or a Traversal
then a monoidal summary of the parts of the log that are visited will be
returned.
ilistenings
::MonadWriter
w m =>IndexedGetter
w u -> (i -> u -> v) -> m a -> m (a, v)ilistenings
::MonadWriter
w m =>IndexedLens'
w u -> (i -> u -> v) -> m a -> m (a, v)ilistenings
:: (MonadWriter
w m,Monoid
v) =>IndexedFold
w u -> (i -> u -> v) -> m a -> m (a, v)ilistenings
:: (MonadWriter
w m,Monoid
v) =>IndexedTraversal'
w u -> (i -> u -> v) -> m a -> m (a, v)
Implementation Details
class Contravariant (f :: Type -> Type) where #
Minimal complete definition
Instances
getting :: (Profunctor p, Profunctor q, Functor f, Contravariant f) => Optical p q f s t a b -> Optical' p q f s a Source #
Coerce a Getter
-compatible Optical
to an Optical'
. This
is useful when using a Traversal
that is not simple as a Getter
or a
Fold
.
getting
::Traversal
s t a b ->Fold
s agetting
::Lens
s t a b ->Getter
s agetting
::IndexedTraversal
i s t a b ->IndexedFold
i s agetting
::IndexedLens
i s t a b ->IndexedGetter
i s a
Instances
Semigroupoid (Const :: Type -> Type -> Type) | |
Defined in Data.Semigroupoid | |
Generic1 (Const a :: k -> Type) | |
FoldableWithIndex Void (Const e :: Type -> Type) | |
Defined in WithIndex | |
FunctorWithIndex Void (Const e :: Type -> Type) | |
TraversableWithIndex Void (Const e :: Type -> Type) | |
Unbox a => Vector Vector (Const a b) | |
Defined in Data.Vector.Unboxed.Base Methods basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (Const a b) -> m (Vector (Const a b)) basicUnsafeThaw :: PrimMonad m => Vector (Const a b) -> m (Mutable Vector (PrimState m) (Const a b)) basicLength :: Vector (Const a b) -> Int basicUnsafeSlice :: Int -> Int -> Vector (Const a b) -> Vector (Const a b) basicUnsafeIndexM :: Monad m => Vector (Const a b) -> Int -> m (Const a b) basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (Const a b) -> Vector (Const a b) -> m () | |
Unbox a => MVector MVector (Const a b) | |
Defined in Data.Vector.Unboxed.Base Methods basicLength :: MVector s (Const a b) -> Int basicUnsafeSlice :: Int -> Int -> MVector s (Const a b) -> MVector s (Const a b) basicOverlaps :: MVector s (Const a b) -> MVector s (Const a b) -> Bool basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (Const a b)) basicInitialize :: PrimMonad m => MVector (PrimState m) (Const a b) -> m () basicUnsafeReplicate :: PrimMonad m => Int -> Const a b -> m (MVector (PrimState m) (Const a b)) basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (Const a b) -> Int -> m (Const a b) basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (Const a b) -> Int -> Const a b -> m () basicClear :: PrimMonad m => MVector (PrimState m) (Const a b) -> m () basicSet :: PrimMonad m => MVector (PrimState m) (Const a b) -> Const a b -> m () basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (Const a b) -> MVector (PrimState m) (Const a b) -> m () basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (Const a b) -> MVector (PrimState m) (Const a b) -> m () basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (Const a b) -> Int -> m (MVector (PrimState m) (Const a b)) | |
Bifoldable (Const :: Type -> TYPE LiftedRep -> Type) | |
Bifunctor (Const :: Type -> Type -> Type) | |
Bitraversable (Const :: Type -> Type -> Type) | |
Defined in Data.Bitraversable Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Const a b -> f (Const c d) | |
Eq2 (Const :: Type -> Type -> Type) | |
Defined in Data.Functor.Classes | |
Ord2 (Const :: Type -> Type -> Type) | |
Defined in Data.Functor.Classes Methods liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> Const a c -> Const b d -> Ordering | |
Read2 (Const :: Type -> Type -> Type) | |
Defined in Data.Functor.Classes Methods liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (Const a b) liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Const a b] liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (Const a b) liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [Const a b] | |
Show2 (Const :: Type -> TYPE LiftedRep -> Type) | |
Defined in Data.Functor.Classes Methods liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> Const a b -> ShowS liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [Const a b] -> ShowS | |
Biapplicative (Const :: Type -> Type -> Type) | |
NFData2 (Const :: Type -> Type -> Type) | |
Defined in Control.DeepSeq | |
Hashable2 (Const :: Type -> Type -> Type) | |
Defined in Data.Hashable.Class Methods liftHashWithSalt2 :: (Int -> a -> Int) -> (Int -> b -> Int) -> Int -> Const a b -> Int | |
Biapply (Const :: Type -> Type -> Type) | |
Bifoldable1 (Const :: Type -> TYPE LiftedRep -> Type) | |
Defined in Data.Semigroup.Foldable.Class Methods bifold1 :: Semigroup m => Const m m -> m bifoldMap1 :: Semigroup m => (a -> m) -> (b -> m) -> Const a b -> m | |
Bitraversable1 (Const :: Type -> TYPE LiftedRep -> Type) | |
Defined in Data.Semigroup.Traversable.Class Methods bitraverse1 :: Apply f => (a -> f b) -> (c -> f d) -> Const a c -> f (Const b d) bisequence1 :: Apply f => Const (f a) (f b) -> f (Const a b) | |
Foldable (Const m :: TYPE LiftedRep -> Type) | |
Defined in Data.Functor.Const Methods fold :: Monoid m0 => Const m m0 -> m0 foldMap :: Monoid m0 => (a -> m0) -> Const m a -> m0 foldMap' :: Monoid m0 => (a -> m0) -> Const m a -> m0 foldr :: (a -> b -> b) -> b -> Const m a -> b foldr' :: (a -> b -> b) -> b -> Const m a -> b foldl :: (b -> a -> b) -> b -> Const m a -> b foldl' :: (b -> a -> b) -> b -> Const m a -> b foldr1 :: (a -> a -> a) -> Const m a -> a foldl1 :: (a -> a -> a) -> Const m a -> a elem :: Eq a => a -> Const m a -> Bool maximum :: Ord a => Const m a -> a minimum :: Ord a => Const m a -> a | |
Eq a => Eq1 (Const a :: Type -> Type) | |
Defined in Data.Functor.Classes | |
Ord a => Ord1 (Const a :: Type -> Type) | |
Defined in Data.Functor.Classes Methods liftCompare :: (a0 -> b -> Ordering) -> Const a a0 -> Const a b -> Ordering | |
Read a => Read1 (Const a :: Type -> Type) | |
Defined in Data.Functor.Classes Methods liftReadsPrec :: (Int -> ReadS a0) -> ReadS [a0] -> Int -> ReadS (Const a a0) liftReadList :: (Int -> ReadS a0) -> ReadS [a0] -> ReadS [Const a a0] liftReadPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec (Const a a0) liftReadListPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec [Const a a0] | |
Show a => Show1 (Const a :: TYPE LiftedRep -> Type) | |
Defined in Data.Functor.Classes Methods liftShowsPrec :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> Int -> Const a a0 -> ShowS liftShowList :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> [Const a a0] -> ShowS | |
Contravariant (Const a :: Type -> Type) | |
Traversable (Const m :: Type -> Type) | |
Monoid m => Applicative (Const m :: Type -> Type) | |
Functor (Const m :: Type -> Type) | |
NFData a => NFData1 (Const a :: TYPE LiftedRep -> Type) | |
Defined in Control.DeepSeq | |
Hashable a => Hashable1 (Const a :: Type -> Type) | |
Defined in Data.Hashable.Class Methods liftHashWithSalt :: (Int -> a0 -> Int) -> Int -> Const a a0 -> Int | |
Semigroup m => Apply (Const m :: Type -> Type) | |
ComonadCofree (Const b :: Type -> Type) ((,) b) | |
Defined in Control.Comonad.Cofree.Class | |
Sieve (Forget r :: Type -> Type -> TYPE LiftedRep) (Const r :: Type -> Type) | |
Defined in Data.Profunctor.Sieve | |
(Typeable k, Data a, Typeable b) => Data (Const a b) | |
Defined in Data.Data Methods gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Const a b -> c (Const a b) gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Const a b) toConstr :: Const a b -> Constr dataTypeOf :: Const a b -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Const a b)) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Const a b)) gmapT :: (forall b0. Data b0 => b0 -> b0) -> Const a b -> Const a b gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Const a b -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Const a b -> r gmapQ :: (forall d. Data d => d -> u) -> Const a b -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Const a b -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Const a b -> m (Const a b) gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Const a b -> m (Const a b) gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Const a b -> m (Const a b) | |
Storable a => Storable (Const a b) | |
Defined in Data.Functor.Const Methods peekElemOff :: Ptr (Const a b) -> Int -> IO (Const a b) pokeElemOff :: Ptr (Const a b) -> Int -> Const a b -> IO () peekByteOff :: Ptr b0 -> Int -> IO (Const a b) pokeByteOff :: Ptr b0 -> Int -> Const a b -> IO () | |
Monoid a => Monoid (Const a b) | |
Semigroup a => Semigroup (Const a b) | |
Bits a => Bits (Const a b) | |
Defined in Data.Functor.Const Methods (.&.) :: Const a b -> Const a b -> Const a b (.|.) :: Const a b -> Const a b -> Const a b xor :: Const a b -> Const a b -> Const a b complement :: Const a b -> Const a b shift :: Const a b -> Int -> Const a b rotate :: Const a b -> Int -> Const a b setBit :: Const a b -> Int -> Const a b clearBit :: Const a b -> Int -> Const a b complementBit :: Const a b -> Int -> Const a b testBit :: Const a b -> Int -> Bool bitSizeMaybe :: Const a b -> Maybe Int shiftL :: Const a b -> Int -> Const a b unsafeShiftL :: Const a b -> Int -> Const a b shiftR :: Const a b -> Int -> Const a b unsafeShiftR :: Const a b -> Int -> Const a b rotateL :: Const a b -> Int -> Const a b | |
FiniteBits a => FiniteBits (Const a b) | |
Defined in Data.Functor.Const Methods finiteBitSize :: Const a b -> Int countLeadingZeros :: Const a b -> Int countTrailingZeros :: Const a b -> Int | |
Bounded a => Bounded (Const a b) | |
Defined in Data.Functor.Const | |
Enum a => Enum (Const a b) | |
Defined in Data.Functor.Const | |
Floating a => Floating (Const a b) | |
Defined in Data.Functor.Const Methods sqrt :: Const a b -> Const a b (**) :: Const a b -> Const a b -> Const a b logBase :: Const a b -> Const a b -> Const a b asin :: Const a b -> Const a b acos :: Const a b -> Const a b atan :: Const a b -> Const a b sinh :: Const a b -> Const a b cosh :: Const a b -> Const a b tanh :: Const a b -> Const a b asinh :: Const a b -> Const a b acosh :: Const a b -> Const a b atanh :: Const a b -> Const a b log1p :: Const a b -> Const a b expm1 :: Const a b -> Const a b | |
RealFloat a => RealFloat (Const a b) | |
Defined in Data.Functor.Const Methods floatRadix :: Const a b -> Integer floatDigits :: Const a b -> Int floatRange :: Const a b -> (Int, Int) decodeFloat :: Const a b -> (Integer, Int) encodeFloat :: Integer -> Int -> Const a b significand :: Const a b -> Const a b scaleFloat :: Int -> Const a b -> Const a b isInfinite :: Const a b -> Bool isDenormalized :: Const a b -> Bool isNegativeZero :: Const a b -> Bool | |
Generic (Const a b) | |
Ix a => Ix (Const a b) | |
Defined in Data.Functor.Const Methods range :: (Const a b, Const a b) -> [Const a b] index :: (Const a b, Const a b) -> Const a b -> Int unsafeIndex :: (Const a b, Const a b) -> Const a b -> Int inRange :: (Const a b, Const a b) -> Const a b -> Bool rangeSize :: (Const a b, Const a b) -> Int unsafeRangeSize :: (Const a b, Const a b) -> Int | |
Num a => Num (Const a b) | |
Read a => Read (Const a b) | |
Defined in Data.Functor.Const | |
Fractional a => Fractional (Const a b) | |
Defined in Data.Functor.Const | |
Integral a => Integral (Const a b) | |
Defined in Data.Functor.Const | |
Real a => Real (Const a b) | |
Defined in Data.Functor.Const Methods toRational :: Const a b -> Rational | |
RealFrac a => RealFrac (Const a b) | |
Show a => Show (Const a b) | |
NFData a => NFData (Const a b) | |
Defined in Control.DeepSeq | |
Eq a => Eq (Const a b) | |
Ord a => Ord (Const a b) | |
Defined in Data.Functor.Const | |
Hashable a => Hashable (Const a b) | |
Defined in Data.Hashable.Class | |
Wrapped (Const a x) Source # | |
Prim a => Prim (Const a b) | |
Defined in Data.Primitive.Types Methods alignment# :: Const a b -> Int# indexByteArray# :: ByteArray# -> Int# -> Const a b readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Const a b #) writeByteArray# :: MutableByteArray# s -> Int# -> Const a b -> State# s -> State# s setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Const a b -> State# s -> State# s indexOffAddr# :: Addr# -> Int# -> Const a b readOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Const a b #) writeOffAddr# :: Addr# -> Int# -> Const a b -> State# s -> State# s setOffAddr# :: Addr# -> Int# -> Int# -> Const a b -> State# s -> State# s | |
Unbox a => Unbox (Const a b) | |
Defined in Data.Vector.Unboxed.Base | |
t ~ Const a' x' => Rewrapped (Const a x) t Source # | |
Defined in Control.Lens.Wrapped | |
type Rep1 (Const a :: k -> Type) | |
Defined in Data.Functor.Const type Rep1 (Const a :: k -> Type) = D1 ('MetaData "Const" "Data.Functor.Const" "base" 'True) (C1 ('MetaCons "Const" 'PrefixI 'True) (S1 ('MetaSel ('Just "getConst") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) | |
newtype MVector s (Const a b) | |
Defined in Data.Vector.Unboxed.Base | |
type Rep (Const a b) | |
Defined in Data.Functor.Const type Rep (Const a b) = D1 ('MetaData "Const" "Data.Functor.Const" "base" 'True) (C1 ('MetaCons "Const" 'PrefixI 'True) (S1 ('MetaSel ('Just "getConst") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) | |
type Unwrapped (Const a x) Source # | |
Defined in Control.Lens.Wrapped | |
newtype Vector (Const a b) | |
Defined in Data.Vector.Unboxed.Base |