X {..} <- getEesod notation

I see this notation throughout the sample code for Yesod web applications and have no idea what that means:

 getHomeR :: Handler Html getHomeR = do App {..} <- getYesod 

What does this syntax mean?

I also see the following, I assume the notation:

 getHomeR :: Handler Html getHomeR = do App x <- getYesod 

i.e. Some identifier x instead of the cryptic {..} .

+7
source share
1 answer

They are called wildcards - taking into account the definition of the entry ( App in this case), the App { .. } template displays the entire field names in the field. For example, given the following record definition

 {-# LANGUAGE RecordWildCards #-} data Test = Test { a :: Int, b :: Int } 

you can match it in a template by entering fields a and b in scope, for example.

 sumTest :: Test -> Int sumTest Test {..} = a + b 
+10
source

All Articles