summaryrefslogtreecommitdiff
path: root/src/Utils.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utils.hs')
-rw-r--r--src/Utils.hs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/Utils.hs b/src/Utils.hs
new file mode 100644
index 0000000..2254fde
--- /dev/null
+++ b/src/Utils.hs
@@ -0,0 +1,30 @@
1{-# LANGUAGE ViewPatterns, OverloadedStrings, FlexibleContexts #-}
2
3module Utils
4 ( showEntity
5 , apply, apply'
6 ) where
7
8import Data.Text (Text)
9import qualified Data.Text as Text
10
11import Data.Monoid (Monoid(..), (<>))
12
13import Control.Monad.State.Class
14import Control.Monad.Writer.Class
15
16import Types
17
18showEntity :: Entity -> Text
19showEntity (Entity name number)
20 | (Just (show -> n)) <- number = name <> " № " <> Text.pack n
21 | otherwise = name
22
23apply' :: (MonadState Sequence m, MonadWriter History m) => Alteration -> m ()
24apply' alteration = do
25 (newSt, hist) <- apply alteration <$> get
26 tell hist
27 put newSt
28
29apply :: Alteration -> Sequence -> (Sequence, History)
30apply alteration seq = undefined