I’m experimenting with a monadic visual functional programming language in Haskell. Instead of writing my own type checker, I’d like to use PureScript’s type checker as a library. It has all features I need, especially row polymorphism. My idea is to do something like this:
Preload some PureScript modules.
Let an end user create or modify a program, represented internally using my own AST.
Convert this internal AST to PureScript’s AST as my “main module”.
Run PureScript’s type checker to get errors out, show them to the end user.
Loop over (2) to (4).
Do you think this is feasible? I could use some pointers in the code which functions to use. I.e.
TypeChecker.typeCheckModule clearly type checks a module. But how to run monad m to get all errors and warnings?
How to keep the preloaded modules in memory and only recheck my generated AST? Could/Should I use the IDE functionality to preload and reload modules? The IDE interface suggests it only works with file names, not ASTs.
How to parse simple expressions like “sin pi * 4” into PureScript’s AST?
An alternative would be to generate PureScript source files and use the IDE as a library, or run purs in IDE mode, listening to JSON output. More ideas are welcome!
Maybe my first post was a bit long and unclear, so let me try to restate my questions more directly:
I’d like to parse a PureScript expression (so not an entire module or a declaration, only the part after the =), and get a PureScript AST out of it or an error: parseExpr :: String -> Either AST Error. What should I use?
I’d like to feed a PureScript module to the PureScript type checker, and get succes or a list of failures out: checkModule : AST -> Either (List Error) Succes. What should I use?
Hope somebody can point me in the right direction!