Large enum sets - Haskell

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

jkeuhlen

(Also asked in FP slack, not sure how much crossover there is right now)
Has anyone every worked with large enum sets? I'm trying to determine the best way to work with a bunch of specific codes that we want to have type safety for. Think data Code = X0001 | X0002 | ... | X9999 and we will probably have more than one of these types scoped by their applicable countries. I could dump all of the codes into a CSV and load that via template haskell or just write out all of the enums directly. I've never worked with this many of them before so wasn't sure if there was a best practice around it that made it easier to work with.

Asad Saeeduddin

I don't know your use case, but maybe you can use the inhabitants of kind Nat instead

Asad Saeeduddin

you can use a type class to constrain it to natural numbers smaller than some upper bound