On Fri, Sep 27, 2013 at 11:31 AM, Anthony Tavener wrote: > > On Fri, Sep 27, 2013 at 9:08 AM, Dmitry Grebeniuk wrote: > >> >> Why will anyone ever need more than 200 constructors of a sum type? >> (also note the presence of polymorphic variant types.) >> >> > Back when I read about the limit on constructors I had a moment of worry. > Thankfully the limit is only on non-constant constructors. > > I currently have a variant with 292 constructors, but only 30 are > non-constant. > These represent optional characteristics a character may have in a game, > some > with additional payload. I could imagine all of them having their own > payload, > but of course there are other options, like polymorphic variants, or > encoding these > purely as data rather than types. > > I wanted to share that as a "be careful of what seems impossible from your > perspective". ;) > Right. Constant constructors are represented as integers and require no header, so they're very cheap. And polymorphic variants use more memory, so they're not a great option. Having the flexibility for more constructors is a good thing. Yotam