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

КОМЕНТАРІ • 6

  • @snatvb
    @snatvb 4 місяці тому +4

    you can implement negative: type Negative = T extends N ? never : T; type NotString = Negative

    • @JohnMcclaned
      @JohnMcclaned Місяць тому

      I like your funny words magic man

  • @minyoungna6642
    @minyoungna6642 5 місяців тому +3

    Hyped for both ArkType and Effect!

  • @z0nx
    @z0nx 5 місяців тому +4

    The only time I would say we need more discrimination, for sure!

  • @MarioBasic
    @MarioBasic 5 місяців тому +1

    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

    • @michaelarnaldi6680
      @michaelarnaldi6680 5 місяців тому +3

      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