aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Control/Monad/Page.hs
blob: 82b7715d51b43b43494a14a689f25f5a3d41e4dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module Control.Monad.Page where

import Control.Monad.State
import Control.Monad.Trans (lift)
import Types.Session
import Types.Scores
import Types.Classes

type Page = StateT Session (State ScoresList)

runPage :: Page a -> ScoresList -> Session -> (ScoresList, Session, a)
runPage k scores session = (scores', session', a)
  where
    ((a, session'), scores') = runState (runStateT k session) scores

putSession :: Session -> Page ()
putSession = put

getSession :: Page Session
getSession = get

getScores :: Page ScoresList
getScores = lift get

putScores :: ScoresList -> Page ()
putScores = lift . put