-
-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should enums with identical structure but defined in separate locations be considered the same type? #568
Comments
Related: #443 |
Ah, interesting! The programming languages that I know of all have the same solution that if I understand correctly CWL currently has, where a type is defined in one place, and then imported wherever else it's used. That means you get to keep your namespaces, and there is no potential for problems when people start combining CLTs from different sources. However, as the other thread shows, people expect those two types to be the same. I think a good solution could be to introduce the concept of compatible types. If type A is compatible with type B, then any value of type A can be used anywhere a value of type B is expected, it being converted implicitly. And vice versa. Like how you can pass an int to a function expecting a float in many languages. That means that the two enum definitions would actually define different types (with the same name but in different namespaces), so that we avoid clashes, but being identical, they're compatible, so you can still pass a value of one type into an input of the other type. Then the question is how to decide whether two types are compatible. Being identical would definitely be good, and the natural way to define it is using Liskov subtypes (this is literally Liskov substitution), but can we derive that from two custom type definitions? |
@LourensVeen could you explain, please, about what clashes are you talking? In the type field of any enum I do specifay what exact strings it should accept! And I do not need/mean/want any changes to that strings occur. The enum "symbols" are not ids! There is no place in the CWL spec, where it is said they should be unique or should be processed as ids! |
I'm thinking a bit more generally here. What if you workflow had
and the command line tool that you're calling has
With different definitions, we can't consider them the same type for sure. So should that give an error message, because we have two types with the same name but defined differently? Does it matter whether the two definitions are identical or not? Maybe we should be allowed to have as many copies of a type definition as we want, but only as long as they're identical? Or should this be okay regardless of whether they differ or not, because one is really One option, which is maybe how you see things (?), is to consider type checking simply schema validation. So that means that in your example, we have an input object, which is a string with a particular value, which is first checked against the workflow.cwl#foo schema, passes that check, is passed on to task.cwl, where it's checked against the task.cwl#foo schema, and passes again. Its type is still string, and as long as it passes all the schemas it meets along its way through the workflow, we don't care whether those different schemas are actually compatible in theory, we'll just check values against them at runtime, and if they're incompatible, then no value will pass, but the workflow will still be valid. |
From common-workflow-language/cwltool#308 (comment)
The text was updated successfully, but these errors were encountered: