-
Notifications
You must be signed in to change notification settings - Fork 102
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
(docs) Add tentative type annotations to Task methods #94
Conversation
Also, from here, I could not figure out the difference between fat arrow (=>) and arrow (->). |
The function notation is As for the type of or/and, the error type is the same for simplicity. While in JS you can use Ideally this'd encourage people to keep their types a bit more consistent, too, as something like So, for that reason, we kinda arbitrarily restrict the types to be a bit more consistent:
These types should also include the resources. Each task has an unique resource associated with it, which is consumed when you run that task (automatically by the TaskExecution). There's no real type notation for this concept yet (linear types), so they can be simplified by just putting the resource type on the LHS and RHS. The constructor's type would be:
And then each method transforming a task just keeps the same resource:
Methods combining tasks yield a combination of both resources:
|
@robotlolita thanks! The changes based on your feedback are WIP. |
btw, re documenting Task based on Result (gitter discussion) - I have started with type annotations and looking at tests. Next, I'll be looking at |
Shouldn't this:
be:
? |
|
Thanks @safareli ! |
Ah, yes, sorry, my |
@robotlolita np I was going to bring this up in my next push, but it might take a bit longer than expected so: I noticed you've switched the rejected and resolved values in the type annotations. i.e. data.Task was but in your e.g. above it's I've started the re-write of the type annotations using this new way (resolved value first) - as I figured, since Tasks are now created differently, perhaps it makes more sense to have the resolved values first. Also, I personally like having resolution types first - but wanted to clear this up. In any case, it won't be a big deal to change again in case the above was just a typo. Note, one thing that came to mind as a possible "inconsistency":
|
@robotlolita I'm not sure the changes I made are exactly what you had in mind. Some things to look out for:
|
That's pretty much it. In the places where there're two independent tasks, and the result is one of them, each task gets its own resource, and the resulting type has the resource of the task returned. The resolved value part was an error on my part, sorry :< It doesn't really matter as long as the types line up, but as you mentioned it becomes inconsistent with things like |
@robotlolita np I'll make the changes re the resolved value position. |
constructor
type annotations are in need of guidance.and
andor
type annotations.and
, got from here. Was going to go with:(Task a b).(Task c d) => (Task a _) or (Task c _) or (Task _ (b, d))
) - why is the rejected part of both Tasks the same typea
?