const -package:dhall

const x y always evaluates to x, ignoring its second argument.
const x = \_ -> x
This function might seem useless at first glance, but it can be very useful in a higher order context.

Examples

>>> const 42 "hello"
42
>>> map (const 42) [0..3]
[42,42,42,42]
const x y always evaluates to x, ignoring its second argument.
>>> const 42 "hello"
42
>>> map (const 42) [0..3]
[42,42,42,42]
const x is a unary function which evaluates to x for all inputs.
>>> const 42 "hello"
42
>>> map (const 42) [0..3]
[42,42,42,42]
const x is a unary function which evaluates to x for all inputs. For instance,
>>> map (const 42) [0..3]
[42,42,42,42]
const x is a unary function which evaluates to x for all inputs.
>>> const 42 "hello"
42
>>> map (const 42) [0..3]
[42,42,42,42]
Convert between () and a constant (not a true bijection).
Lifts the input value as a constant into an expression.
Adds an element to the head of an n-ary tuple
>>> consT 5 (True,'c')
(5,True,'c')
Construct a stream that has the same given value at each step.
Not on Stackage, so not searched. Read-only mutable primitives
Differentiable logging constant function.

Examples of usage

>>> import Control.Arrow (runKleisli)

>>> import Control.Monad.Logger (runStdoutLoggingT)

>>> import Debug.SimpleExpr.Expr (variable)

>>> import InfBackprop (call, derivative)
>>> runStdoutLoggingT $ runKleisli (call (const 42)) ()
42
Infinitely differentiable constant function.

Examples of usage

>>> import Prelude (Float)

>>> import InfBackprop (call, derivative, derivativeN)
>>> call (const 5) ()
5
>>> derivative (const (5 :: Float)) 42
0
>>> derivativeN 2 (const (5 :: Float)) 42
0.0
The Const functor.

Examples

>>> fmap (++ "World") (Const "Hello")
Const "Hello"
Because we ignore the second type parameter to Const, the Applicative instance, which has (<*>) :: Monoid m => Const m (a -> b) -> Const m a -> Const m b essentially turns into Monoid m => m -> m -> m, which is (<>)
>>> Const [1, 2, 3] <*> Const [4, 5, 6]
Const [1,2,3,4,5,6]
The Const functor.
The Const functor.