I'm trying to embed a Haskell REPL within one of my Haskell applications. The idea would be that only a subset of the Haskell libraries would be loaded by default, plus my own set of functions, and the user would use those in order to interact with the environment.
To solve this problem, I know one way would be to create a (mini-)Haskell parser + evaluator and map my mini-Haskell parser's functions to actual Haskell functions, but I'm sure there is a better way to do this.
Is there a nice and clean way to build a REPL for Haskell using Haskell?
Haskell has a nice REPL known as GHCi, where GHC refers to the main Haskell compiler and the 'i' is for interactive.
Repl is opened in the context of the current Atom editor, so there is no need to load the file (even though :l filename will work). Type any ghci command in the bar at the bottom of the window and press shift+enter (on Win and Linux) or cmd+enter (on macOS) to execute it.
A read–evaluate–print loop (REPL) environment takes single user inputs, executes them, and returns the result to the user. GHCi is GHC's interactive environment. The stack ghci or stack repl commands, which are equivalent, allow you to load components and files of your project into GHCi.
Introduction. GHCi is GHC's interactive environment, in which Haskell expressions can be interactively evaluated and programs can be interpreted.
A few things that already exist:
All of the above are assuming that you don't want to deal with writing a Haskell interpreter yourself, which is probably the case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With