Skip to content

Instantly share code, notes, and snippets.

@chreekat
Last active September 9, 2015 01:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chreekat/a4c624a94b8d5dc70db5 to your computer and use it in GitHub Desktop.
Save chreekat/a4c624a94b8d5dc70db5 to your computer and use it in GitHub Desktop.

Context: I want to repl our app from within 'stack ghci'. I've "backported" DevelMain.hs to work with our hand-updated 1.0⟶1.2 scaffolding: see chreekat/ghci-runner and dev/Runner.hs. It ain't workin so hot just yet. There are three main problems, only one of which I'm going to focus on here[1].

Problem: Adding a new Message :reloads as expected, but does not behave as expected.

  1. I start up my runner mentioned above.
  2. I add a reference to a new Message (_{MsgFoo}) in a template.
  3. I touch the relevant .hs file and :reload. Type error, as expected: No such value "MsgFoo"!
  4. I add a new entry in messages/en.msg, touch Foundation.hs and :reload again. Compile success.
  5. I rerun the site (running main from dev/Runner.hs in the ghci prompt) and load the page that uses the new Message. Surprisingly, it displays the next Message — that is, the value that is on the next line in messages/en.msg — as if the app was indexing an old version of the array of Messages!
  6. I quit and restart stack ghci, and restart the runner, and everything is ok.

Question: What might be to blame for this behavior? Is there potentially any way around it, or has ghci-runner (and foreign-store beneath) gotten too greedy, and dug too deep? Clearly, data from the last run is living on somehow. But where? I'm not really sure where to look.

Thanks!

[1]: For reference, the other two are frequent ghci segfaults (which I can only assume has a similar root cause as this issue with Messages), and the lack of yesod-bin's dependency-tracking for templates et al, which I am experimenting at circumventing with vim magic.

N.B. I am casually using Message as a proto-type (no pun intended) here. If I were to be precise, I would call them value constructors of the datatype generated by mkMessage. But you knew that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment