O'Reilly logo

Developing Web Applications with Haskell and Yesod by Michael Snoyman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

File Structure

The scaffolded site is built as a fully cabalized Haskell package. In addition to source files, config files, templates, and static files are produced as well.

Cabal File

Whether directly using cabal, or indirectly using yesod devel, building your code will always go through the cabal file. If you open the file, you’ll see there are both library and executable blocks. Only one of these is built at a time, depending on the value of the library-only flag. If library-only is turned on, then the library is built, which is how yesod devel calls your app. Otherwise, the executable is built.

The library-only flag should only be used by yesod devel; you should never be explicitly passing it into cabal. There is an additional flag, dev, that allows cabal to build an executable, but turns on some of the same features as the library-only flag, i.e., no optimizations and reload versions of the Shakespearean template functions.

In general, you will build as follows:

  • When developing, use yesod devel exclusively.

  • When building a production build, perform cabal clean && cabal configure && cabal build. This will produce an optimized executable in your dist folder.

    Note

    In the past we had a -fproduction flag. If you produced a scaffolded site in the past, you may have to use this flag to get a production build.

You’ll also notice that we specify all language extensions in the cabal file. The extensions are specified twice: once for the executable, and once for the library. If you add any extensions ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required