terminology: sum constructors - Haskell

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

Torsten Schmits

Given a sum type data A = X | Y, how do you qualify the constructor X in relation to a value y = Y? uninhabited?

Georgi Lyubenov // googleson78

never thought about how to refer to X in this situation :thinking:

Torsten Schmits

you're doing too little type level magic!

Torsten Schmits

maybe something like chosen and not chosen

Torsten Schmits

for A + (B + (C + ..., inl would always refer to an inhabited constructor, but the last element would be an inr, so that doesn' work either :oh_no:

Georgi Lyubenov // googleson78

inhabited is confusing to me because it usually refers to types, not terms

TheMatten

I guess it's like asking about "foo" in relation to bar = "bar" - maybe it's simply "different value" or "unequal"?

Torsten Schmits

Georgi Lyubenov // googleson78 said:

inhabited is confusing to me because it usually refers to types, not terms

you could think of the sum type as a universe and the constructors as its types :sweat_smile:

Torsten Schmits

so my use case is that I do an iteration over the constructors with Generic with a value at hand, executing different operations based on whether the value is of the given constructor.