Home > loopgotowhile-site

loopgotowhile-site

Loopgotowhile-site is a project mainly written in HASKELL and JAVASCRIPT, based on the BSD-3-Clause license.

Site and evaluation service for loopgotowhile

This is the source code for the accompanying site & evaluation service for the project loopgotowhile. A live instance can be found here. The evaluation service uses Happstack. The editor functionality is provided by CodeMirror. The design of the site is inspired by Homebrew.

How to install this project?

  1. Install the Haskell platform. This will give you GHC and the cabal-install build tool.

  2. Install loopgotowhile. Instructions are to be found in the README.

  3. Clone this project and build it with cabal:

     git clone git://github.com/eugenkiss/loopgotowhile-site.git
     cd loopgotowhile-site
     cabal build

Now you'll have the executable loopgotowhile-site/dist/build/LGWServer. You can run it and a server will be started that listens to port 8000 and can process special post requests to execute or transform code. See LGWServer.hs for more details. However, the server does not serve static files by default. To enable serving static files you must give the executable the test parameter like so LGWServer test. Note, that you must run the executable from the main project's folder, i.e. loopgotowhil, so that the server can find the files.

For further convenience install fabric and adapt fabfile.py. Then you can use some shortcut commands to e.g. upload this project to your server and serve static files with ngnix. See fabfile.py for more details.

How are the resources limited for the evaluation service?

By using the timeout function computations that take longer than five seconds are discarded. Mainly, this is needed to prevent infinite loops from keeping the server busy forever.

The heap size for the created executable is limited as well so that the server's memory will not be filled up completely.

To limit the CPU resources for this evaluation service you can use the program cpulimit on linux. For further information look here.

What else is there to mention?

If you get an error like mkTextEncoding: invalid argument from the statically-linked binary, try setting the GCONV_PATH environment variable to point to the location of the codecs from the libc package, e.g. put export GCONV_PATH=/usr/lib/gconv at the top of your .bashrc on the remote. See also http://blog.malde.org/index.php/2010/05/22/snagged/.

For some reason it is very flaky to get both processes LGWServer and cpulimit running on the remote with fabric. It only works every fourth time or so.

If there would be an easy way to spit out Javascript from Haskell code I'd rather do that and have the interpreters run on the client side instead of running a program on the server for various reasons.

http://johnmacfarlane.net/pandoc/try was used to convert LaTeX math formulas to html.

Currently, I'm using a poor-man's semaphore approximation to limit the number of concurrent operations because I needed something like a non-blocking semaphore which I could not find as a library. Nonetheless, my solution seems to work just fine. However, when I compile the program with ghc 7.0.2 and try to use the executable on my server there is the error

epollCreate: unsupported operation (Function not implemented)

The solution is either to use an as-of-yet unreleased new version of ghc with bug #5005 fixed or to update the distribution and thus the kernel on my server. But I don't want to do the latter so I have to wait until I'll be able to allow more than one concurrent computation on my server.

What are some suggestions for future improvements?

Evaluation Service

  • Maybe change to Yesod? The memory usage of the evaluation service is a bit too high imho. With Yesod, it seems, I could even go without nginx as Warp seems to be good enough to serve static content.

Editor

  • Implement loop, loop-strict, while, while-strict, goto, goto-strict CodeMirror modes so that there is syntax highlighting and smart indentation.
    • Change enterMode from "keep" to "indent" and tabMode from "shift" to "indent"
    • Switch modes when selecting another input language or checking strict.

Usability

  • The selects and the checkbox should be styled so that they fit the theme instead of relying on the standard browser styling.