Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the $() construct?

I have been trying to find in the Haskell reference the use of this:

getHomeR = defaultLayout $ do
    setTitle "My Awesome Site"
    $(widgetFile "home")

Specifically:

$(widgetFile "home")

I know that the $ operator gives precedence to whatever is to the right of it, but I have not been able to comprehend the usage of $(). Anyone?

like image 812
Luis Dos Reis Avatar asked Jun 28 '15 17:06

Luis Dos Reis


1 Answers

This is not using the $ application operator, but is involving a Template Haskell slice.

Very roughly, widgetFile "home" is code which is run at compile time: it generates Haskell code, which is then compiled as usual. It's a form of metaprogramming in Haskell.

like image 108
chi Avatar answered Nov 10 '22 23:11

chi