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 (say Maybe). 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.

Combinators#

FunctionSignatureLocation
applyToa -> (a -> b) -> bcrocks/combinators/applyTo
composeB(b -> c) -> (a -> b) -> a -> ccrocks/combinators/composeB
constanta -> () -> acrocks/combinators/constant
converge(b -> c -> d) -> (a -> b) -> (a -> c) -> a -> dcrocks/combinators/converge
flip(a -> b -> c) -> b -> a -> ccrocks/combinators/flip
identitya -> acrocks/combinators/identity
psi(b -> b -> c) -> (a -> b) -> a -> a -> ccrocks/combinators/psi
substitution(a -> b -> c) -> (a -> b) -> a -> ccrocks/combinators/substitution

Helpers#

FunctionSignatureLocation
assignObject -> Object -> Objectcrocks/helpers/assign
assoc
(deprecated)
(String | Integer) -> a -> (Object | Array) -> (Object | Array)crocks/helpers/assoc
binary((*) -> c) -> a -> b -> ccrocks/helpers/binary
brancha -> Pair a acrocks/Pair/branch
compose((y -> z), ..., (a -> b)) -> a -> zcrocks/helpers/compose
composeKChain m => ((y -> m z), ..., (a -> m b)) -> a -> m zcrocks/helpers/composeK
composePPromise p => ((y -> p z c), ..., (a -> p b c)) -> a -> p z ccrocks/helpers/composeP
composeSSemigroupoid s => (s y z, ..., s a b) -> s a zcrocks/helpers/composeS
curry((a, b, ...) -> z) -> a -> b -> ... -> zcrocks/helpers/curry
defaultPropsObject -> Object -> Objectcrocks/helpers/defaultProps
defaultToa -> b -> acrocks/helpers/defaultTo
dissoc
(deprecated)
(String | Integer) -> a -> acrocks/helpers/dissoc
fanout(a -> b) -> (a -> c) -> (a -> Pair b c)crocks/Pair/fanout
findFoldable f => ((a -> Boolean) | Pred) -> f a -> Maybe acrocks/Maybe/find
fromPairsFoldable f => f (Pair String a) -> Objectcrocks/helpers/fromPairs
getPath[ (String | Integer) ] -> a -> Maybe bcrocks/Maybe/getPath
getPathOra -> f [ (String | Integer) ] -> b -> acrocks/helpers/getPathOr
getProp(String | Integer) -> a -> Maybe bcrocks/Maybe/getProp
getPropOra -> (String | Integer) -> b -> ccrocks/helpers/getPropOr
liftA2Applicative m => (a -> b -> c) -> m a -> m b -> m ccrocks/helpers/liftA2
liftA3Applicative m => (a -> b -> c -> d) -> m a -> m b -> m c -> m dcrocks/helpers/liftA3
liftNApplicative m => Number -> ((*) -> a) -> (*m) -> m acrocks/helpers/liftN
mapPropsObject -> Object -> Objectcrocks/helpers/mapProps
mapReduceFoldable f => (a -> b) -> (c -> b -> c) -> c -> f a -> ccrocks/helpers/mapReduce
mconcatMonoid m, Foldable f => m -> f a -> m acrocks/helpers/mconcat
mconcatMapMonoid m, Foldable f => m -> (b -> a) -> f b -> m acrocks/helpers/mconcatMap
mreduceMonoid m, Foldable f => m -> f a -> acrocks/helpers/mreduce
mreduceMapMonoid m, Foldable f => m -> (b -> a) -> f b -> acrocks/helpers/mreduceMap
nAryNumber -> ((*) -> a) -> (*) -> acrocks/helpers/nAry
objOfString -> a -> Objectcrocks/helpers/objOf
omit[ String ] -> Object -> Objectcrocks/helpers/omit
once((*) -> a) -> ((*) -> a)crocks/helpers/once
partial(((*) -> c), *) -> (*) -> ccrocks/helpers/partial
pickFoldable f => f String -> Object -> Objectcrocks/helpers/pick
pipe((a -> b), ..., (y -> z)) -> a -> zcrocks/helpers/pipe
pipeKChain m => ((a -> m b), ..., (y -> m z)) -> a -> m zcrocks/helpers/pipeK
pipePPromise p => ((a -> p b d), ..., (y -> p z d)) -> a -> p z dcrocks/helpers/pipeP
pipeSSemigroupoid s => (s a b, ..., s y z) -> s a zcrocks/helpers/pipeS
prop
(deprecated)
(String | Integer) -> a -> Maybe bcrocks/Maybe/prop
propOr
(deprecated)
a -> (String | Integer) -> b -> ccrocks/helpers/propOr
propPath
(deprecated)
[ (String | Integer) ] -> a -> Maybe bcrocks/Maybe/propPath
propPathOr
(deprecated)
a -> [ (String | Integer) ] -> b -> acrocks/helpers/propPathOr
safe((a -> Boolean) | Pred) -> a -> Maybe acrocks/Maybe/safe
safeAftersafeAfter :: ((b -> Boolean) | Pred) -> (a -> b) -> a -> Maybe bcrocks/Maybe/safeAfter
safeLift((a -> Boolean) | Pred) -> (a -> b) -> a -> Maybe bcrocks/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 -> acrocks/helpers/tap
toPairsObject -> List (Pair String a)crocks/Pair/toPairs
tryCatch((*) -> b) -> (*) -> Result e bcrocks/Result/tryCatch
unary((*) -> b) -> a -> bcrocks/helpers/unary
unit() -> undefinedcrocks/helpers/unit
unsetPath[ (String | Integer) ] -> a -> acrocks/helpers/unsetPath
unsetProp(String | Integer) -> a -> acrocks/helpers/unsetProp

Logic#

Every 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

FunctionSignatureLocation
and(a -> Boolean) -> (a -> Boolean) -> a -> Booleancrocks/logic/and
ifElse(a -> Boolean) -> (a -> b) -> (a -> b) -> a -> bcrocks/logic/ifElse
implies(a -> Boolean) -> (a -> Boolean) -> a -> Booleancrocks/logic/implies
not(a -> Boolean) -> a -> Booleancrocks/logic/not
or(a -> Boolean) -> (a -> Boolean) -> a -> Booleancrocks/logic/or
unless(a -> Boolean) -> (a -> a) -> a -> acrocks/logic/unless
when(a -> Boolean) -> (a -> a) -> a -> acrocks/logic/when