diff options
Diffstat (limited to 'src/Utils.hs')
-rw-r--r-- | src/Utils.hs | 30 |
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 | |||
3 | module Utils | ||
4 | ( showEntity | ||
5 | , apply, apply' | ||
6 | ) where | ||
7 | |||
8 | import Data.Text (Text) | ||
9 | import qualified Data.Text as Text | ||
10 | |||
11 | import Data.Monoid (Monoid(..), (<>)) | ||
12 | |||
13 | import Control.Monad.State.Class | ||
14 | import Control.Monad.Writer.Class | ||
15 | |||
16 | import Types | ||
17 | |||
18 | showEntity :: Entity -> Text | ||
19 | showEntity (Entity name number) | ||
20 | | (Just (show -> n)) <- number = name <> " № " <> Text.pack n | ||
21 | | otherwise = name | ||
22 | |||
23 | apply' :: (MonadState Sequence m, MonadWriter History m) => Alteration -> m () | ||
24 | apply' alteration = do | ||
25 | (newSt, hist) <- apply alteration <$> get | ||
26 | tell hist | ||
27 | put newSt | ||
28 | |||
29 | apply :: Alteration -> Sequence -> (Sequence, History) | ||
30 | apply alteration seq = undefined | ||