Brad Clawsie
Brad Clawsie

Reputation: 1080

how to iterate in snap framework without cabal install

I love the snap framework but I hate running 'cabal install' with each iteration (minor code change) I want to try out.

Is there an alternative for rapid iteration?

Upvotes: 4

Views: 535

Answers (2)

Carl
Carl

Reputation: 27013

Start with

cabal install --reinstall -fhint snap

Then, for your project:

cabal clean
cabal configure -fdevelopment
cabal build
./dist/build/projname/projname

You shouldn't ever use cabal install for binaries that you don't want to be able to execute from arbitrary locations, anyway. You should be using cabal build for things you only want to run locally.

You will need to run cabal build and start the program again when you change Main.hs or your project's .cabal file.

If you have any further questions, comment - I'm the guy who implemented this functionality for Snap.

Upvotes: 9

Dan Burton
Dan Burton

Reputation: 53675

Yesod provides yesod devel which automatically reloads code changes. I am not aware of a comparable capability in snap, but it is highly likely that they can reuse much of the Yesod code that does this.

Given the existence of Snap.Loader.Devel I'm guessing they might already provide something like what you are asking for, but I can't find the documentation on how to use it. The FAQ question How do I run my app in development mode still requires a cabal install; it's unclear from the docs whether you only need to do this once, or every time the code changes.

Upvotes: 2

Related Questions