Search results

compose2 :: forall a b x y. (a -> b) -> (x -> y -> a) -> x -> y -> b

\f g x y -> f (g x y)

P purescript-point-free M PointFree
composeSecondFlipped :: forall a b x y. (y -> b) -> (x -> b -> a) -> x -> y -> a
P purescript-point-free M PointFree
over2 :: forall t a s b. Newtype t a => Newtype s b => (a -> t) -> (a -> a -> b) -> t -> t -> s

Lifts a binary function to operate over newtypes.

newtype Meter = Meter Int
derive newtype instance newtypeMeter :: Newtype Meter _
newtype SquareMeter = SquareMeter Int
derive newtype instance newtypeSquareMeter :: Newtype SquareMeter _

area :: Meter -> Meter -> SquareMeter
area = over2 Meter (*)

The above example also demonstrates that the return type is polymorphic here too.

P purescript-newtype M Data.Newtype
under2 :: forall t a s b. Newtype t a => Newtype s b => (a -> t) -> (t -> t -> s) -> a -> a -> b

The opposite of over2: lowers a binary function that operates on Newtyped values to operate on the wrapped value instead.

P purescript-newtype M Data.Newtype
traverse :: forall f t a. Coercible (f a) (f t) => Newtype t a => (a -> t) -> (a -> f a) -> t -> f t

Similar to the function from the Traversable class, but operating within a newtype instead.

P purescript-newtype M Data.Newtype
applySecondFlipped :: forall x y a. x -> (y -> x -> a) -> y -> a
P purescript-point-free M PointFree
compose :: forall c b a. (b -> c) -> (a -> b) -> (a -> c)

Returns a new function that calls the first function with the result of calling the second.

let addTwo x = x + 2
let double x = x * 2
let addTwoThenDouble x = addTwo :compose double
addTwoThenDouble 3 -- 10

This is function composition.

P purescript-neon M Neon.Primitive.Function
finch :: forall c b a. a -> (c -> a -> b) -> c -> b

F combinator - finch

ETTET

Λ a b c . a → b → (b → a → c) → c

λ x y f . f y x

P purescript-birds M Aviary.Birds
robin :: forall c b a. a -> (b -> a -> c) -> b -> c

R combinator - robin

BBT

Λ a b c . a → (b → a → c) → b → c

λ x f y . f y x

P purescript-birds M Aviary.Birds
over :: forall t a s b. Newtype t a => Newtype s b => (a -> t) -> (a -> b) -> t -> s

Lifts a function operate over newtypes. This can be used to lift a function to manipulate the contents of a single newtype, somewhat like map does for a Functor:

newtype Label = Label String
derive instance newtypeLabel :: Newtype Label _

toUpperLabel :: Label -> Label
toUpperLabel = over Label String.toUpper

But the result newtype is polymorphic, meaning the result can be returned as an alternative newtype:

newtype UppercaseLabel = UppercaseLabel String
derive instance newtypeUppercaseLabel :: Newtype UppercaseLabel _

toUpperLabel' :: Label -> UppercaseLabel
toUpperLabel' = over Label String.toUpper
P purescript-newtype M Data.Newtype
under :: forall t a s b. Newtype t a => Newtype s b => (a -> t) -> (t -> s) -> a -> b

The opposite of over: lowers a function that operates on Newtyped values to operate on the wrapped value instead.

newtype Degrees = Degrees Number
derive instance newtypeDegrees :: Newtype Degrees _

newtype NormalDegrees = NormalDegrees Number
derive instance newtypeNormalDegrees :: Newtype NormalDegrees _

normaliseDegrees :: Degrees -> NormalDegrees
normaliseDegrees (Degrees deg) = NormalDegrees (deg % 360.0)

asNormalDegrees :: Number -> Number
asNormalDegrees = under Degrees normaliseDegrees

As with over the Newtype is polymorphic, as illustrated in the example above - both Degrees and NormalDegrees are instances of Newtype, so even though normaliseDegrees changes the result type we can still put a Number in and get a Number out via under.

