How hard would it be: Purescript to Dart backend (for making a Flutter app on purescript)

  1. How hard would it be to make a backend for Dart language?
  2. How one would implement the Aff? (bc it’s not possible to terminate Futures)

Would be awesome to write web and mobile (that works faster then react-native written apps) on the same language

3 Likes

One aspect of Dart that makes it more difficult is that

Dart does not support tail-call optimization. There are no current plans to add it.

3 Likes

Other relatively non-trivial thing is compiling pattern matches to decision trees, see for example this paper https://www.cs.tufts.edu/~nr/cs257/archive/luc-maranget/jun08.pdf

3 Likes

If you use the purescript-backend-optimizer project to codegen Dart, it already does the decision tree optimization, which is more clearly explained here (purescript-backend-optimizer/optimized-pattern-matching.md at main · aristanetworks/purescript-backend-optimizer · GitHub), and implemented in that project here (purescript-backend-optimizer/Convert.purs at main · aristanetworks/purescript-backend-optimizer · GitHub)

This is the approach we’re currently taking in the purescm backend, which will compile PureScript to Chez Scheme.

4 Likes