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 Importandimport Chat.Data as Importto 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
getChatin theApprecord (afterappHttpManagerandappLogger) in Fundation.hs, add YesodChat instance for App: I had to modify the
getUserNameon theJust uidcase (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 userThis seems very long and nested... Can we do better?
- In
Fundation.hs, addchatWidget ChatRafter the linepc <- widgetToPageContent $ doin thedefaultLayoutdefinition. 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 >>=Chatafter theappLogger <- newStdoutLoggerSet defaultBufSize >>= makeYesodLoggerandappStatic <- ...in themakeFundationdefinition, but the type doesn't match. I'm a totally lost here, I don't really understand how this functionmakeFundationworks.