diff options
Diffstat (limited to 'src/Types.hs')
-rw-r--r-- | src/Types.hs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/Types.hs b/src/Types.hs index 10cea7a..a90e5fe 100644 --- a/src/Types.hs +++ b/src/Types.hs | |||
@@ -8,6 +8,7 @@ module Types | |||
8 | , Alteration(..) | 8 | , Alteration(..) |
9 | , Sequence | 9 | , Sequence |
10 | , History | 10 | , History |
11 | , Context(..) | ||
11 | , SequenceM | 12 | , SequenceM |
12 | ) where | 13 | ) where |
13 | 14 | ||
@@ -15,6 +16,7 @@ import Data.PQueue.Prio.Max (MaxPQueue) | |||
15 | import qualified Data.PQueue.Prio.Max as MaxPQueue (empty) | 16 | import qualified Data.PQueue.Prio.Max as MaxPQueue (empty) |
16 | 17 | ||
17 | import Data.Sequence (Seq) | 18 | import Data.Sequence (Seq) |
19 | import qualified Data.Sequence as Seq (empty) | ||
18 | 20 | ||
19 | import Data.Text (Text) | 21 | import Data.Text (Text) |
20 | 22 | ||
@@ -46,12 +48,21 @@ type Sequence = MaxPQueue SequenceValue Entity | |||
46 | 48 | ||
47 | type History = Seq (Alteration, Comment) | 49 | type History = Seq (Alteration, Comment) |
48 | 50 | ||
49 | type SequenceM m = (MonadWriter History m, MonadState Sequence m, MonadIO m) | 51 | data Context = Context |
52 | { ctxSequence :: Sequence | ||
53 | , ctxHistory :: History | ||
54 | } | ||
55 | deriving (Show) | ||
56 | |||
57 | type SequenceM m = (MonadState Context m, MonadIO m) | ||
50 | 58 | ||
51 | instance MonadState s m => MonadState s (InputT m) where | 59 | instance MonadState s m => MonadState s (InputT m) where |
52 | get = lift get | 60 | get = lift get |
53 | put = lift . put | 61 | put = lift . put |
54 | state = lift . state | 62 | state = lift . state |
55 | 63 | ||
56 | instance Default (MaxPQueue k v) where | 64 | instance Default Context where |
57 | def = MaxPQueue.empty | 65 | def = Context |
66 | { ctxSequence = MaxPQueue.empty | ||
67 | , ctxHistory = Seq.empty | ||
68 | } | ||