giogonzo / fp-ts-ramda Goto Github PK
View Code? Open in Web Editor NEWRamda functions reimplemented in fp-ts
Home Page: https://giogonzo.github.io/fp-ts-ramda/
License: MIT License
Ramda functions reimplemented in fp-ts
Home Page: https://giogonzo.github.io/fp-ts-ramda/
License: MIT License
Hi! now that I'm back to typescript, I'm willing to learn fp-ts
but I miss some functions from ramda too much ๐ญ, how would ifElse
be implemented? Thanks!
As per title, I noticed this drastically improve performances in the cases I tested
How do you want to go about allPass
? I am by no means an expert in fp-ts
, but I'm struggling to find a reasonable implementation which makes me tempted to go this route:
function _allPass <T>(funs: Array<Predicate<T>>, val: T): boolean { return funs.every(fun => fun(val)); }
Here's a list of all the Ramda functions and their current status in this repo.
For each function, I added some notes on how they could be mapped in fp-ts terms taken from https://github.com/gcanti/fp-ts/blob/master/docs/recipes/ramda.md
We could use this issue to coordinate between multiple people on the ongoing effort in porting the entire API (or part of it)
Function | Implemented | Owners | Notes, mapping in fp-ts |
---|---|---|---|
__ | out of scope | ||
add | โ | @kightlingerh | see fp-ts 's Field |
addIndex | |||
adjust | โ | @giogonzo | |
all | โ | @kightlingerh | |
allPass | โ | @kightlingerh | |
always | โ | @giogonzo | |
and | โ | @giogonzo | |
any | โ | @kightlingerh | |
anyPass | โ | @kightlingerh | |
ap | At the core it's just fpTsInstance.ap |
||
aperture | |||
append | โ | @giogonzo | |
apply | should map to apply from fp-ts/lib/function |
||
applySpec | |||
applyTo | โ | @giogonzo | |
ascend | should map to Ord.contramap |
||
assoc | โ | @kightlingerh | |
assocPath | |||
binary | |||
bind | |||
both | |||
call | |||
chain | At the core it's just fpTsInstance.chain |
||
clamp | โ | @giogonzo | |
clone | |||
comparator | should map to Ord.fromCompare |
||
complement | |||
compose | should map to function.compose |
||
composeWith | |||
concat | see fp-ts 's Semigroup |
||
cond | |||
construct | |||
constructN | |||
converge | |||
countBy | |||
curry | should map to function.curry |
||
curryN | |||
dec | should map to function.decrement |
||
defaultTo | โ | @giogonzo | |
descend | see Ord.contramap , Ord.getDualOrd |
||
difference | |||
differenceWith | |||
dissoc | see Record.remove |
||
dissocPath | |||
divide | see fp-ts 's Field |
||
drop | should map to Array.drop |
||
dropLast | should map to Array.dropEnd |
||
dropLastWhile | |||
dropRepeats | |||
dropRepeatsWith | |||
dropWhile | should map to Array.dropWhile |
||
either | |||
empty | |||
endsWith | โ | @mfirry | Implemented for arrays only (not strings) |
eqBy | see Eq.contramap |
||
eqProps | |||
equals | โ | @kightlingerh | see Eq |
evolve | |||
F | should map to function.constFalse |
||
filter | see Filterable |
||
find | Array.find |
||
findIndex | Array.findIndex |
||
findLast | Array.findLast |
||
findLastIndex | Array.findLastIndex |
||
flatten | Array.flatten |
||
flip | function.flip |
||
forEach | |||
forEachObjIndexed | |||
fromPairs | โ | @giogonzo | |
groupBy | NonEmptyArray.groupBy |
||
groupWith | see NonEmptyArray.group , NonEmptyArray.groupSort |
||
gt | Ord.greaterThan |
||
gte | Ord.greaterThanOrEq |
||
has | Record.member |
||
hasIn | |||
hasPath | |||
head | Array.head |
||
identical | see Eq |
||
identity | function.identity |
||
ifElse | |||
inc | function.increment |
||
includes | |||
indexBy | see NonEmptyArray.groupBy |
||
indexOf | Array.findIndex |
||
init | Array.init |
||
innerJoin | |||
insert | Array.insertAt |
||
insertAll | |||
intersection | |||
intersperse | |||
into | |||
invert | |||
invertObj | |||
invoker | |||
is | |||
isEmpty | |||
isNil | |||
join | |||
juxt | |||
keys | Record.keys |
||
keysIn | |||
last | Array.last |
||
lastIndexOf | Array.findLastIndex |
||
length | |||
lens | should use monocle-ts lib |
||
lensIndex | should use monocle-ts lib |
||
lensPath | should use monocle-ts lib |
||
lensProp | should use monocle-ts lib |
||
lift | |||
liftN | |||
lt | Ord.lessThan |
||
lte | Ord.lessThanOrEq |
||
map | At the core it's just fpTsInstance.map |
||
mapAccum | |||
mapAccumRight | |||
mapObjIndexed | |||
match | |||
mathMod | |||
max | Ord.max |
||
maxBy | |||
mean | |||
median | |||
memoizeWith | |||
mergeDeepLeft | |||
mergeDeepRight | |||
mergeDeepWith | |||
mergeDeepWithKey | |||
mergeLeft | |||
mergeRight | |||
mergeWith | see Record.getMonoid |
||
mergeWithKey | |||
min | Ord.min |
||
minBy | |||
modulo | |||
move | |||
multiply | see Field |
||
nAry | |||
negate | Ring.negate |
||
none | |||
not | |||
nth | Array.index |
||
nthArg | |||
o | |||
objOf | โ | @kightlingerh | Record.singleton |
of | array.of |
||
omit | |||
once | |||
or | see Semigroup.semigroupAny |
||
otherwise | |||
over | should use monocle-ts lib |
||
pair | function.tuple |
||
partial | |||
partialRight | |||
partition | see Filterable |
||
path | should use monocle-ts lib |
||
pathEq | |||
pathOr | |||
pathSatisfies | |||
pick | |||
pickAll | |||
pickBy | |||
pipe | function.pipe |
||
pipeWith | |||
pluck | |||
prepend | Array.cons |
||
product | see Foldable.product |
||
project | |||
prop | โ | @kightlingerh | uses monocle-ts |
propEq | |||
propIs | |||
propOr | |||
props | |||
propSatisfies | |||
range | Array.range |
||
reduce | |||
reduceBy | |||
reduced | |||
reduceRight | |||
reduceWhile | |||
reject | |||
remove | |||
repeat | Array.replicate |
||
replace | |||
reverse | Array.reverse |
||
scan | Array.scanLeft |
||
sequence | see Traversable in fp-ts |
||
set | should use monocle-ts lib |
||
slice | |||
sort | |||
sortBy | |||
sortWith | |||
split | |||
splitAt | Array.split |
||
splitEvery | @mfirry | Array.chunksOf |
|
splitWhen | |||
startsWith | |||
subtract | see Ring |
||
sum | |||
symmetricDifference | |||
symmetricDifferenceWith | |||
T | function.constTrue |
||
tail | Array.takeWhile |
||
take | Array.take |
||
takeLast | โ | @mfirry, @gcanti | Implemented for arrays only (not strings) |
takeLastWhile | |||
takeWhile | Array.takeWhile |
||
tap | |||
test | |||
then | |||
thunkify | |||
times | Array.makeBy |
||
toLower | |||
toPairs | โ | @giogonzo | |
toPairsIn | |||
toString | |||
toUpper | |||
transduce | |||
transpose | |||
traverse | see Traversable |
||
trim | |||
tryCatch | IOEither.tryCatch |
||
type | |||
unapply | |||
unary | |||
uncurryN | |||
unfold | |||
union | |||
unionWith | |||
uniq | Array.uniq |
||
uniqBy | Array.uniq |
||
uniqWith | |||
unless | |||
unnest | see Chain.flatten |
||
until | |||
update | Array.unsafeUpdateAt |
||
useWith | |||
values | see Record.toArray |
||
valuesIn | |||
view | should use monocle-ts lib |
||
when | |||
where | |||
whereEq | |||
without | |||
xprod | โ | @giogonzo | |
zip | Array.zip |
||
zipObj | |||
zipWith | Array.zipWith |
I've tried a simple definition along these lines:
import { takeLast } from './takeLast'
export function endsWith<A>(suffix: Array<A>): (list: Array<A>) => boolean;
export function endsWith<A>(suffix: Array<A>, list: Array<A>): boolean;
export function endsWith<A>(suffix: Array<A>, list?: Array<A>): any {
if (list === undefined) {
return function(list: Array<A>) {
return endsWith(suffix, list);
};
} else {
return takeLast(suffix.length, list) === suffix;
}
}
(also lurking on https://github.com/ramda/ramda/blob/v0.26.1/source/endsWith.js#L27)
But it doesn't seem to work.
Any hint?
Any chance you can add a license to the repo?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.