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


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.


Other relatively non-trivial thing is compiling pattern matches to decision trees, see for example this paper


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