Functions
There are (6) function classifications included in this library:
Combinators: A collection of functions that are used for working with other functions. These do things like compose (2) functions together, or flip arguments on a function. They typically either take a function, return a function or a bit a both. These are considered the glue that holds the mighty house of
crocks
together and a valuable aid in writing reusable code.Helper Functions: All other support functions that are either convenient versions of combinators or not even combinators at all cover this group.
Logic Functions: A helpful collection of Logic based combinators. All of these functions work with predicate functions and let you combine them in some very interesting ways.
Predicate Functions: A helpful collection of predicate functions to get you started.
Point-free Functions: Wanna use these ADTs in a way that you never have to reference the actual data being worked on? Well here is where you will find all of these functions to do that. For every algebra available on both the Crocks and Monoids there is a function here.
Transformation Functions: All the functions found here are used to transform from one type to another, naturally. These come are handy in situations where you have functions that return one type (like an
Either
), but are working in a context of another (sayMaybe
). You would like to compose these, but in doing so will result in a nesting that you will need to account for for the rest of your flow.
#
CombinatorsFunction | Signature | Location |
---|---|---|
applyTo | a -> (a -> b) -> b | crocks/combinators/applyTo |
composeB | (b -> c) -> (a -> b) -> a -> c | crocks/combinators/composeB |
constant | a -> () -> a | crocks/combinators/constant |
converge | (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d | crocks/combinators/converge |
flip | (a -> b -> c) -> b -> a -> c | crocks/combinators/flip |
identity | a -> a | crocks/combinators/identity |
psi | (b -> b -> c) -> (a -> b) -> a -> a -> c | crocks/combinators/psi |
substitution | (a -> b -> c) -> (a -> b) -> a -> c | crocks/combinators/substitution |
#
HelpersFunction | Signature | Location |
---|---|---|
assign | Object -> Object -> Object | crocks/helpers/assign |
assoc (deprecated) | (String | Integer) -> a -> (Object | Array) -> (Object | Array) | crocks/helpers/assoc |
binary | ((*) -> c) -> a -> b -> c | crocks/helpers/binary |
branch | a -> Pair a a | crocks/Pair/branch |
compose | ((y -> z), ..., (a -> b)) -> a -> z | crocks/helpers/compose |
composeK | Chain m => ((y -> m z), ..., (a -> m b)) -> a -> m z | crocks/helpers/composeK |
composeP | Promise p => ((y -> p z c), ..., (a -> p b c)) -> a -> p z c | crocks/helpers/composeP |
composeS | Semigroupoid s => (s y z, ..., s a b) -> s a z | crocks/helpers/composeS |
curry | ((a, b, ...) -> z) -> a -> b -> ... -> z | crocks/helpers/curry |
defaultProps | Object -> Object -> Object | crocks/helpers/defaultProps |
defaultTo | a -> b -> a | crocks/helpers/defaultTo |
dissoc (deprecated) | (String | Integer) -> a -> a | crocks/helpers/dissoc |
fanout | (a -> b) -> (a -> c) -> (a -> Pair b c) | crocks/Pair/fanout |
find | Foldable f => ((a -> Boolean) | Pred) -> f a -> Maybe a | crocks/Maybe/find |
fromPairs | Foldable f => f (Pair String a) -> Object | crocks/helpers/fromPairs |
getPath | [ (String | Integer) ] -> a -> Maybe b | crocks/Maybe/getPath |
getPathOr | a -> f [ (String | Integer) ] -> b -> a | crocks/helpers/getPathOr |
getProp | (String | Integer) -> a -> Maybe b | crocks/Maybe/getProp |
getPropOr | a -> (String | Integer) -> b -> c | crocks/helpers/getPropOr |
liftA2 | Applicative m => (a -> b -> c) -> m a -> m b -> m c | crocks/helpers/liftA2 |
liftA3 | Applicative m => (a -> b -> c -> d) -> m a -> m b -> m c -> m d | crocks/helpers/liftA3 |
liftN | Applicative m => Number -> ((*) -> a) -> (*m) -> m a | crocks/helpers/liftN |
mapProps | Object -> Object -> Object | crocks/helpers/mapProps |
mapReduce | Foldable f => (a -> b) -> (c -> b -> c) -> c -> f a -> c | crocks/helpers/mapReduce |
mconcat | Monoid m, Foldable f => m -> f a -> m a | crocks/helpers/mconcat |
mconcatMap | Monoid m, Foldable f => m -> (b -> a) -> f b -> m a | crocks/helpers/mconcatMap |
mreduce | Monoid m, Foldable f => m -> f a -> a | crocks/helpers/mreduce |
mreduceMap | Monoid m, Foldable f => m -> (b -> a) -> f b -> a | crocks/helpers/mreduceMap |
nAry | Number -> ((*) -> a) -> (*) -> a | crocks/helpers/nAry |
objOf | String -> a -> Object | crocks/helpers/objOf |
omit | [ String ] -> Object -> Object | crocks/helpers/omit |
once | ((*) -> a) -> ((*) -> a) | crocks/helpers/once |
partial | (((*) -> c), *) -> (*) -> c | crocks/helpers/partial |
pick | Foldable f => f String -> Object -> Object | crocks/helpers/pick |
pipe | ((a -> b), ..., (y -> z)) -> a -> z | crocks/helpers/pipe |
pipeK | Chain m => ((a -> m b), ..., (y -> m z)) -> a -> m z | crocks/helpers/pipeK |
pipeP | Promise p => ((a -> p b d), ..., (y -> p z d)) -> a -> p z d | crocks/helpers/pipeP |
pipeS | Semigroupoid s => (s a b, ..., s y z) -> s a z | crocks/helpers/pipeS |
prop (deprecated) | (String | Integer) -> a -> Maybe b | crocks/Maybe/prop |
propOr (deprecated) | a -> (String | Integer) -> b -> c | crocks/helpers/propOr |
propPath (deprecated) | [ (String | Integer) ] -> a -> Maybe b | crocks/Maybe/propPath |
propPathOr (deprecated) | a -> [ (String | Integer) ] -> b -> a | crocks/helpers/propPathOr |
safe | ((a -> Boolean) | Pred) -> a -> Maybe a | crocks/Maybe/safe |
safeAfter | safeAfter :: ((b -> Boolean) | Pred) -> (a -> b) -> a -> Maybe b | crocks/Maybe/safeAfter |
safeLift | ((a -> Boolean) | Pred) -> (a -> b) -> a -> Maybe b | crocks/Maybe/safeLift |
setPath | [ (String | Integer) ] -> a -> (Object | Array) -> (Object | Array) | crocks/helpers/setPath |
setProp | (String | Integer) -> a -> (Object | Array) -> (Object | Array) | crocks/helpers/setProp |
tap | (a -> b) -> a -> a | crocks/helpers/tap |
toPairs | Object -> List (Pair String a) | crocks/Pair/toPairs |
tryCatch | ((*) -> b) -> (*) -> Result e b | crocks/Result/tryCatch |
unary | ((*) -> b) -> a -> b | crocks/helpers/unary |
unit | () -> undefined | crocks/helpers/unit |
unsetPath | [ (String | Integer) ] -> a -> a | crocks/helpers/unsetPath |
unsetProp | (String | Integer) -> a -> a | crocks/helpers/unsetProp |
#
LogicEvery function in crocks
, that takes a predicate function of the
form a -> Boolean
, can be replaced with a Pred instance of the
type: Pred a
and vice-versa
Function | Signature | Location |
---|---|---|
and | (a -> Boolean) -> (a -> Boolean) -> a -> Boolean | crocks/logic/and |
ifElse | (a -> Boolean) -> (a -> b) -> (a -> b) -> a -> b | crocks/logic/ifElse |
implies | (a -> Boolean) -> (a -> Boolean) -> a -> Boolean | crocks/logic/implies |
not | (a -> Boolean) -> a -> Boolean | crocks/logic/not |
or | (a -> Boolean) -> (a -> Boolean) -> a -> Boolean | crocks/logic/or |
unless | (a -> Boolean) -> (a -> a) -> a -> a | crocks/logic/unless |
when | (a -> Boolean) -> (a -> a) -> a -> a | crocks/logic/when |