samhh / fp-ts-std Goto Github PK
View Code? Open in Web Editor NEWThe missing pseudo-standard library for fp-ts.
Home Page: https://samhh.github.io/fp-ts-std/
License: MIT License
The missing pseudo-standard library for fp-ts.
Home Page: https://samhh.github.io/fp-ts-std/
License: MIT License
Probably out of scope if we want to support Node? Or perhaps not, Node users would just need to not import those. Or fp-ts-dom
?
Improves docs e.g. O.Option
-> Option
when using flow
.
Like ordinary filtering does.
Descriptions and versions are now enforced but examples notably are not.
It's probably a good idea to do so, though there are some exports for which an example arguably poses no value.
See also: gcanti/docs-ts#45
Candidates:
JSONString
- Stringified JSONUnit
- to do away with null
and undefined
entirelyHello! I'm a big fan of this library!
Maybe it would be useful to have a parseInt
function in Number.ts
? It might help with #29
import {flow} from 'fp-ts/function'
import * as O from 'fp-ts/Option'
import {invert} from './Boolean'
const parseInt = flow(Number.parseInt, O.fromPredicate(invert(isNaN)))
Or is this too trivial to be worth it?
Not considered it at all thus far, very likely needs attention.
Current not should be renamed to something else.
This'll make it consistent with Haskell and Ramda.
Blocked by: eslint-functional/eslint-plugin-functional#194
Or only merge into master for releases. The docs are getting ahead of releases.
Maybe duplicate?
Already a dependency, let's actually use it now.
Datum/RemoteData are nice, it'd be nice to support them without adding any further dependencies.
I think?
Can't get this to work without thunking A
(where ReturnTypes
is just ReturnType
over an array via mapped type):
const fork = <A, B, C extends Array<(x: A) => B>>(gs: [...C]) => (x: A): ReturnTypes<C> =>
gs.map(applyTo(x)) as ReturnTypes<C>
Example of intended usage:
declare const sum: (x: number[]) => number
declare const length: (x: unknown[]) => number
declare const joined: (x: unknown[]) => string
fork([sum, length, joined]) // (xs: number[]) => [number, number, string]
This'd cross out juxt
in the Ramda doc but be... better. Can probably then tackle converge
too.
To log a task duration. Something like this. I suppose it can be useful.
export const logDuration = <A>(ma: Task<A>): Task<A> => {
return () => {
const start = Date.now();
return ma().then((a) => {
// eslint-disable-next-line no-console
console.log(`${(Date.now() - start) / 1000}s`);
return a;
});
};
};
Not sure how this'll work in terms of webextension-polyfill-ts
. Don't want to include a dependency like that for anyone not using it.
Some newtypes for things like Milliseconds
would be handy.
Here's a rough draft of the concept. Pick
has become a bit simpler, and they both now accept rest parameters. Omit
(may?) have better performance characteristics w/o the use of delete
(though this is unclear)
Not sure if one or neither of these are desired as they are breaking changes, but I can spin up a PR if it is/they are!
P.S. Credit to @qlonik for UnionToIntersection and for the delete research
The tests using timers fail in 27.0.6 irrespective of which timer strategy is used.
A la fp-ts and other community projects.
Consistency with unless
and easier to understand the type signature at a glance.
e.g.
const minimum = <A>(ord: Ord<A>): ((xs: NonEmptyArray<A>) => A) => NEA.fold(getMeetSemigroup(ord))
Like Haskell's minimum
and maximum
, but total.
Instead of unknown
, could it be?:
type JSONType = null | string | boolean | number | JSONType[] | Record<string, JSONType>
The files are included with the package but since package.json
does not have field main
, it doesn't know where to look.
Let's not make consumers do this themselves.
Probably don't export mkJSONString.
Does anyone care about this? So we could do away with null
/undefined
entirely.
Some stuff in Lodash that's not in fp-ts or Ramda could be useful here.
Zip currently only works for arrays of the same size, which is sometimes fine but sometimes you want to zip up uneven arrays and keep the parts that were uneven. How about a function like:
const zipWithAll = <A, B, C>(
fa: ReadonlyArray<A>,
fb: ReadonlyArray<B>,
f: (a: O.Option<A>, b: O.Option<B>) => C): ReadonlyArray<C> => {
const fc: Array<C> = []
const len = Math.max(fa.length, fb.length)
for (let i = 0; i < len; i++) {
fc[i] = f(i < fa.length ? O.some(fa[i]) : O.none, i < fb.length ? O.some(fb[i]) : O.none)
}
return fc
}
// zip but just gives arrays of size 1 when its uneven
const zipAll = <A, B, C>(fa: ReadonlyArray<A>, fb: ReadonlyArray<B>) =>
zipWithAll(fa, fb, (a, b) => A.compact<(A|B)>([a, b]))
zipAll([1,2,3], [4,5])
// => [[1,4], [2, 5], [3]]
type Character = string & { length: 1 };
e.g. no need for a sum
function when you can just do fold(monoidSum)
Find myself having to rewrite a functional wrapper around accessing process.env
quite often.
Probably need to adjust publish mechanism to copy it into dist/.
Take inspiration from fp-ts-local-storage, but encode the possibility of failure into every applicable type signature.
It can throw a TypeError.
I'm a little tired of using a Monoid to concat arrays together all the time, how would y'all feel about a convenience function for Array like
const concat = <A>(a:A[]) => (b:A[]) => A.getMonoid<A>().concat(a, b)
just so we can pipe some stuff together like
pipe(R.keys(x), concat(R.keys(y)), A.uniq(eqString))
Oops!
On develop branch in CI. 100% locally with Node 15.
join
not split
, silly.
not
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.