This is an infix alias for contramap.
Moduletrace-dispatcher-2.13.1Haskell2010
Cardano.Logging
- 1 class
- 18 values
- Packagetrace-dispatcher-2.13.1
- Exports19
- LanguageHaskell2010
- LicenceApache-2.0
- SourceContravariant.hs
module Cardano.Logging.Configuration
module Cardano.Logging.ConfigurationParser
module Cardano.Logging.Consistency
module Cardano.Logging.Formatter
module Cardano.Logging.FrequencyLimiter
module Cardano.Logging.Trace
module Cardano.Logging.TraceDispatcherMessage
module Cardano.Logging.Tracer.Composed
module Cardano.Logging.Tracer.DataPoint
module Cardano.Logging.Tracer.EKG
module Cardano.Logging.Tracer.Forward
module Cardano.Logging.Tracer.Standard
module Cardano.Logging.Types
module Cardano.Logging.Utils
Inverse of use.
Trace strings using traceM. This will use stderr. See documentation in Debug.Trace for more details.
Make an emitting tracer from a callback.
Use a natural transformation to change the m type. This is useful, for
instance, to use concrete IO tracers in monad transformer stacks that have
IO as their base.
Uses traceMaybe to give a tracer which emits only if a predicate is true.
A monadic version of squelchUnless.
Trace strings to stdout. Output could be jumbled when this is used from multiple threads. Consider debugTracer instead.
Run a tracer only for the Just variant of a Maybe. If it's Nothing, the nullTracer is used (no output).
The arrow representation allows for proper laziness: if the tracer parameter
does not produce any tracing effects, then the predicate won't even be
evaluated. Contrast with the simple contravariant representation as
a -> m (), in which the predicate _must_ be forced no matter what,
because it's impossible to know a priori whether that function will not
produce any tracing effects.
It's written out explicitly for demonstration. Could also use arrow notation:
traceMaybe p tr = Tracer $ proc a -> do
case k a of
Just b -> use tr -< b
Nothing -> Arrow.squelch -< ()A monadic version of traceMaybe.
Inverse of arrow. Useful when writing arrow tracers which use a contravariant tracer (the newtype in this module).
Do a non-emitting effect. This effect will only be run if some part of the tracer downstream emits (see emit).
Do an emitting effect. Contrast with effect which does not make the tracer an emitting tracer.
Use a natural transformation to change the underlying monad.
Ignore the input and do not emit. The name is intended to lead to clear and suggestive arrow expressions.
The class of contravariant functors.
Whereas in Haskell, one can think of a Functor as containing or producing values, a contravariant functor is a functor that can be thought of as consuming values.
As an example, consider the type of predicate functions a -> Bool. One
such predicate might be negative x = x < 0, which
classifies integers as to whether they are negative. However, given this
predicate, we can re-use it in other situations, providing we have a way to
map values to integers. For instance, we can use the negative predicate
on a person's bank balance to work out if they are currently overdrawn:
newtype Predicate a = Predicate { getPredicate :: a -> Bool }
instance Contravariant Predicate where
contramap :: (a' -> a) -> (Predicate a -> Predicate a')
contramap f (Predicate p) = Predicate (p . f)
| `- First, map the input...
`----- then apply the predicate.
overdrawn :: Predicate Person
overdrawn = contramap personBankBalance negative
Any instance should be subject to the following laws:
Note, that the second law follows from the free theorem of the type of contramap and the first law, so you need only check that the former condition holds.
Instances38Contravariant, …
Contravariant SettableStateVarDefined in StateVar-1.2.2 · Data.StateVarContravariant ToJSONKeyFunctionDefined in aeson-2.2.5.1 · Data.Aeson.Types.ToJSONContravariant ComparisonDefined in base-4.22.0.0 · Data.Functor.ContravariantA Comparison is a Contravariant Functor, because contramap can apply its function argument to each input of the comparison function.
Contravariant EquivalenceDefined in base-4.22.0.0 · Data.Functor.ContravariantEquivalence relations are Contravariant, because you can apply the contramapped function to each input to the equivalence relation.
Contravariant PredicateDefined in base-4.22.0.0 · Data.Functor.ContravariantA Predicate is a Contravariant Functor, because contramap can apply its function argument to the input of the predicate.
Without newtypes
contramap fequals precomposing withf(=(. f)).contramap :: (a' -> a) -> (Predicate a -> Predicate a') contramap f (Predicate g) = Predicate (g . f)Contravariant ProxyDefined in base-4.22.0.0 · Data.Functor.ContravariantContravariant U1Defined in base-4.22.0.0 · Data.Functor.ContravariantContravariant V1Defined in base-4.22.0.0 · Data.Functor.ContravariantContravariant (Op a)Defined in base-4.22.0.0 · Data.Functor.ContravariantContravariant f => Contravariant (WrappedDivisible f)Defined in semigroupoids-6.0.2 · Data.Functor.Contravariant.DiviseContravariant m => Contravariant (MaybeT m)Defined in transformers-0.6.1.2 · Control.Monad.Trans.MaybeMonad m => Contravariant (Tracer m)Defined in contra-tracer-0.2.1.1 · Control.TracerMonad m => Contravariant (Trace m)Defined in trace-dispatcher-2.13.1 · Cardano.Logging.TypesContramap lifted to Trace
Contravariant (Const a)Defined in base-4.22.0.0 · Data.Functor.ContravariantContravariant (Constant a)Defined in transformers-0.6.1.2 · Data.Functor.ConstantContravariant f => Contravariant (Alt f)Defined in base-4.22.0.0 · Data.Functor.ContravariantContravariant f => Contravariant (Rec1 f)Defined in base-4.22.0.0 · Data.Functor.ContravariantContravariant f => Contravariant (Backwards f)Defined in transformers-0.6.1.2 · Control.Applicative.BackwardsDerived instance.
Contravariant f => Contravariant (IdentityT f)Defined in transformers-0.6.1.2 · Control.Monad.Trans.IdentityContravariant f => Contravariant (Reverse f)Defined in transformers-0.6.1.2 · Data.Functor.ReverseDerived instance.
Contravariant m => Contravariant (ExceptT e m)Defined in transformers-0.6.1.2 · Control.Monad.Trans.ExceptContravariant m => Contravariant (ReaderT r m)Defined in transformers-0.6.1.2 · Control.Monad.Trans.ReaderContravariant m => Contravariant (StateT s m)Defined in transformers-0.6.1.2 · Control.Monad.Trans.State.LazyContravariant m => Contravariant (StateT s m)Defined in transformers-0.6.1.2 · Control.Monad.Trans.State.StrictContravariant m => Contravariant (WriterT w m)Defined in transformers-0.6.1.2 · Control.Monad.Trans.Writer.LazyContravariant m => Contravariant (WriterT w m)Defined in transformers-0.6.1.2 · Control.Monad.Trans.Writer.Strict(Contravariant f, Functor g) => Contravariant (ComposeCF f g)Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Compose(Functor f, Contravariant g) => Contravariant (ComposeFC f g)Defined in contravariant-1.5.6 · Data.Functor.Contravariant.ComposeContravariant (K1 i c)Defined in base-4.22.0.0 · Data.Functor.Contravariant(Contravariant f, Contravariant g) => Contravariant (Product f g)Defined in base-4.22.0.0 · Data.Functor.Contravariant(Contravariant f, Contravariant g) => Contravariant (Sum f g)Defined in base-4.22.0.0 · Data.Functor.Contravariant(Contravariant f, Contravariant g) => Contravariant (f :*: g)Defined in base-4.22.0.0 · Data.Functor.Contravariant(Contravariant f, Contravariant g) => Contravariant (f :+: g)Defined in base-4.22.0.0 · Data.Functor.ContravariantContravariant f => Contravariant (M1 i c f)Defined in base-4.22.0.0 · Data.Functor.ContravariantContravariant m => Contravariant (RWST r w s m)Defined in transformers-0.6.1.2 · Control.Monad.Trans.RWS.LazyContravariant m => Contravariant (RWST r w s m)Defined in transformers-0.6.1.2 · Control.Monad.Trans.RWS.Strict(Functor f, Contravariant g) => Contravariant (Compose f g)Defined in base-4.22.0.0 · Data.Functor.Contravariant(Functor f, Contravariant g) => Contravariant (f :.: g)Defined in base-4.22.0.0 · Data.Functor.Contravariant