1. 9
    1. 2

      I love union (sum) types! It’s a great way to define recursive types in an expressive and efficient fashion. For Advent of Code last year I used them to solve the “Snail Problem” Day 18

      struct Snail
          left::Union{Int, Snail}
          right::Union{Int, Snail}


      I was able to do it functionally in Julia, relying on Multiple Dispatch and Union types. See a solution written in Go that’s twice as many lines and a lot harder to read, not to pick on the author but rather the language that requires a lot more work to parse and reparse a structure that can be represented naturally with the right types.

      1. 2

        minor pedantic note - union types aren’t the same as sum types (they are sometimes known as untagged and tagged unions respectively). here’s one example of where that makes a difference.