I found this code on the front 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 features are used in [$parseRoutes|/ Home GET|]
and [$hamlet|%h1 Hello World|]
to get the $, |, / and % symbols working, and what do the symbols do?
() is very often used as the result of something that has no interesting result. For example, an IO action that is supposed to perform some I/O and terminate without producing a result will typically have type IO () .
Overview. We use pattern matching in Haskell to simplify our codes by identifying specific types of expression. We can also use if-else as an alternative to pattern matching. Pattern matching can also be seen as a kind of dynamic polymorphism where, based on the parameter list, different methods can be executed.
Haskell uses a traditional Hindley-Milner polymorphic type system to provide a static type semantics [4, 6], but the type system has been extended with type classes (or just classes) that provide a structured way to introduce overloaded functions. A class declaration (Section 4.3.
Haskell (/ˈhæskəl/) is a general-purpose, statically-typed, purely functional programming language with type inference and lazy evaluation.
Those would be a Quasiquotation. It's a way to use Template Haskell to embed another language into Haskell. The quasiquotes 'parseRoutes and hamlet define how to parse and interpret what is inside the bracket [$FOO| ... ]. Many more details at the link above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With