- daniel sti
- 10/31/11
Dear specialists,
the following code snip leads to a typesystem error in the closure inside the sortBy():
type meet (datetime & void) is not a subtype of java.lang.Comparable
sequence<Order> best = new sequence<Order>(empty);
best = best.sortBy({~it => it.orderDate; }, asc);
orderDate is of type "datetime" implemented in the dates language. But datetime is a simple concept derived from Type - so indeed it does not implement the java.comparable interface.
How can i get rid of the typesystem error message. I already tried to write a new inference rule in my language for SortOperation ("sortBy") with overrides set to "true". But that does not override the original rule.
Any other possibilities ?
Best,
Dan
the following code snip leads to a typesystem error in the closure inside the sortBy():
type meet (datetime & void) is not a subtype of java.lang.Comparable
sequence<Order> best = new sequence<Order>(empty);
best = best.sortBy({~it => it.orderDate; }, asc);
orderDate is of type "datetime" implemented in the dates language. But datetime is a simple concept derived from Type - so indeed it does not implement the java.comparable interface.
How can i get rid of the typesystem error message. I already tried to write a new inference rule in my language for SortOperation ("sortBy") with overrides set to "true". But that does not override the original rule.
Any other possibilities ?
Best,
Dan
- Magvay
- 10/31/11
You can write a subtyping rule for your orderDate type to describe that Order is subtype of Comparable.
subtyping rule supertypesOf_Order {
weak = false
applicable for concept = orderDate as orderDate
rule {
return <Comparable>;
}
}
Here, <Comparable> is a quotation.
subtyping rule supertypesOf_Order {
weak = false
applicable for concept = orderDate as orderDate
rule {
return <Comparable>;
}
}
Here, <Comparable> is a quotation.
- Magvay
- 10/31/11
Sorry, probably, datetime should be a subtype of Comparable. It could be a bug in dates language.
- daniel sti
- 10/31/11
Hi,
yes indeed. That works. I have created a subtype rule for the DateTimeWithTZ Concept, telling that Comparable is a subtype of datetime ...
Cool! Thanks
yes indeed. That works. I have created a subtype rule for the DateTimeWithTZ Concept, telling that Comparable is a subtype of datetime ...
Cool! Thanks