I'm trying to make the chat example from the Yesod book working in the scaffolding site.
I think I've corrected almost all I had to correct, but all of that is completely new to me (it's my first "real" Haskell project) and I'm not very confident in all my modifications; moreover, I'm really stuck at the point 7. Could you comment all the following points if necessary, and helping me for the 7. (in bold some questions/remarks)?
- Copy/paste the Chat.hs and Chat/Data.hs in the root of my site,
- add
import Chat as Import
andimport Chat.Data as Import
to Import.NoFoundation, - add import of IO, Bool, return, Maybe(Nothing), ($) in Data.hs, since the extension NoImplicitPrelude is on Seems very clumsy... Do we have to import all the standard operators on each new file?
- in Fundation.hs, add
getChat
in theApp
record (afterappHttpManager
andappLogger
) in Fundation.hs, add YesodChat instance for App: I had to modify the
getUserName
on theJust uid
case (in the original example of Chat, it was justJust uid -> return uid
):Just uid -> do muser <- runDB $ get uid case muser of Nothing -> error "uid not in the DB" Just user -> return $ userIdent user
This seems very long and nested... Can we do better?
- In
Fundation.hs
, addchatWidget ChatR
after the linepc <- widgetToPageContent $ do
in thedefaultLayout
definition. Now, I have the following warning :
Application.hs:60:36: Warning: Fields of ‘App’ not initialised: getChat In the expression: App {..}
I think I have to write something like
getChat <- newChan >>=Chat
after theappLogger <- newStdoutLoggerSet defaultBufSize >>= makeYesodLogger
andappStatic <- ...
in themakeFundation
definition, but the type doesn't match. I'm a totally lost here, I don't really understand how this functionmakeFundation
works.