Hi all,
Does anyone have handy an example file that:
- Uses the Haskell API from purescript-compiler
- Initializes the compiler context that is basically empty apart from prims
- Is able to compile an expression to corefn
- Possibly also returning the type of the expression
I’m interested in dabbling with using PureScript in this way:
- In Haskell, make a QuasiQuote for PS:
[ps|$x * y|]
wherex
may be from Haskell scope, buty
will be a scope agreed to be setup in the JS runtime with the right type. - Types that are supposed to be made available are copied from Haskell into the PureScript context, e.g. in Haskell:
data Status = LoggedIn | Trial
[ps|
\state ->
case state.status of
LoggedIn -> ...
Trial -> ...
|]
As I’m interested in seeing how far I can go with doing as much as possible server-side and then only when client-side logic is really needed, then run a snippet of PureScript. I noticed that I was always able to get quite far in such a design (where most things on the screen would be server-side generated, and only occasionally where you want to avoid server roundtrip you would use “client-side expression”), but found that when you need a client-side “if” or “case” or that a simple EDSL in Haskell isn’t good enough; you want a proper language with real syntax, its own Haskell-type system, maintained.
While PureScript with all its packages and whatnot is great, I’m interested in exploring it as a judiciously used “shader” language for Haskell web dev. Inverting control so that Haskell is compiling small snippets of it and defining what types are available, rather than there being two separate toolchains I have to run separately (ghc/cabal and purs/psc).
IOW, I want a “pure” scripting language and PS could be that.
I can spend some hours browsing through the purescript codebase, but someone might already have a starting point for me. Thanks!