Search code examples
constraint-programmingminizinc

How do I return the type of a variable in minizinc?


I'd like to do something like this:

enum COLORS = {"green", "red", "blue"};
output [show(type(COLORS)];

And I would expect this to output enum. I can't seem to find out from the docs how to do this.


Solution

  • MiniZinc currently does not include any reflection operations that will allow you to get the name of the type.

    Your example might actually not be a great one, because the enum keyword semantically creates a new type, in this case COLORS. So my intuition for what a type function would return would be COLORS, not enum.

    If you feel this could be a useful feature (and you maybe have a more extensive example where this is used), then you can submit an issue to the MiniZinc issue tracker: https://github.com/MiniZinc/libminizinc/issues