Comments (4)
@flauwekeul added and published in v3.6.0
π
from ts-belt.
Unless I'm missing something
no, youβre actually not missing anything :)
I think this is very clean.
I take your point and fully agree this is a very clean solution, but on the other hand most of the time it requires defining types manually, which is not developer-friendly and was much problematic in Ramda (if you use Ramda in TS), and basically I wanted to avoid this, for instance:
type SomeType1 = {
readonly prop: string
}
const someFn: (arg: SomeType1) => string = createPipe(D.getUnsafe('prop'), S.toUpperCase)
someFn(value)
with the current implementation, you only need to define a type to the provided argument and a result type is correctly inferred:
type SomeType1 = {
readonly prop: string
}
const someFn = (value: SomeType1) => pipe(value, D.getUnsafe('prop'), S.toUpperCase)
someFn(value)
I consider adding pipe
that returns a new function and accepts a single argument but still, due to TS limitations, most of the time developers will have to use it like the following to get types correctly inferred:
const value = pipe(
['hello', 'world'],
A.map(createPipe(S.remove('o'), S.toUpperCase)),
) // β ['HELL', 'WRLD']
from ts-belt.
Thanks for explaining. I didn't take into account that TS is the limiting factor here. Also, I see that fp-ts' pipe
has the same signature, probably for the same reason. However, fp-ts also has the flow
util. I haven't used it yet, but maybe they figured out a way to make it infer types without too much hassle.
from ts-belt.
thanks for sharing the link! β€οΈ good news, the initial implementation of flow
in ts-belt
looks really promising, and I think it will be included in the next version
from ts-belt.
Related Issues (20)
- Add type guard compatible overload for `O.filter` HOT 1
- Typescript error from Result example HOT 2
- Library reexport
- What is the recommended way of testing the value in an object? HOT 5
- a very simple request : N.toString HOT 1
- Handling generic typing for D.toPairs()
- Would a D.deleteOtherKeys be useful as part of the core? HOT 1
- F.getWithDefault Coercion type problem HOT 5
- Unsafe `isNone()` and `isSome()` type predicates HOT 1
- Ts-belt is 4x slower because it uses the arguments object
- Why an Option type instead of `type` | undefined? HOT 4
- Using unions for a result HOT 11
- ts-belt usage example flagged by TypeScript HOT 2
- why not `Do Notation` and `Applicative`
- Misleading annotations for Array.range
- Is this library still being maintained? HOT 1
- π§ Announcement: the current state of ts-belt π§ HOT 3
- `AR.isOk` and `AR.isError` not defined
- `AR.toOption` for `undefined` promise resolutions resulting in `{ BS_PRIVATE_NESTED_SOME_NONE: 0 }` HOT 1
- O.Option's functions with null literal value behaves differ from with undefined literal values HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ts-belt.