[WIP] Add typescript type definition #196

Closed
wants to merge 4 commits into
from

Conversation

Projects
None yet
2 participants
@jvanbruegge
Contributor

jvanbruegge commented Mar 4, 2017

No description provided.

@phadej

This comment has been minimized.

Show comment
Hide comment
@phadej

phadej Mar 4, 2017

Member

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?

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

This comment has been minimized.

Show comment
Hide comment
@phadej

phadej Mar 4, 2017

Member

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

Member

phadej commented Mar 4, 2017

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

@jvanbruegge

This comment has been minimized.

Show comment
Hide comment
@jvanbruegge

jvanbruegge Mar 4, 2017

Contributor

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

Contributor

jvanbruegge commented Mar 4, 2017

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

@jvanbruegge

This comment has been minimized.

Show comment
Hide comment
@jvanbruegge

jvanbruegge Mar 5, 2017

Contributor

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

Contributor

jvanbruegge commented Mar 5, 2017

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

This comment has been minimized.

Show comment
Hide comment
@phadej

phadej Mar 6, 2017

Member

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

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

This comment has been minimized.

Show comment
Hide comment
@jvanbruegge

jvanbruegge Mar 6, 2017

Contributor

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

Contributor

jvanbruegge commented Mar 6, 2017

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

@jvanbruegge

This comment has been minimized.

Show comment
Hide comment
@jvanbruegge

jvanbruegge Mar 6, 2017

Contributor

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

Contributor

jvanbruegge commented Mar 6, 2017

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

@phadej

This comment has been minimized.

Show comment
Hide comment
@phadej

phadej Mar 6, 2017

Member

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

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

This comment has been minimized.

Show comment
Hide comment
@jvanbruegge

jvanbruegge Mar 6, 2017

Contributor

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@jvanbruegge

jvanbruegge Mar 6, 2017

Contributor

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?)
Contributor

jvanbruegge commented Mar 6, 2017

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

This comment has been minimized.

Show comment
Hide comment
@jvanbruegge

jvanbruegge Mar 6, 2017

Contributor

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

Contributor

jvanbruegge commented Mar 6, 2017

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

@phadej

This comment has been minimized.

Show comment
Hide comment
@phadej

phadej Mar 6, 2017

Member

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)

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

This comment has been minimized.

Show comment
Hide comment
@jvanbruegge

jvanbruegge Mar 6, 2017

Contributor

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

Contributor

jvanbruegge commented Mar 6, 2017

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

@phadej

This comment has been minimized.

Show comment
Hide comment
@phadej

phadej Mar 6, 2017

Member

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).

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

This comment has been minimized.

Show comment
Hide comment
@phadej

phadej Mar 6, 2017

Member

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

function const(x) {
  return function (y) { return x; }
}
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

This comment has been minimized.

Show comment
Hide comment
@jvanbruegge

jvanbruegge Mar 6, 2017

Contributor

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

Contributor

jvanbruegge commented Mar 6, 2017

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

@jvanbruegge

This comment has been minimized.

Show comment
Hide comment
@jvanbruegge

jvanbruegge Mar 12, 2017

Contributor

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

Contributor

jvanbruegge commented Mar 12, 2017

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

This comment has been minimized.

Show comment
Hide comment
@phadej

phadej Mar 12, 2017

Member

Merged as a part of #202

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