Live data from Hacker News

Free-types: Higher kinded types in TypeScript

github.com

1–10 of 51 posts

Re: Free-types: Higher kinded types in TypeScript

#5
Looking forward to a proper monad lib in Typescript!

However, I can only assume that molding/abusing types like this might have a big - if not huge - impact on compilation times...

I've created a template-like generic type that allows you compose multiple kinds and replace any property of an object with a function returning the same type as the property, and vscode has such a hard time inferring types that intellisense has become unusable in this context.

Curious to see how this will turn out.

Re: Free-types: Higher kinded types in TypeScript

#6
I wonder if there is any relationship between HKT and C#/Rust generics, from my perspective I always see HKT as "A type that accepts types that generates another type" and generic as "A functor that accepts types that generates another type". That makes me wonder if types and functors are exchangable.

Re: Free-types: Higher kinded types in TypeScript

#7
post #5

Looking forward to a proper monad lib in Typescript! However, I can only assume that molding/abusing types like this might have a big - if not huge - impact on compilation times... I've created a template-like generic type that allows you compose multiple kinds and replace any property of an object with a function returning the same type as the property, and vscode has such a hard time inferring types that intellisen…

I'm using fp-ts https://gcanti.github.io/fp-ts/

Re: Free-types: Higher kinded types in TypeScript

#8
post #2

I’d love to be able to do dependent types in TS. Does this make that possible?

Might be wrong here, but I'm of the understanding that a dependent type system is undecidable, and so to have static dependent types you need to have a more restricted language, like the inability to write arbitrarily recursive functions.

In short I don't think so but I'd also love a good explanation as to why I'm wrong.

Re: Free-types: Higher kinded types in TypeScript

#9
post #8
post #2

I’d love to be able to do dependent types in TS. Does this make that possible?

Might be wrong here, but I'm of the understanding that a dependent type system is undecidable, and so to have static dependent types you need to have a more restricted language, like the inability to write arbitrarily recursive functions. In short I don't think so but I'd also love a good explanation as to why I'm wrong.

Typescript's type system is already undecidable (except that they limit recursion depth). I don't know much about dependent types but I'd guess it similarly doesn't matter much in practice that in the general case they're undecidable?

Re: Free-types: Higher kinded types in TypeScript

#10
post #2

I’d love to be able to do dependent types in TS. Does this make that possible?

No. Typescript cannot access runtime values (I assume you mean types that depend on runtime values). In TypeScript types can depend on other types and it does support literal types which covers a lot of use cases. What do you need dependent types for?

[Edit: why the down vote?]

Post reply on HN