1. 9

  2. 4

    Pretty clever! Going out to 8 generic parameters seems aggressive but func<…> goes out to 16 (!!). Makes me wonder if it would be worthwhile to add variadic generic parameters. Could be something like class Foo<…T> {} where T would resolve to a T[].

    Libraries like this make me miss C# and its bulletproof generics.

    1. 3

      Awesome! I have a similar library for JavaScript called Results, and it’s encouraging to see another implementation choose a similar API.

      At OpenRide, on the web client, we model a lot of data as discriminated unions with Results, to force it to handle all the cases. Of course, since it’s JS and we don’t have static typechecking to enforce it, bugs can still sneak in wherever tests don’t cover a path that run through a .match. Despite that, it has still felt like a significant win so far.

      Does anyone know of any good research/studies/blog posts or anything that look at discriminated unions, either as language features, or as libraries bolted on?

      (edit: whoops, hit Update instead of Preview the first time)