Reputation: 672
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)?
import Chat as Import
and import Chat.Data as Import
to Import.NoFoundation,getChat
in the App
record (after appHttpManager
and appLogger
)in Fundation.hs, add YesodChat instance for App: I had to modify the getUserName
on the Just uid
case (in the original example of Chat, it was just Just 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?
Fundation.hs
, add chatWidget ChatR
after the line pc <- widgetToPageContent $ do
in the defaultLayout
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 the appLogger <- newStdoutLoggerSet defaultBufSize >>= makeYesodLogger
and appStatic <- ...
in the makeFundation
definition, but the type doesn't match. I'm a totally lost here, I don't really understand how this function makeFundation
works.
Upvotes: 2
Views: 197
Reputation: 31355
You actually got almost the entire way there. I think you just need to change the line to:
getChat <- fmap Chat newChan
Alternatively, if you're not familiar with he fmap
function yet, you can use do notation and get:
chan <- newChan
let getChat = Chat chan
Upvotes: 2