summaryrefslogtreecommitdiff
path: root/src/Utils.hs
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-05-07 21:43:23 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2016-05-07 21:43:23 +0200
commit3df1de8111f8efa853ed73161a28cb69612322d3 (patch)
treeee7f5e88649f694ff4d9f7b2ca3c5de16f91a8d5 /src/Utils.hs
parent2e662e12f5fd6d26eee9e74b06b9cf3d176df07e (diff)
download2017-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.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