This project is read-only.

Syntax sugar for monadic structures

Topics: Language Specification
Oct 7, 2012 at 7:42 PM

Are there any plans for including something like Haskell's do notation or the computational expressions in F# into TypeScript? If this were available, then the following features could be implemented on the library level rather than on the compiler level:

  • C#'s async keyword: This would make it possible to avoid callback spaghetti code. Especially useful in node.js.
  • Coroutines: HTML5 game developers would surely benefit from this (as evidenced by the usage of coroutines in Lua powered games).
  • List comprehensions

This would open up immense possibilities, wouldn't it?

Oct 9, 2012 at 12:03 AM

We've so far focused on large scale app development capabilities - classes, modules and types.  Going forward, we expect our focus to be first and foremost on (a) improving the type system to be able to capture more JS library typings and (b) including further support for ECMASCript 6 capabilities.

Some of the specific features you describe are things that are in some form being enabled with ES6 - array comprehensions and iterators/generators.  Compiling these to ES3/ES5 though would be less simple and clean code generation than we've currently been aiming for, so we're holding back on them for now.

Adding computation expressions or macros is probably also further away on the roadmap, but something we'll be thinking about.