Discriminated Unions in TypeScript, Effect, and ArkType by David Blass (Effect Days 2024)
Вставка
- Опубліковано 25 лис 2024
- Get Effect support from the community → / discord
Effect is an ecosystem of tools to build better applications and libraries in TypeScript.
Website & docs: effect.website/
Community: / discord
X (Twitter): / effectts_
Github: github.com/Eff...
______________________________________
Effect Days 2024 was sponsored by:
Inato - inato.com/
Evryg - www.evryg.com/
Effectful Technologies - effectful.co/
______________________________________
David Blass gave us a deeper understanding of the set theory at the heart of TypeScript and how libraries like Effect and ArkType leverage it to improve static and runtime performance and make your code safer.
Highlights:
→ Introducing discriminated unions and set-based types in TypeScript.
→The benefits of discriminated unions, including constant time checks and better error messages.
→ The practical application of discriminated unions in TypeScript and Effect, showcasing their power in pattern matching.
______________________________________
David Blass is an open-source TypeScript developer working on ArkType - a native type syntax optimized from editor to runtime.
Learn more about and follow David:
X (Twitter): / ssalbdivad
Github: github.com/ssa...
ArkType: arktype.io/
______________________________________
#Effect #TypeScript #TypeScriptLibrary #ArkType
you can implement negative: type Negative = T extends N ? never : T; type NotString = Negative
I like your funny words magic man
Hyped for both ArkType and Effect!
The only time I would say we need more discrimination, for sure!
After viewing this video and reading the official documention for arktype I still don't know what it brings to the table compared to Effect/schema...it helps me validate numbers? I can already do that... Don't mean to be negative, but I'm having trouble understanding the use case
Same use case as zod, io-ts and any other validation library. It aims to have a simpler syntax and focuses on performance, in some cases it can be much faster than the alternatives. As one of the designing authors of effect/schema I can say that we share some design with ArkType, namely they are both AST based compared to the others that are not, which means they both allow you to derive whatever you want from the types and they both can take advantage of introspecting the schema structure to optimise decoding / encoding. I personally don't like the design choice of having a type-level parser and of using string literals to declare types and prefer the approach that we use in effect/schema but that is sort of a matter of personal taste, David's work on ArkType is beyond imaginable