Happstack 0.2 Released

It has been one whole month in the making and Happstack 0.2 is finally here — a  lot of love has gone into this release!

Get up and running easily with cabal install

A lot of thought has gone into making Happstack more approachable for the newbie. Assuming you have cabal-install up and running and either ghc 6.8.3 or 6.10.1, you can just:

cabal update && cabal install happstack
happstack new project myproject
cd myproject
# linux
sh bin/run.sh
# windows
bin\run.bat

Open up your browser to http://127.0.0.1:8000 and enjoy a neat guestbook example application you can play with! (Much thanks to Jeremy Shaw for help with this)

What else is new?

  • Generalization of the SimpleHTTP library to ease the pain of wrapping and unwrapping WebPartT’s and ServerPartT’s (Thanks to Daniel Rogers)
  • New experimental gzip filter in happstack-server (similar to apache mod_deflate)
  • Cookie fix from happstack-helpers was integrated
  • HSP & HStringTemplate integration (see the examples in the guestbook app)
  • New combined logging format for Happstack.Server.SimpleHTTP

See the CHANGELOG for details

Documentation

The documentation for toplevel functions has been expanded greatly, much of this work being done by none other than Creighton Hogg. A fresh new version of happstack-tutorial will also be released soon which has details on Multimaster Replication.

Detailed Happstack 0.2 Release Notes have been created which explain how you can port your existing HAppS 0.9 or Happstack 0.1 application. Beyond that there is alot of other very useful information inside. Take a look!

Andrea Vezzosi (Saizan) has created Haddocks for Happstack 0.2.

About these ads

23 Comments

Filed under Development, Events, News

