:: t -> t1 -> t

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]
An alias of const, this upgrades a handler that does not accept LambdaContext as its first curried argument to one that does. This allows us to use other combinators to construct a lambda runtime that accepts a handler that ignores LambdaContext. In the example below, we reconstruct pureRuntime without actually using it. @ {-# LANGUAGE NamedFieldPuns, DeriveGeneric #-} module Main where import AWS.Lambda.Runtime (pureRuntimeWithContext) import AWS.Lambda.Combinators (withoutContext) import Data.Aeson (FromJSON) import GHC.Generics (Generic) data Named = Named { name :: String } deriving Generic instance FromJSON Named myHandler :: Named -> String myHandler (Named { name }) = "Hello, " ++ name main :: IO () main = (pureRuntimeWithContext . withoutContext) myHandler @
addHeader adds a header to a response. Note that it changes the type of the value in the following ways:
  1. A simple value is wrapped in "Headers '[hdr]":
>>> let example0 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;

>>> getHeaders example0
[("someheader","5")]
  1. A value that already has a header has its new header *prepended* to the existing list:
>>> let example1 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;

>>> let example2 = addHeader True example1 :: Headers '[Header "1st" Bool, Header "someheader" Int] String

>>> getHeaders example2
[("1st","true"),("someheader","5")]
Note that while in your handlers type annotations are not required, since the type can be inferred from the API type, in other cases you may find yourself needing to add annotations.
This is the pure functional matching operator. If the target cannot be produced then some empty result will be returned. If there is an error in processing, then error will be called.
Extracts the element at a finite index of an infinite sequence (a !! that can't fail).
Extracts _exactly_ n elements from the infinite stream s.
Extracts _no more than_ n elements from the possibly-infinite sequence s.
Lops off the branches of the tree below a certain depth, turning a potentially-infinite structure into a finite one. Like a generalized take.
raise a number to a non-negative integral power
Extend a generic builder by a type-specific case. The builder created by extB def ext returns def if ext cannot be cast to type a, and like ext otherwise. The name extB is short for "extend builder".

Examples

>>> extB True 'a'
True
>>> extB True False
False