fiber/effects for UI and event bus, eg. OpenCode's opentui and harness are built on this library, been using the 4-beta whilst hacking on some OpenCode plugins
The types allow you to very narrowly define functions so that you can, for example, require that a NonEmptyArray be passed. This helps to fulfill that requirement without casts.
As a Python person, that 2nd one looks like a bug. Expecting an exception there. Although also Python doesn't have an `undefined`; `None` would have to suffice.
Not really. If you try to take something from an empty container (language or real life) then you should get an error/issue. The container type doesn't change when it's empty, and the operation is just senseless; all that's happening here is added mental gymnastics that makes code unintuitive to read. Checking if/asserting a container isn't empty is a straight forward `if cont: ...` or `assert cont` in Python, which anyone can just get.
Right, you can attempt to take and potentially error, but if you already know that taking is possible you can skip the noise and simply return a result. Checking if your container is empty every time you remove an item is not free.
The type soft-enforces₁ it immediately for everyone though.
Without the type there are a few possibilities:
1. I could forget the assertion and have buggy code without realizing.
2. I could ensure that all uses do the assertion. Even if we can statically know that it is empty. This costs us the check for every call of the function, and ends up being more code.
Alternatively I could statically know in advance. The code won't let me `Array.pop` because that is invalid, so:
1. I *cannot* make that mistake
2. It cost no runtime performance
3. It cost no extra code in a function
1: I say soft-enforce because if someone were to pass a value incorrectly cast as NonEmpty, it would still have a runtime error, but that is a bug elsewhere, not here.
part of it is because js is a throwing language, and since there are no "checked" exceptions they need to basically rebuild the universe in their paradigm.
but they seem to want to rebuild everything, eg
> The Console service exposes common console methods such as logging, warnings, errors, groups, counters, tables, and timers. Because console access goes through a service, programs can use custom console implementations in tests or other environments. This module also includes scoped helpers that close console groups or timers automatically.
Petty aside: Several JS people I know who were previously quite down on using a dependency injection framework are now seeing the benefits after adopting Effect. The most egregious example being a colleague who considered the adaption of DI tooling to be a language-level defect. It’s now one of his primary selling points for Effect.
i wouldn't consider the opinions of people who consider themselves "js people" to be particularly interesting, considering the ultimate state of that ecosystem. i say that as someone who writes js professionally.
you dont need an entire runtime to implement polymorphic console.logging. tbh the fact they want to implement the world to do this is more of an inditement against this approach than anything else
It isn't a case of wanting to implement the world to do this though.
Instead, it is a case of the active users of the library saying, "Wow, the Effect way of doing this is so much nicer, can we have everything this way please?"
Not playing devil's advocate or anything, but effect systems go beyond DI: it's not just about passing around a capability, but managing its lifecycle in a referentially transparent manner, i.e. monads all the way down. It's a real pain, but they set themselves up to bear the burden, so, good for the rest of us I guess?
Almost every single JavaScript package is on NPM. Being on NPM does not automatically increase your attack vectors. The vast majority of the npm attacks have been "Supply Chain Attacks"[0] where an upstream dependency is injected with malicious code, then automatically downloaded and executed when users update a package.
If you look at Effect's package.json on GitHub[1], you'll see that they have several "devDependencies", but no regular "dependencies". That means, unless you are working on the package itself, using it does not require downloading any other packages whatsoever. Thus, Effect is not susceptible to any of the issues that you have read about in the news. The only way malicious code could be transported through the package would be if the maintainers suddenly became evil.
That being said, I don't use Effect and I think it's kind of overrated by the FP community. But, I appreciate the ideas behind it, and I felt the need to educate you about your needless fear of any library simply existing on NPM.
Sometimes I use the wayback machine to visit marketing pages before the advent of AI, so I can get a better understanding of what they actually do instead of just a bunch of AI jargon.
I’ve had to click around a bit and I think this is a better summary: <a href="https://effect.website/docs/v4/getting-started/why-effect#the-effect-pattern" rel="nofollow">https://effect.website/docs/v4/getting-started/why-effect#th...
import { Effect } from "effect"
const divide = (a: number, b: number): Effect.Effect<number, Error, never> =>
b === 0
? Effect.fail(new Error("Cannot divide by zero"))
: Effect.succeed(a / b)
Effect.runSync(divide(4, 2)) // => 2
This seems to be similar in spirit to railway oriented programming (see e.g. <a href="https://returns.readthedocs.io/en/latest/pages/railway.html" rel="nofollow">https://returns.readthedocs.io/en/latest/pages/railway.html), but I’m not 100% confident here.
Yes, I read that and left scratching my head. Does it also encabulate?
Really reminded me of this classic pitch (and yes I know it's not the original turbo encabulator).
> More over, whenever fluorescent score motion is required it may also be employed in conjunction with a drawn reciprocation Dingle arm to reduce sinusoidal depleneration. The Retro Encabulator has now reached a high level of development and it's being successfully used in the operation of Millford Trunions. It's available soon wherever Rockwell Automation products are sold.
A library for effects. Algebraic effects, to be more precise.
To be fair "algebraic effects" is part of my priors. If you don't know what that is those specific words won't help you, but the examples should!
>incredibly simple to build the API and a background worker process with Effect. I get logging, telemetry, error handling, concurrency, API doc generation, and more for free!
But that can't be a library? Must be a framework? (eg more batteries included)
Not only that but the play tab is broken. The default example does not compile in their own playground. And I'm still not sure what this thing is.
claude-ai · · focus · HN ↗
verdverm · · focus · HN ↗
claude-ai · · focus · HN ↗
[dead]
slopinthebag · · focus · HN ↗
nvme0n1p1 · · focus · HN ↗
Rebuild JS's core data structures: <a href="https://effect.website/docs/v4/api/effect/Array" rel="nofollow">https://effect.website/docs/v4/api/effect/Array
Then rebuild the entire JS ecosystem on top of their custom data structures.
And then the main heading on their home page is "Reliable TypeScript for the AI era"? Really? I'll pass.
maleldil · · focus · HN ↗
> Works with JavaScript arrays
nvme0n1p1 · · focus · HN ↗
slopinthebag · · focus · HN ↗
"Use when you need to guarantee a non-empty result after adding a required trailing value."
...whatever that means lol
spaethnl · · focus · HN ↗
itishappy · · focus · HN ↗
skeledrew · · focus · HN ↗
spaethnl · · focus · HN ↗
skeledrew · · focus · HN ↗
itishappy · · focus · HN ↗
spaethnl · · focus · HN ↗
Without the type there are a few possibilities: 1. I could forget the assertion and have buggy code without realizing. 2. I could ensure that all uses do the assertion. Even if we can statically know that it is empty. This costs us the check for every call of the function, and ends up being more code.
Alternatively I could statically know in advance. The code won't let me `Array.pop` because that is invalid, so:
1: I say soft-enforce because if someone were to pass a value incorrectly cast as NonEmpty, it would still have a runtime error, but that is a bug elsewhere, not here.itishappy · · focus · HN ↗
slopinthebag · · focus · HN ↗
but they seem to want to rebuild everything, eg
> The Console service exposes common console methods such as logging, warnings, errors, groups, counters, tables, and timers. Because console access goes through a service, programs can use custom console implementations in tests or other environments. This module also includes scoped helpers that close console groups or timers automatically.
yeah idk mate
spaethnl · · focus · HN ↗
bbg2401 · · focus · HN ↗
slopinthebag · · focus · HN ↗
slopinthebag · · focus · HN ↗
spaethnl · · focus · HN ↗
Instead, it is a case of the active users of the library saying, "Wow, the Effect way of doing this is so much nicer, can we have everything this way please?"
itishappy · · focus · HN ↗
Console is IO and IO is the effect.
slopinthebag · · focus · HN ↗
ezst · · focus · HN ↗
amelius · · focus · HN ↗
But I only read the news when it comes to npm, so maybe my fear is not justified.
tiagod · · focus · HN ↗
amelius · · focus · HN ↗
jazzypants · · focus · HN ↗
If you look at Effect's package.json on GitHub[1], you'll see that they have several "devDependencies", but no regular "dependencies". That means, unless you are working on the package itself, using it does not require downloading any other packages whatsoever. Thus, Effect is not susceptible to any of the issues that you have read about in the news. The only way malicious code could be transported through the package would be if the maintainers suddenly became evil.
That being said, I don't use Effect and I think it's kind of overrated by the FP community. But, I appreciate the ideas behind it, and I felt the need to educate you about your needless fear of any library simply existing on NPM.
[0] <a href="https://unit42.paloaltonetworks.com/monitoring-npm-supply-chain-attacks/" rel="nofollow">https://unit42.paloaltonetworks.com/monitoring-npm-supply-ch...
[1] <a href="https://github.com/Effect-TS/effect/blob/main/package.json" rel="nofollow">https://github.com/Effect-TS/effect/blob/main/package.json
spaethnl · · focus · HN ↗
[dead]
WalterGR · · focus · HN ↗
[dead]
miguel-muniz · · focus · HN ↗
vantassell · · focus · HN ↗
Their main page makes the product pretty clear.
<a href="https://effect.website" rel="nofollow">https://effect.website
SwellJoe · · focus · HN ↗
I can't parse this into meaning anything:
"Reliable TypeScript for the AI era
Build production-ready systems your team can ship, customers can depend on, and AI agents can work with."
OK, it's written in TypeScript, I guess. Is it a library? What does it do?
notpushkin · · focus · HN ↗
exceptione · · focus · HN ↗
notpushkin · · focus · HN ↗
pohl · · focus · HN ↗
itishappy · · focus · HN ↗
> Reliable TypeScript for the AI era
It is a library.
aand16 · · focus · HN ↗
oliwarner · · focus · HN ↗
hexasquid · · focus · HN ↗
oliwarner · · focus · HN ↗
Really reminded me of this classic pitch (and yes I know it's not the original turbo encabulator).
> More over, whenever fluorescent score motion is required it may also be employed in conjunction with a drawn reciprocation Dingle arm to reduce sinusoidal depleneration. The Retro Encabulator has now reached a high level of development and it's being successfully used in the operation of Millford Trunions. It's available soon wherever Rockwell Automation products are sold.
itishappy · · focus · HN ↗
oliwarner · · focus · HN ↗
And if multiple people are wondering what something fundamentally is, perhaps it's the pitch, not the people.
itishappy · · focus · HN ↗
To be fair "algebraic effects" is part of my priors. If you don't know what that is those specific words won't help you, but the examples should!
Incipient · · focus · HN ↗
But that can't be a library? Must be a framework? (eg more batteries included)
nateb2022 · · focus · HN ↗
That's not the definition of a framework.
You call a library. A framework calls you.
airstrike · · focus · HN ↗
[dead]
14u2c · · focus · HN ↗
0x20cowboy · · focus · HN ↗
lenkite · · focus · HN ↗
Anyways, I understood it as a Typescript copy of Scala's ZIO library.