title: Function out of scope
body: <p>I have a doubt of why is this happening. I have been following the "Yesod Web" ebook but with a scaffolded site. When I arrived to a position that I wanted to apply the function of "plural" inside a "messages" file, the compiler returns this error:</p>
  
  <p>Foundation.hs:52:1: Not in scope: `plural'</p>
  
  <p>Where plural is declared in the same hs file as the one that I am calling the "hamlet" one. However, if I move the function declaration before the line #52 in the "Foundation.hs" file, then the error vanishes and it let me compile it effectively. Why does this happen??</p>
  
  <pre><code>module Handler.UserProfile where
  
  import Import
  import Data.Maybe (fromMaybe)
  import Data.Text (pack, unpack)
  
  viewCountName :: Text
  viewCountName = "UserProfileViews"
  
  readInt :: String -&gt; Int
  readInt = read
  
  plural :: Int -&gt; String -&gt; String -&gt; String
  plural 1 x _ = x
  plural _ _ y = y
  
  getUserProfileR :: Handler RepHtml
  getUserProfileR = do
  
      viewCount &lt;- lookupSession viewCountName
                  &gt;&gt;= return . (1 +) . readInt . unpack . fromMaybe "0"
      setSession viewCountName (pack $ show viewCount)
  
      maid &lt;- maybeAuth
      --msg &lt;- getMessageRender
      let user = case maid of
                      Nothing -&gt; "(Unknown User ID)" --show MsgHello --
                      Just (Entity _ u) -&gt; userEmail u
      defaultLayout $ do
          setTitleI MsgUserProfile
          $(widgetFile "nhUserProfile")
  </code></pre>