Elixir's intersection types

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 มิ.ย. 2024
  • Elixir is exploring the idea of adding types. During ElixirConf 2023, José Valim talked about the need for an intersection type when specifying types for certain Elixir functions. I checked out the research paper to understand more. Here, I show why we need that type.
    For more videos, check out www.elixirstreams.com
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 17

  • @1astery1
    @1astery1 8 หลายเดือนก่อน +2

    Thanks, I was a bit confused, and your video really clarify that!

    • @germanvelasco
      @germanvelasco  8 หลายเดือนก่อน

      So glad to hear that!

  • @mythrando
    @mythrando 7 หลายเดือนก่อน +2

    Thank you, I was confused as well and this cleared it up very nicely!

    • @germanvelasco
      @germanvelasco  7 หลายเดือนก่อน +1

      Glad to hear it!

  • @aarroisi
    @aarroisi หลายเดือนก่อน

    I hope that it will be possible to separate the type per each function clause and automatically make all function clause's types are combined with an "and". It will be a lot cleaner.

  • @kostasgkoutis8534
    @kostasgkoutis8534 9 หลายเดือนก่อน +3

    That reminds me a lot function overloading

  • @encapsulatio
    @encapsulatio 9 หลายเดือนก่อน +1

    Where can I see the video presentations they made on the type system at ElixirConf 2023?

    • @germanvelasco
      @germanvelasco  8 หลายเดือนก่อน

      th-cam.com/video/giYbq4HmfGA/w-d-xo.html

  • @defman21
    @defman21 9 หลายเดือนก่อน +1

    2:48 I haven’t watched the talks yet, but I’d really appreciate if we could provide a type specification for each of the function’s heads:
    $ integer() -> integer()
    def negate(x), do: …
    $ boolean() -> boolean()
    def negate(x), do: …

    • @germanvelasco
      @germanvelasco  9 หลายเดือนก่อน +1

      Yeah, that would be nice. I don't know if there'll be limitations around that, but I like that we can at least break it into multiple lines. It makes it read very nicely.

    • @bo0tzz
      @bo0tzz 8 หลายเดือนก่อน +1

      José mentioned that you can format the type either way - all at the top, or above each head.

    • @tshakah
      @tshakah 8 หลายเดือนก่อน

      My understanding after watching Jose's video was that you could do this

  • @cwhy
    @cwhy 8 หลายเดือนก่อน

    Like your concise videos, and of course Elixir. Gonna be your 667'th subscriber to break the 666 here 😆

    • @germanvelasco
      @germanvelasco  8 หลายเดือนก่อน

      Thanks for looking out for that number! 👀 😂

  • @ericg3065
    @ericg3065 8 หลายเดือนก่อน

    I still don't see why this is necessary. The guard clause clearly indicates what type of data the function accepts. I just hope Elixir doesn't turn into something similar to TypeScript.

    • @germanvelasco
      @germanvelasco  8 หลายเดือนก่อน +2

      The guard clause specifies data at runtime. Types would do it at compile time. I too am worried about what types will mean for Elixir, but I know José and team are very careful in their approach. So, I think we'll land with something good -- if they land at all.

    • @ericg3065
      @ericg3065 8 หลายเดือนก่อน +2

      @@germanvelasco Oh now I see. I like the simplicity of $ integer() -> integer(). If they go with this approach I hope it replaces typespecs. It's a lot easier on the eyes. Elixir is not perfect and has flaws like any other language but I love it's simplicity and expressiveness. It's the only language I've been able to understand at a high level. I hate to see that go away by introducing more complexity to the language. Thanks so much for all of your contributions to Elixir and keep up the good work :)