Skip to content

Conversation

@jvanbruegge
Copy link
Contributor

No description provided.

@phadej
Copy link
Member

phadej commented Mar 4, 2017

Looks great, just had discussion about having type-definitions last week! Is it easy to add a test testing at least some of those definitions as part of the test-suite, i.e. having type-script test-suite as well?

@phadej
Copy link
Member

phadej commented Mar 4, 2017

I updated david, if you rebase, travis should be green.

@jvanbruegge
Copy link
Contributor Author

Yes, you can write a normal test file in typescript and check if it compiles

@jvanbruegge
Copy link
Contributor Author

The problem I have here is with the vararg fubctiobs, as typescriot only allows the vararg to be the last parameter. So some of the functions I cant type at all

@phadej
Copy link
Member

phadej commented Mar 6, 2017

Will they be typeable if we provide a versions with varargs as the the last parameters? .combine has quite advanced type, after all?

@jvanbruegge
Copy link
Contributor Author

Yes, the vararg has to be the last one and there shouldnt be an optional argument too

@jvanbruegge
Copy link
Contributor Author

Thats the problem with forall too, the optional parameter is not the last one

@phadej
Copy link
Member

phadej commented Mar 6, 2017

can typescript express dependencies, like tsCombine(f : (a, b ...) => r, x : generator<a>, y : generator<b> ...)?

We could add tsForall, and tsCombine if they are even somehow typeable in TypeScript

@jvanbruegge
Copy link
Contributor Author

jvanbruegge commented Mar 6, 2017

Sadly not yet. I can only type it:
tsCombine(f : (a, ...any[]) => r, x1 : generator<a>, ...xn : generator<any>[])
So you get types for the first generator and an any type for the rest.

But typescript allows polymorphic type declarations, so you can just copy & paste this until 10 params (most people use less) and have the any vararg declaration for the rare occasions you use more

@jvanbruegge
Copy link
Contributor Author

Ok, I think I got it mostly
The stuff missing is:

  • the either stuff, because I dont know how it should be used or how it is useful
  • the fn/fun arbitrary, as I dont know how to use them (where does the b type come from?)

@jvanbruegge
Copy link
Contributor Author

I think we dont need extra typescript functions. The way this is here now should be sufficient

@phadej
Copy link
Member

phadej commented Mar 6, 2017

b in fn can be anything, we don't need to generate the values of that type, we just test them for an equality (iirc with === / egal)

@jvanbruegge
Copy link
Contributor Author

yeah, but the function that is generated, what does it accept?

@phadej
Copy link
Member

phadej commented Mar 6, 2017

either is a special case of sum (which you type very loosely).

The noteable thing here, is that either and sum are tagged, i.e. in either int int scenario, you'll know whether you have left or right int. IIRC there was issue about producing untagged unions too, but there the problem is shrinking (you need the tag to know how to shrink).

@phadej
Copy link
Member

phadej commented Mar 6, 2017

function accepts values of b, i.e. anything you want. E.g. write type for

function const(x) {
  return function (y) { return x; }
}

@jvanbruegge
Copy link
Contributor Author

Ahh, ok. And what is the difference between fn and fun?

@jvanbruegge
Copy link
Contributor Author

I think that most of the use cases are now covered, the either stuff can be added later on if there is demand for it

@phadej
Copy link
Member

phadej commented Mar 12, 2017

Merged as a part of #202

@phadej phadej closed this Mar 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants