Data.Function
- Package
- purescript-prelude
- Repository
- purescript/purescript-prelude
#flip Source
flip :: forall c b a. (a -> b -> c) -> b -> a -> c
Flips the order of the arguments to a function of two arguments.
flip const 1 2 = const 2 1 = 2
#const Source
const :: forall b a. a -> b -> a
Returns its first argument and ignores its second.
const 1 "hello" = 1
#apply Source
apply :: forall b a. (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.
#($) Source
Operator alias for Data.Function.apply (right-associative / precedence 0)
Applies a function to an argument: the reverse of (#)
.
length $ groupBy productCategory $ filter isInStock $ products
is equivalent to:
length (groupBy productCategory (filter isInStock products))
Or another alternative equivalent, applying chain of composed functions to a value:
length <<< groupBy productCategory <<< filter isInStock $ products
#applyFlipped Source
applyFlipped :: forall b a. a -> (a -> b) -> b
Applies an argument to a function. This is primarily used as the (#)
operator, which allows parentheses to be ommitted in some cases, or as a
natural way to apply a value to a chain of composed functions.
#(#) Source
Operator alias for Data.Function.applyFlipped (left-associative / precedence 1)
Applies an argument to a function: the reverse of ($)
.
products # filter isInStock # groupBy productCategory # length
is equivalent to:
length (groupBy productCategory (filter isInStock products))
Or another alternative equivalent, applying a value to a chain of composed functions:
products # filter isInStock >>> groupBy productCategory >>> length
#on Source
on :: forall c b a. (b -> b -> c) -> (a -> b) -> a -> a -> c
The on
function is used to change the domain of a binary operator.
For example, we can create a function which compares two records based on the values of their x
properties:
compareX :: forall r. { x :: Number | r } -> { x :: Number | r } -> Ordering
compareX = compare `on` _.x
Re-exports from Control.Category
#compose Source
compose :: forall a d c b. Semigroupoid a => a c d -> a b c -> a b d
- Modules
- Control.
Applicative - Control.
Apply - Control.
Bind - Control.
Category - Control.
Monad - Control.
Semigroupoid - Data.
Boolean - Data.
BooleanAlgebra - Data.
Bounded - Data.
CommutativeRing - Data.
DivisionRing - Data.
Eq - Data.
EuclideanRing - Data.
Field - Data.
Function - Data.
Functor - Data.
HeytingAlgebra - Data.
Monoid - Data.
Monoid. Additive - Data.
Monoid. Conj - Data.
Monoid. Disj - Data.
Monoid. Dual - Data.
Monoid. Endo - Data.
Monoid. Multiplicative - Data.
NaturalTransformation - Data.
Ord - Data.
Ord. Unsafe - Data.
Ordering - Data.
Ring - Data.
Semigroup - Data.
Semigroup. First - Data.
Semigroup. Last - Data.
Semiring - Data.
Show - Data.
Symbol - Data.
Unit - Data.
Void - Prelude
- Record.
Unsafe - Type.
Data. Row - Type.
Data. RowList