samhh / fp-ts-std

The missing pseudo-standard library for fp-ts.
https://samhh.github.io/fp-ts-std/
MIT License
207 stars 27 forks source link

Update ramda-comparison.md #104

Closed SimonAM closed 2 years ago

SimonAM commented 2 years ago

Changed links which references fp-ts-std where it should be fp-ts. Removed links to functions that does not exist.

anyPass : refers to anyPass. No such function anywhere. allPass : refers to all Pass. No such function anywhere. either : refers to boolean::either. No such function.

samhh commented 2 years ago

Thanks again! anyPass and allPass have moved to Predicate. either can now point to or.

SimonAM commented 2 years ago

added documentation for pick.

Pick returns undefined on missing values. This behavior differs from the ramda implementation and should be clear to the user.

samhh commented 2 years ago

The example you provided doesn't typecheck:

pipe({ a: 1, b: 'two' }, pick(['a', 'c']))
Type '"c"' is not assignable to type '"a" | "b"'.
SimonAM commented 2 years ago

Ok. I'm really new to typescript. Do you know why i'm not getting the error on my stackblitz application?

samhh commented 2 years ago

Your import should be from fp-ts-std/Record.

SimonAM commented 2 years ago

Ah yes wonderful, now i see the type error! However, this doesn't allow the code to run on stackblitz because of conditional imports not working. Shouldn't #7 be open or is there something that I'm missing?

samhh commented 2 years ago

That website doesn't work in my browser so I can't offer very specific advice, but per the README:

fp-ts-std is published with both ESM and CJS modules. The import paths in either case needn't change and the appropriate module resolution should be picked up by Node and your bundler, however if your environment doesn't support conditional exports you'll need to import directly from a dist/(cjs|esm)/ subdirectory. Given ESM modules the library should tree shake well.

We use the library at work with Webpack (ESM), and it runs okay in Node for me locally (CJS):

> R = require('fp-ts-std/Record')
> R.pick.name
'pick'
samhh commented 2 years ago

Thanks for this, mostly incorporated in https://github.com/samhh/fp-ts-std/commit/3ffee45ac9c528ca6616896104a76605f0346229.