Alson Kemp

ANNOUNCE: Turbinado V0.6

It’s been long enough since Turbinado V0.4 that I figured I’d skip V0.5 and go straight to announcing Turbinado V0.6.  Lots of new excellent features:

  • By popular demand, support for CGI serving. Apparently some web hosts don’t support HTTP proxying, so some folks requested CGI support.
  • Statically compiled Layouts, Views, Controllers.
  • Support for “.format” in routes. If a request path is “/User/List.xml”, then the following View will be called: /App/Views/User/ListXml.hs.
  • Lower case paths.
  • Support for cookies (see here for examples).
  • Encrypted cookie sessions (see here to see how to use them).
  • Much easier installs using cabal-install.
  • Support for GHC 6.10.  GHC 6.8 is no longer supported.

Turbinado V0.7 will be all about:

  • Documentation. (seriously.)
  • User authentication.
  • Tutorials.


Installation is pretty painless if you use cabal-install, so make sure that you have cabal-install installed first.  See here: http://hackage.haskell.org/trac/hackage/wiki/CabalInstall.

To install Turbinado:

git clone git@github.com:alsonkemp/turbinado-website.git
cd turbinado-website
cabal install
[This might fail, saying that "trhsx" can't be found.  However, "trhsx" was built during the install and is probably at ~/.cabal/bin/trhsx, so copy "trhsx" to your path and re-run "cabal install".]

CGI Configuration

[Note: you don’t want to use CGI without statically compiling in some Controllers, Layouts and Views.  See below.]

Usually, Turbinado is called with “-p” to specify the port the process should listen on (e.g. “turbinado -p 8080”).  When called with the “-c” flag, Turbinado will handle CGI requests.  However, because of the process setup and tear down times, responding to CGI requests takes about 250ms, which is considerably slower than responding to HTTP requests (about 1ms).

Again following Rails, Turbinado includes a CGI script called “dispatch.cgi” in the /static directory.

Apache Configuration

In order to use Turbinado’s CGI functionality with Apache, you’ll need to something like the following in order to tell Apache to allow CGI scripts in your Turbinado /static directory and to send all requests (e.g. “^(.\*)$”) to the “dispatch.cgi” script.

  DocumentRoot /home/alson/turbinado-website/static
  <Directory "/home/alson/turbinado-website/static">
     Options +FollowSymLinks +ExecCGI +Includes
     AddHandler cgi-script .cgi
     AllowOverride None
     Order allow,deny
     Allow from all
  RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/dispatch.cgi [QSA,L]

Static Compilation Of Resources

Turbinado is designed to dynamically compile and link in the various resources (Controllers, Layouts, Views) needed to serve a request. However, it can take up to 15 seconds to complete that process the first time a particular page is requested (subsequent requests are very fast). With CGI, the server only ever sees the first request, so Turbinado would never be able to serve a CGI request faster than 10-20 seconds.

To fix this, you can now compile into the server particular resources. See Config/Routes.hs here. Turbinado stores a function along with the file path and function name in a tuple, so you just give Turbinado that information in the Routes.hs file and it’ll load those functions into the CodeStore at startup:

staticLayouts =
    [ ("App/Layouts/Default.hs", "markup", App.Layouts.Default.markup)

Support for “formats”

Rails has great support for file formats. Turbinado is trying to follow that lead. The system will try to figure out the MIME type based on the extension. According to the standard routes (Config/Routes.hs), the following path=>View mappings will occur:

/abba/ding => /App/Views/Abba/Ding.hs
/abba/ding.xml => /App/Views/Abba/DingXml.hs
/bloof/snort/1.csv => /App/Views/Bloof/SnortCsv.hs

The same Controller handles all formats; only the View will change. Also, usage of a format causes a blank Layout to be used (on the assumption that you don’t want a Layout used with a CSV, XML, etc output).

Lower case paths

Turbinado now defaults to using lower case paths (configured in Config/App.hs), so the following paths get mapped to Controllers and Views as follows:

/abba/ding_fling => /App/Controllers/Abba.hs : dingFling
                 => /App/Views/Abba/DingFling.hs


Cookies are now supported. Examples here.

setCookie $ mkCookie "counter" (show 0)
v <- getCookieValue "counter"
deleteCookie "counter"

Cookie Sessions

Session data is encrypted and stuffed into a cookie. The encryption key is set in Config/App.hs. Session usage examples are here.

setSessionValue "counter" "0"
v <- setSessionValue "counter"
deleteSessionKey "counter"

Written by alson

March 12th, 2009 at 10:20 pm

Posted in Haskell,Turbinado

with 14 comments

14 Responses to 'ANNOUNCE: Turbinado V0.6'

Subscribe to comments with RSS or TrackBack to 'ANNOUNCE: Turbinado V0.6'.

  1. Hi!

    We already thought Turbinado is dead and went to django/dojo/js road :-/

    Any ETA for next release with (hopefully) some tutorials?



    13 Mar 09 at 4:22 am

  2. Gour,

    Turbinado definitely isn’t dead! Just hadn’t had a release in a month or so. That said, unless you’re interested in developing/contributing, I would definitely recommend Rails or Django for real website building right now.

    Depending on my schedule, I’m going to try to get documentation and some tutorials fixed up in the next week or two.



    13 Mar 09 at 11:23 am

  3. Hi Alson,

    thank you for reply.

    I was expecting to see some commit to github and not seeing any I was thinking…

    I’d like to contribute a bit, but without docs I won’t be able to come far 🙁

    Otoh, there is imminent need to put something together, and that’s why we’ll use Django.

    However, let’s think about Turbinado as our ‘bright future’ for web development.

    It’s progressing (seeing latest feature list) quite nice, and wish you to become a real killer-app in the Haskell’s arsenal 😉



    13 Mar 09 at 12:56 pm

  4. Alson,
    This is a great project. I am trying to learn it and just downloaded it.
    I built cabal-install and it has been working fine to install other packages like HTTP, zlib, etc.
    When I cd to turbinado-website and run cabal install I get the following error. How to fix it?

    Resolving dependencies…
    cabal: cannot configure turbinado-0.6.0. It requires base >=4
    For the dependency on base >=4 there are these packages: base- However
    none of them are available.
    base- was excluded because of the top level dependency base -any


    14 Mar 09 at 3:24 am

  5. Joshi,

    Not sure what is the issue there. Turbinado only compiles with GHC 6.10 and GHC 6.10 includes both base-3 and base-4. My first guess would be that you’re using GHC 6.8. Are you using GHC 6.8 or GHC 6.10?



    14 Mar 09 at 10:21 pm

  6. I’m currently oscilating between happstack and turbinado. The first one coming with good tutorial/documentation will probably win me over.

    Vagif Verdi

    14 Mar 09 at 11:42 pm

  7. Vagif,

    Documentation is the Achilles heel of open source projects. I’ve been focused on adding features, but know that documentation is a major problem for Turbinado and will be focusing on that for the next release.



    15 Mar 09 at 12:52 pm

  8. Thanks, Alson. Yes, that was the problem. I was on ghc 6.8 and after upgrading to 6.10 I could compile turbinado fine. Is there a tutorial / hello world?


    16 Mar 09 at 2:43 am

  9. After upgrading to ghc 6.10 and installing all cabal packages that turbinado depends on, I still got linker error during turbinado build. And I could resolve it only after installing libedit-dev package on Ubuntu.
    Alson, you might want to include that in your list of dependencies in documentation. configure does not complain about that.


    16 Mar 09 at 2:56 am

  10. Joshi,

    Thanks for the note. Since GHC 6.10 is just getting added to Debian (and Ubuntu), there are still some hiccups in the packages. I’ll ping the GHC maintainer and suggest that they make libedit-dev a dependency of GHC 6.10. We’d discussed it before.



    16 Mar 09 at 12:11 pm

  11. After building turbinado, the URL http://the-machines-name:9999/images/1×1.gif works. But, trying any other controller fails with the following error:

    Turbinado/Environment/Types.hs:31:51: HTTP.Request' is not applied to enough type arguments Expected kind‘, but HTTP.Request' has kind -> *’ In the type Maybe HTTP.Request' In the data type declaration forEnvironment’

    Am I missing anything? Request really has kind -> and Maybe does expect kind *. I tried replacing Maybe HTTP.Request by HTTP.Request String and that seems to take me beyond that error before failing at other points.

    I will appreciate explanation.


    26 May 09 at 5:12 pm

  12. This is probably due to using HTTP 4000. Turbinado is currently compatible with HTTP 3000, though I am about to update it to HTTP 4000. Should be done this weekend.


    1 Jun 09 at 9:19 pm

  13. While loading XMLGenerator.hs in ghci it throws following error:

    XMLGenerator.hs:162:16: parse error on input `|’

    The code at that place is as follows:
    fromAttrValue v@(Value needsEscape str) = case str of
    [ v1+, (| ‘,’, vs@:(_+) |)+ ] ->
    map (fromAttrValue . Value needsEscape) (v1:vs)

    Am I missing some ghc extension? I will appreciate if you explain how this list is created or point to appropriate resources. I know comma-separated lists and the standard list comprehension with pipe operator. But, I don’t recognize this v1+ thing.

    I would like to contribute and can work on fixing bugs or on code improvements. But, I need some guidance or support from you.



    10 Jun 09 at 11:21 pm

  14. Joshi,

    Thank you for the bug report. To be perfectly honest, I wouldn’t be able to figure out what to do with that error message, since HSX causes wildly strange error messages to be thrown.

    But things are getting better! I’ve actually completely removed the HSX (XML) support from Turbinado and replaced it with a custom preprocessor that handles HAML and XHTML. I’m typing up the release notes for Turbinado 0.7 right now, so check back soon. V0.7 is currently on Github @ http://github.com/turbinado.



    14 Jun 09 at 12:13 am

Leave a Reply