[Haskell-beginners] What's this [f| data |] ??

Felipe Almeida Lessa felipe.lessa at gmail.com
Wed Jul 4 04:43:48 CEST 2012


On Tue, Jul 3, 2012 at 11:10 PM, Carlos J. G. Duarte
<carlos.j.g.duarte at gmail.com> wrote:
> For instance, on this http://www.yesodweb.com/blog/2012/04/yesod-js-todo
> they have a few constructs like this:
>
> mkYesod "App" [parseRoutes|
> / HomeR GET
> /todo TodosR GET PUT
> /todo/#TodoId TodoR GET DELETE
> |]
>
> It seems that the inline text is going to be fed to parseRoutes. How does
> that constructs work (links?)? I already know list comprehensions which
> appear to be related with this.

That's a Template Haskell (TH) quasi-quotation.  The 'parseRoutes'
function is the quasi-quoter.  Check [1] and [2] for starters =).
Also, don't be afraid to ask questions on the Yesod mailing list (of
which I'm a subscriber, too).

[1] http://www.haskell.org/haskellwiki/Quasiquotation
[2] http://www.haskell.org/ghc/docs/latest/html/users_guide/template-haskell.html#th-quasiquotation

Cheers,

-- 
Felipe.



More information about the Beginners mailing list