23 responses to “Happstack 0.2 Released

  1. thomashartman1

    huzzah!

  2. Marko Tosic

    For some reason i need to do a

    cabal install –global happy

    by hand when updating or the build of haskell-src-exts-0.4.8 fails on Linux amd64 / ghc6.10.1.

    Other than that: Huzzah!

    • Marko, most likely this happens because you do not have the –user cabal bin folder in your path. It is located (if your on linux) at ~/.cabal/bin. Please see the release notes for more information!

      • I’m also running x86_64 Linux and GHC 6.10.1 and I experienced the same issue. I tried the path workaround but neither that nor “cabal install –global happy” fixed the issue. Cabal fails to build haskell-src-exts and I’m stopped in my tracks.

      • Got it now. I blew everything away and did clean reinstalls and the path workaround seemed to fix it.

  3. Wonderful work & wonderful demo app

  4. zorg

    $ cabal update && cabal install happstack
    Downloading package list from server
    ‘http://hackage.haskell.org/packages/archive’
    Resolving dependencies…
    Downloading binary-0.5…
    Downloading utf8-string-0.3.4…
    cabal: Error: some packages failed to install:
    HJScript-0.4.4 depends on utf8-string-0.3.4 which failed to install.
    binary-0.5 failed while downloading the package.
    happstack-0.2.1 depends on utf8-string-0.3.4 which failed to install.
    happstack-data-0.2.1 depends on binary-0.5 which failed to install.
    happstack-ixset-0.2.1 depends on binary-0.5 which failed to install.
    happstack-server-0.2.1 depends on binary-0.5 which failed to install.
    happstack-state-0.2.1 depends on binary-0.5 which failed to install.
    hsp-0.4.5 depends on utf8-string-0.3.4 which failed to install.
    hspread-0.3.1 depends on binary-0.5 which failed to install.
    hsx-0.4.8 depends on utf8-string-0.3.4 which failed to install.
    utf8-string-0.3.4 failed while downloading the package.

  5. zorg

    apparently downloading manually utf8-string-0.3.4 from Hackage and doing cabal install, works

    I had the same issue with binary-0.5

  6. Tyson

    Yay! Congrats on a job well done! : )

  7. Sebastian

    Built the sample app, then I thought I’d add another field to the guestbook (age::Integer), so I added it to the data type, and the FromData instance, and the form (btw, having to rely on string based lookup to pass data from a form is very 1990′s – take a look at WASH), and the view, but then when I run it I get:
    Main.exe: too few bytes. Failed reading at byte position 91

    What does that mean?

    • Hello Sebastian,

      There are a few libraries for doing non-string based lookup for passing data, such as the formlets library, which work fine with happstack. We may use one of them in a future version of guestbook, but we wanted to keep things simple and avoid extra dependencies for now.

      The error about too few bytes occurred because you modified the data type, but did not provide a migration path for the old data. So, when the guestbook app tried to load the stored data from disk, it failed. During development, you can just delete the old state by deleting the _local directory.

      If you were updating a live site with data you actually wanted migrated, then you would need add the correct instances to the Version and Migration classes. I should add some comments to the guestbook code regarding that.

  8. Sebastian

    Can you use Text.HTML to produce a web page? I mean I’m guessing you can, but is there a simple way? I prefer combinators to weird non-standard syntax extensions.

    • A Response is just the HTTP headers and a bytestring representing the body of your response — so you can use whatever library you want to produce the web page. The page does not even need to be HTML, it could be JSON, an image file, etc.

      To make things easier, there is a class, ToMethod, which has instances for turning some common types like Text.HTML, HSP, etc, into a Response. But, you can easily add more types if you want.

      The happstack platform tries to avoid forcing you to use one way when another way would work just as well. It also tries to avoid recreating things that already exist. Since there are many libraries for creating HTML in Haskell, happstack just lets you use whichever ones you want.

  9. I’m desperately trying to get this installed but I keep running into trouble.

    I’ve made gradual progress by following some of the advice in the above comments, but now I get these issues:

    $ cabal install happstack
    Resolving dependencies…
    Configuring hsp-0.4.5…
    Preprocessing library hsp-0.4.5…
    Building hsp-0.4.5…
    ghc: could not execute: trhsx
    cabal: Error: some packages failed to install:
    happstack-0.2.1 depends on hsp-0.4.5 which failed to install.
    hsp-0.4.5 failed during the building phase. The exception was:
    exit: ExitFailure 1

    I tried installing trhsx and I get this:

    $ cabal install trhsx -v
    …snip…
    Creating dist/build (and its parents)
    /usr/bin/ghc -package-name trhsx-0.2.2 –make -hide-all-packages -i -idist/build -i. -idist/build/autogen -Idist/build/autogen -Idist/build -optP-include -optPdist/build/autogen/cabal_macros.h -odir dist/build -hidir dist/build -stubdir dist/build -O Trhsx
    [1 of 1] Compiling Trhsx ( Trhsx.hs, dist/build/Trhsx.o )

    Trhsx.hs:1:0:
    Failed to load interface for `Prelude’:
    it is a member of package base-3.0.3.0, which is hidden
    cabal: Error: some packages failed to install:
    trhsx-0.2.2 failed during the building phase. The exception was:
    exit: ExitFailure 1

    I’m a bit of a haskell noob, so I’m lost at this point. How do I force it to ‘find’ the Prelude module? I can determine from ghci that I have it.

    Congrats on the release! I’m super delighted to see how far happs has come since I watched some ancient video on it a few days ago.

    • Nicholas, trhsx is part of hsx, I think what your looking for is:
      cabal install hsx

    • No love. It says the packages are already installed.

      $ cabal install hsx
      Resolving dependencies…
      No packages to be installed. All the requested packages are already installed.
      If you want to reinstall anyway then use the –reinstall flag.

      $ cabal install happstack
      Resolving dependencies…
      Configuring hsp-0.4.5…
      Preprocessing library hsp-0.4.5…
      Building hsp-0.4.5…
      ghc: could not execute: trhsx
      cabal: Error: some packages failed to install:
      happstack-0.2.1 depends on hsp-0.4.5 which failed to install.
      hsp-0.4.5 failed during the building phase. The exception was:
      exit: ExitFailure 1

      Could it be that I’ve hosed something? I’m running os x 10.5.6 and I’ve had quite a lot of problems trying to get happstack from the tutorial to build as well (still haven’t gotten a working copy built).

      $ cabal install
      Resolving dependencies…
      cabal: cannot configure happstack-ixset-0.2.1. It requires happstack-data
      >=0.2.1 && =0.2.1 && <0.3 there are these packages:
      happstack-data-0.2.1. However none of them are available.
      happstack-data-0.2.1 was excluded because happstack-data-0.1 was selected
      instead
      happstack-data-0.2.1 was excluded because happs-tutorial-0.7.1 requires
      happstack-data ==0.1

      I’ve gone to to hackage and installed every one of those manually but I still get that error. I think I’m pretty lost.

  10. Whoops, forgot to add that the last error was when trying to install happs-tutorial-0.7.1.

    • Nicholas,

      Firstly please make sure that ~/.cabal/bin is in your path. Secondly, please know that happstack-tutorial has not been updated for the new release yet, but should be within the week.

    • Hey Nicholas,

      I was having the exact same error message that you were (I’m also running ghc 6.10.1 on Mac OS 10.5.6). Unfortunately, I’m not 100% crystal clear what exactly I did that fixed the problem but here is a list of the changes I made (from memory) which allowed me to compile happstack through Cabal:

      Note: GHC is installed through MacPorts so it lives out in /opt/… land

      1. I had “~/.cabal/bin” on my path from the get-go, but needed to move that in the path list to BEFORE the “/opt/local/…”, otherwise it’s a no-start.

      2. I did a “cabal install hsx –reinstall” and that worked for me. “cabal install hsp” would not install.

      3. I changed the “~/.cabal/bin” on my path to “/Users//.cabal/bin”

      4. I logged out and back in, typed “cabal install happstack” and good to go. I think #3 was what did it for me but I’m listing everything just to be sure. (I’m assuming the burnt offerings and dance around my computer chair had nothing to do with the successful install, but if the above doesn’t work, try that too)

      Note that I’m now having a new challenge:
      Desktop $ happstack new project myproject
      Desktop $ cd myproject/
      myproject $ sh bin/run.sh

      src/AppControl.hs:8:7:
      Could not find module `Control.Monad.Trans’:
      it was found in multiple packages: transformers-0.1.1.0 mtl-1.1.0.2

      I think I’m going to try reinstalling ghc from scratch (dumping my ~/.cabal and /opt/local/lib/ghc* directories) and see if that can straighten things out. At some point, I seemed to have messed up my cabal package repo…

      • mtl is more or less the defacto standard “Control.Monad.Trans”, this is a namespace overlap. you can get around this explicitly adding “-hide-package transformers-0.1.1.0″ to your run script command line args for runghc. the other more global option is to simply do a “ghc-pkg hide transformers-0.1.1.0″

  11. Pingback: Top Posts « WordPress.com

  12. Lally

    A few deps didn’t auto-install, but manually calling cabal for them worked.

    Specifically:
    cabal install happy
    cabal install haskell-src-exts
    cabal install happstack

    did the trick.

    It’s running! Easily! With minimal discomfort!

    Wonderful.