diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-05-07 21:43:23 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-05-07 21:43:23 +0200 |
commit | 3df1de8111f8efa853ed73161a28cb69612322d3 (patch) | |
tree | ee7f5e88649f694ff4d9f7b2ca3c5de16f91a8d5 /src/Utils.hs | |
parent | 2e662e12f5fd6d26eee9e74b06b9cf3d176df07e (diff) | |
download | 2017-01-16_17:13:37-3df1de8111f8efa853ed73161a28cb69612322d3.tar 2017-01-16_17:13:37-3df1de8111f8efa853ed73161a28cb69612322d3.tar.gz 2017-01-16_17:13:37-3df1de8111f8efa853ed73161a28cb69612322d3.tar.bz2 2017-01-16_17:13:37-3df1de8111f8efa853ed73161a28cb69612322d3.tar.xz 2017-01-16_17:13:37-3df1de8111f8efa853ed73161a28cb69612322d3.zip |
haskeline based framework
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 | ||