Skip to content

Commit

Permalink
some renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
zachary822 committed Nov 29, 2023
1 parent 67b3485 commit 157c527
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions app/Lib/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ import Database.MongoDB qualified as M
import GHC.Generics
import Web.Scotty.Trans

newtype Config = Config
newtype AppConfig = AppConfig
{ getPool :: Pool Pipe
}

type ConfigReader = ReaderT Config IO
type ScottyM = ScottyT ConfigReader
type ActionM = ActionT ConfigReader
type AppConfigReaderM m = ReaderT AppConfig m
type AppConfigReader = AppConfigReaderM IO
type ScottyM = ScottyT AppConfigReader
type ActionM = ActionT AppConfigReader

newtype Oid = Oid ObjectId

Expand Down
6 changes: 3 additions & 3 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ mdToHtml =
<=< readMarkdown def{readerExtensions = extensionsFromList [Ext_backtick_code_blocks, Ext_raw_html]}
)

scottySocketT' :: Maybe FilePath -> Options -> (ConfigReader Response -> IO Response) -> ScottyM () -> IO ()
scottySocketT' :: Maybe FilePath -> Options -> (AppConfigReader Response -> IO Response) -> ScottyM () -> IO ()
scottySocketT' mpath opts pool app = case mpath of
Nothing -> do
scottyOptsT opts pool app
Expand Down Expand Up @@ -177,7 +177,7 @@ getCurrentPage page = pageOffset page `div` pageLimit page + 1
getMaxPage :: (Integral a, Integral b) => a -> Page -> b
getMaxPage total page = ceiling (fromIntegral total / fromIntegral (pageLimit page) :: Double)

runDb :: (MonadIO m) => Database -> Action IO b -> ActionT (ReaderT Config m) b
runDb :: (MonadIO m) => Database -> Action IO b -> ActionT (AppConfigReaderM m) b
runDb dbname q = do
pool <- getPool <$> lift ask
liftAndCatchIO $
Expand All @@ -203,7 +203,7 @@ main = do

pool <- newPool (defaultPoolConfig (getPipe rs uname passwd) M.close 10 5)

let f = flip runReaderT Config{getPool = pool}
let f = flip runReaderT AppConfig{getPool = pool}
opts =
defaultOptions
{ settings =
Expand Down

0 comments on commit 157c527

Please sign in to comment.