I was playing around in elm-lang.org's interactive IDE, trying to make a draggable circle. In particular, I was going for something like this:
dragCircle :: Number -> (Number, Number) -> DragCircle
type DragCircle = (Form, (Number, Number) -> Bool -> DragCircle)
-- note the infinite type
Then, use foldp
and lift2 (,) position isDown
to feed the DragCircle
automaton.
I ended up crashing the server. I compiled elm-server locally and reproduced the hang and leak. Here's a minimal code sample triggering the leak:
move pos down = rest
rest pos down = if down then move else rest
I suppose such hangs could be avoided using System.Timeout in elm-server, e.g.:
mhtml <- liftIO . timeout 10000000 . evaluate $ Elm.toHtml libLoc (pageTitle filePath) content
I don't know if happstack-server does anything to time out response generation or not.
Another thing you could do is set the maximum amount of memory the runtime system may allocate, by adding this to the .cabal file:
ghc-options: -rtsopts -with-rtsopts=-M512m
This way, if elm-server blows up again, it doesn't bring the whole system to a crawl.