summaryrefslogtreecommitdiff
path: root/src/Utils.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utils.hs')
-rw-r--r--src/Utils.hs20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/Utils.hs b/src/Utils.hs
index cac88ac..b98359a 100644
--- a/src/Utils.hs
+++ b/src/Utils.hs
@@ -2,8 +2,6 @@
2 2
3module Utils 3module Utils
4 ( showEntity 4 ( showEntity
5 , apply, apply'
6 , entities
7 , takeR 5 , takeR
8 ) where 6 ) where
9 7
@@ -24,23 +22,15 @@ import qualified Data.Set as Set
24import Data.Sequence (Seq, ViewR(..), (|>)) 22import Data.Sequence (Seq, ViewR(..), (|>))
25import qualified Data.Sequence as Seq 23import qualified Data.Sequence as Seq
26 24
25import Data.CaseInsensitive ( CI )
26import qualified Data.CaseInsensitive as CI
27
27import Types 28import Types
28 29
29showEntity :: Entity -> Text 30showEntity :: Entity -> Text
30showEntity (Entity name number) 31showEntity (Entity name number)
31 | (Just (show -> n)) <- number = name <> " № " <> Text.pack n 32 | (Just (show -> n)) <- number = CI.original name <> " № " <> Text.pack n
32 | otherwise = name 33 | otherwise = CI.original name
33
34apply' :: MonadState Context m => Alteration -> Comment -> m ()
35apply' alteration comment = modify $ onCtx (apply alteration comment)
36 where
37 onCtx f ctx = let (sequence', history') = f $ ctxSequence ctx in ctx { ctxSequence = sequence', ctxHistory = ctxHistory ctx <> history' }
38
39apply :: Alteration -> Comment -> Sequence -> (Sequence, History)
40apply alteration comment seq = undefined
41
42entities :: MonadState Sequence m => m (Set Entity)
43entities = Set.fromList . MaxPQueue.elems <$> get
44 34
45takeR :: Integer -> Seq a -> Seq a 35takeR :: Integer -> Seq a -> Seq a
46takeR _ (Seq.viewr -> EmptyR) = Seq.empty 36takeR _ (Seq.viewr -> EmptyR) = Seq.empty