You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to define functors that receive ADTs as parameters and couldnt find any documentation about it.
From the tests in this repo i figured that when unpacking an ADT value in the functor implementation, the first value of the returned array is the constructors ordinal number (given that there is at least one parameterized constructor). I assumed that this ordinal value is according to constructors' declaration order, however found out that it is according to alphabetical order.
Is this by design? to be honest i find it somewhat not intuitive...
Example Souffle program:
.functor get_ctor_ordinal(v: T): unsigned stateful
.type T =
B {}
| A {}
| C { x: unsigned }
.decl R(v: T, o: unsigned)
R($B(), @get_ctor_ordinal($B())).
R($A(), @get_ctor_ordinal($A())).
R($C(1), @get_ctor_ordinal($C(1))).
.output R
I was trying to define functors that receive ADTs as parameters and couldnt find any documentation about it.
From the tests in this repo i figured that when unpacking an ADT value in the functor implementation, the first value of the returned array is the constructors ordinal number (given that there is at least one parameterized constructor). I assumed that this ordinal value is according to constructors' declaration order, however found out that it is according to alphabetical order.
Is this by design? to be honest i find it somewhat not intuitive...
Example Souffle program:
Functor Implementation:
Output:
The text was updated successfully, but these errors were encountered: