Skip to content
This repository was archived by the owner on Jul 12, 2025. It is now read-only.

Conversation

@robotlolita
Copy link
Member

@robotlolita robotlolita commented Sep 25, 2017

This PR tracks the work on TypeScript typings (#65). These will work with Folktale 2.x. There's a separate branch to rewrite Folktale in TypeScript (#115). That'll be a breaking change (using ES6 modules), and thus a new major version. TypeScript in Folktale will likely be released early 2018.

Current status

v3.0.1-ts is available on the tstypes channel: npm install folktale@tstypes

  • [ ] adt (note that adt fundamentally can't have useful types)
  • [X] concurrency
  • [X] conversions
  • [/] core (missing curry & partialize)
  • [ ] fantasy-land
  • [/] maybe
  • [/] result
  • [/] validation

[/] indicates partial support, [X] indicates full support.

@ghost ghost assigned robotlolita Sep 25, 2017
@robotlolita robotlolita changed the title TypeScript typings WIP: TypeScript typings Sep 25, 2017
@snewell92 snewell92 mentioned this pull request Oct 19, 2017
4 tasks
__tag: 'Just';
value: A;
map<B>(f: (_: A) => B): Maybe<B>;
apply<B>(this: Maybe<(_: A) => B>, f: Maybe<A>): Maybe<B>;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this type incorrect i think. We use the Generic variable A here for other Maybe, it cause typescript infer the this context must be Maybe<(_: (_: A) => B) => B>. To make it clear try: ma.map(tuple).apply(mb).

Copy link

@syaiful6 syaiful6 Nov 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apply<B, C>(this: Maybe<(_: B) => C>, other: Maybe<B>): Maybe<C> might do the trick, don't use the A variable in Generic.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the A type variable should be local to that method.

@robotlolita
Copy link
Member Author

Well, overloaded functions on arrays will have to be replaced by static arity functions. Too many silent type errors from TypeScript otherwise :/

@robotlolita
Copy link
Member Author

2.1.0-alpha4: fixed .apply types and added missing definitions for Maybe/Result/Validation. Overloaded definitions were removed, though.

@robotlolita robotlolita force-pushed the feat/typescript-typings branch from 5f59067 to 7191280 Compare December 17, 2017 21:04
@robotlolita
Copy link
Member Author

3.0.0-alpha5 adds fixed-arity versions of the previously-overloaded functions. More details coming up in a blog post later :>

toString(): string;
equals(that: Maybe<A>): boolean;
unsafeGet(): A;
fold<B>(onJust: (_: A) => B, onNothing: () => B): B;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is inverted, onNothing is first and onJust in second

toString(): string;
equals(that: Maybe<A>): boolean;
unsafeGet(): A;
fold<B>(onJust: (_: A) => B, onNothing: () => B): B;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same case I've mentioned in the comment above

@robotlolita
Copy link
Member Author

3.0.1-ts fixes .fold and .fromNullable in Maybe

@robotlolita
Copy link
Member Author

Semigroup types don't work with TS 2.8.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants