Browser based repl

Hey friends,

So I’m endeavoring to write a book on functional programming aimed at the greatest of beginners - those who have never done any software development. I’m choosing to use purescript as the language for this book because it’s essentially the same thing as haskell but the UX of the language generally seems better (easier setup, etc etc).

Anyways, I was going to include a setup section but realized try.purescript.org was a nice way to get people fast-tracked to hacking right away. However, I’m weary of introducing effectful code right at the get-go, so I’m trying to avoid the typical “hello world” output to a console right at the beginning.

However, the repl solves the issue nicely! Even though ps setup is relatively easy, the best case scenario would be a browser based repl we could point users to.

Does such a thing exist already? I’ve seen repl.it but it requires sign up, I’m trying to keep the process as painless as possible.

Another question: how difficult would it be to add a repl to try.purescript.org in some manner. I assume this is possible (most software endeavors are with enough grit right?), but I wonder how practical it would be to setup?

Just curious! Thanks!

6 Likes

I think some of the work is already done, as you can already make the repl use the browser instead of node:

$ spago repl --purs-args "--port 8000"

But note that it’s only one way; the repl just pushes the new code to the browser, which then evaluates the javascript and returns the result. I think it’d need significant modification to support receiving new code from the WebSocket? Not sure

3 Likes

You might also be able to embed editable executable code snippets in your book, which could be even more convenient than a repl for readers. Here’s an issue to track some options and next steps for enabling that with PS.

2 Likes

You might also be able to embed editable executable code snippets in your book

Wow thats awesome. That would be the deluxe option haha.

After playing with the repl a bit, I decided try.purescript would be better since it gives you closer to a real-life coding experience. I would definitely be interested in trying out an embedded code box in the book though. Ill keep an eye on that issue. Thanks for the responses!

3 Likes

You might also like to consider something like katacoda.com.

2 Likes