How is the Haskell syntax used in [$ parseRoutes | / Home GET |]?

I found this code on the first page of the Yesod project:

import Yesod data HelloWorld = HelloWorld mkYesod "HelloWorld" [$parseRoutes|/ Home GET|] instance Yesod HelloWorld where approot _ = "" getHome = applyLayout [$hamlet|%h1 Hello World|] main = toWaiApp HelloWorld >>= basicHandler 3000 

What language functions are used in [$parseRoutes|/ Home GET|] and [$hamlet|%h1 Hello World|] to get the characters $, |, / and% and what do the characters do?

+6
syntax web-applications haskell yesod template-haskell
source share
1 answer

This will be a quasiquotation . This is the way to use Template Haskell to embed another language in Haskell. The parseRoutes parameter and the quasiquotes tree determines how to analyze and interpret what is inside the bracket [$ FOO | ...]. For more information, see the link above.

+17
source share

All Articles