{-# LANGUAGE TemplateHaskell, QuasiQuotes, TypeFamilies #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} module Main where import Yesod import Yesod.Static import Control.Concurrent.STM import Control.Arrow ((***)) import Data.Text (Text, unpack) -- speaker and content data Message = Message Text Text -- all those TChans are dupes, so writing to any one writes to them all, but reading is separate data Chat = Chat { chatClients :: TVar [(Int, TChan Message)] , nextClient :: TVar Int , chatStatic :: Static } staticFiles "static" mkYesod "Chat" [parseRoutes| / HomeR GET /check CheckR GET /post PostR GET /static StaticR Static chatStatic |] instance Yesod Chat where approot _ = "" defaultLayout widget = do content <- widgetToPageContent widget hamletToRepHtml [hamlet| !!!