P purescript-newtype M Data.Newtype
memoCompose :: forall a b c. (a -> b) -> (b -> c) -> a -> c

Memoize the composition of two functions

P purescript-pha M Pha.Util
foldingWithIndex :: forall f i x y z. FoldingWithIndex f i x y z => f -> i -> x -> y -> z
P purescript-heterogeneous M Heterogeneous.Folding
mapmap :: forall f g a b. Functor f => Functor g => (a -> b) -> f (g a) -> f (g b)
P purescript-sequences M Data.Sequence.Internal
mmap :: forall a b f g. Functor f => Functor g => (a -> b) -> f (g a) -> f (g b)
P purescript-mason-prelude M MasonPrelude.Functor.Nested
foldingWithIndex :: forall f i x y z. FoldingWithIndex f i x y z => f -> i -> x -> y -> z
P purescript-heterogenous M Heterogenous.Folding
new3 :: forall b a3 a2 a1 o. o -> a1 -> a2 -> a3 -> b
P purescript-ffi-utils M FFI.Util
worbler :: forall b a. b -> (b -> b -> a) -> a

W1 combinator - converse warbler

CW

Λ a b . a → (a → a → b) → b

λ x f = f x x

P purescript-birds M Aviary.Birds
for :: forall a b m t. Applicative m => Traversable t => t a -> (a -> m b) -> m (t b)

A version of traverse with its arguments flipped.

This can be useful when running an action written using do notation for every element in a data structure:

For example:

for [1, 2, 3] \n -> do
  print n
  return (n * n)
P purescript-foldable-traversable M Data.Traversable
mkQ :: forall a b r. Typeable a => Typeable b => r -> (b -> r) -> a -> r
P purescript-ajnsit-typeable M Data.Data
bind :: forall m a b. Bind m => m a -> (a -> m b) -> m b
P purescript-prelude M Control.Bind
discard :: forall a f b. Discard a => Bind f => f a -> (a -> f b) -> f b
P purescript-prelude M Control.Bind
catchError :: forall e m a. MonadError e m => m a -> (e -> m a) -> m a
P purescript-transformers M Control.Monad.Error.Class
apApplyFlipped :: forall f b a. Apply f => f a -> f (a -> b) -> f b
P purescript-optparse M Options.Applicative.Internal.Utils
applyOp :: forall event a b. Applicative event => event a -> event (a -> b) -> event b
P purescript-hyrule M FRP.Event.Class
sampleOnLeft :: forall event a b. IsEvent event => event a -> event (a -> b) -> event b
P purescript-hyrule M FRP.Event.Class
sampleOnRight :: forall event a b. IsEvent event => event a -> event (a -> b) -> event b
P purescript-hyrule M FRP.Event.Class
sampleOn :: forall event b a. IsEvent event => event a -> event (a -> b) -> event b
P purescript-event M FRP.Event.Class
bind' :: forall v1 v0 m c. HasBind c m => ObjectOf c v0 => ObjectOf c (m v1) => Restrictable Function c => m v0 -> (v0 -> (m v1)) -> m v1
P purescript-subcategory M Control.Subcategory.Functor.HasBind
bind :: forall c b a. HasChain a => a b -> (b -> a c) -> a c

A version of chain with the arguments flipped. This is provided only to support desugaring do notation. It is not recommended to use explicitly.

P purescript-neon M Neon.Helper
controlError :: forall f g e a. ErrorControl f g e => f a -> (e -> g a) -> g a
P purescript-errorcontrol M Error.Control
fairConjunction :: forall b a m. MonadLogic m => m a -> (a -> m b) -> m b
P purescript-logic M Control.Monad.Logic.Class
hummingbird :: forall m b a. Bind m => m a -> (a -> m b) -> m b

H combinator - hummingbird

BW(BC)

Λ a b c (a → b → a → c) → a → b → c

λ f x y . f x y x

P purescript-birds M Aviary.Birds
when :: forall b a m. MonadLogic m => m a -> (a -> m b) -> m b
P purescript-logic M Control.Monad.Logic.Class
apply :: forall a b. (a -> b) -> a -> b

