thoughtbot/carnival — pull request #107 by pbrisbin (2014-10-10 14:38:29+00:00)
Title: WIP: Refactor Model/Handler distinction

This PR has two motivations:

First, see if it is as easy/safe to wildly refactor a Haskell codebase as we
keep saying it should be. It was easy, we'll have to see if it was safe.

Second, bring the codebase in line with a few best practices, some accepted
(line-length, formatting, import sorting, etc) and some that I'm proposing now
via this PR.

The new ones are:

- Separate `Model.*` modules for each non-trivial data type
- JSON instances (even though they're orphans, I think it's the best place
for them)
- "virtual accessors" i.e. `userName`
- Query functions, which must return `DB a` and cannot mention `Handler`
- Anything dealing with Request/Response should appear in `Handler.*` or a
`Helper.*`
- Helpers should be about cross-cutting concerns, and not be model or
handler-specific
- One `Handler` module per resource, not per URL