Applies a function to an argument. This is primarily used as the operator ($) which allows parentheses to be omitted in some cases, or as a natural way to apply a chain of composed functions to a value.

P purescript-prelude M Data.Function
liftA1 :: forall f a b. Applicative f => (a -> b) -> f a -> f b

liftA1 provides a default implementation of (<$>) for any Applicative functor, without using (<$>) as provided by the Functor-Applicative superclass relationship.

liftA1 can therefore be used to write Functor instances as follows:

instance functorF :: Functor F where
  map = liftA1
P purescript-prelude M Control.Applicative
liftM1 :: forall m a b. Monad m => (a -> b) -> m a -> m b

liftM1 provides a default implementation of (<$>) for any Monad, without using (<$>) as provided by the Functor-Monad superclass relationship.

liftM1 can therefore be used to write Functor instances as follows:

instance functorF :: Functor F where
  map = liftM1
P purescript-prelude M Control.Monad
map :: forall f a b. Functor f => (a -> b) -> f a -> f b
P purescript-prelude M Data.Functor
un :: forall t a. Newtype t a => (a -> t) -> t -> a

Given a constructor for a Newtype, this returns the appropriate unwrap function.

P purescript-newtype M Data.Newtype
all :: forall a b f. Foldable f => HeytingAlgebra b => (a -> b) -> f a -> b

all f is the same as and <<< map f; map a function over the structure, and then get the conjunction of the results.

P purescript-foldable-traversable M Data.Foldable
any :: forall a b f. Foldable f => HeytingAlgebra b => (a -> b) -> f a -> b

any f is the same as or <<< map f; map a function over the structure, and then get the disjunction of the results.

P purescript-foldable-traversable M Data.Foldable
foldMap :: forall f a m. Foldable f => Monoid m => (a -> m) -> f a -> m
P purescript-foldable-traversable M Data.Foldable
foldMap1 :: forall t a m. Foldable1 t => Semigroup m => (a -> m) -> t a -> m
P purescript-foldable-traversable M Data.Semigroup.Foldable
foldMap1DefaultL :: forall t m a. Foldable1 t => Functor t => Semigroup m => (a -> m) -> t a -> m

A default implementation of foldMap1 using foldl1.

Note: when defining a Foldable1 instance, this function is unsafe to use in combination with foldl1Default.

P purescript-foldable-traversable M Data.Semigroup.Foldable
foldMap1DefaultR :: forall t m a. Foldable1 t => Functor t => Semigroup m => (a -> m) -> t a -> m

A default implementation of foldMap1 using foldr1.

Note: when defining a Foldable1 instance, this function is unsafe to use in combination with foldr1Default.

P purescript-foldable-traversable M Data.Semigroup.Foldable
foldMapDefault :: forall i f a m. FoldableWithIndex i f => Monoid m => (a -> m) -> f a -> m

A default implementation of foldMap using foldMapWithIndex

P purescript-foldable-traversable M Data.FoldableWithIndex
foldMapDefaultL :: forall f a m. Foldable f => Monoid m => (a -> m) -> f a -> m

A default implementation of foldMap using foldl.

Note: when defining a Foldable instance, this function is unsafe to use in combination with foldlDefault.

P purescript-foldable-traversable M Data.Foldable
foldMapDefaultR :: forall f a m. Foldable f => Monoid m => (a -> m) -> f a -> m

A default implementation of foldMap using foldr.

Note: when defining a Foldable instance, this function is unsafe to use in combination with foldrDefault.

P purescript-foldable-traversable M Data.Foldable
mapDefault :: forall i f a b. FunctorWithIndex i f => (a -> b) -> f a -> f b

A default implementation of Functor's map in terms of mapWithIndex

P purescript-foldable-traversable M Data.FunctorWithIndex
cmap :: forall f a b. Contravariant f => (b -> a) -> f a -> f b
P purescript-contravariant M Data.Functor.Contravariant