diff options
Diffstat (limited to 'src/Utils.hs')
| -rw-r--r-- | src/Utils.hs | 20 |
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 | ||
| 3 | module Utils | 3 | module 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 | |||
| 24 | import Data.Sequence (Seq, ViewR(..), (|>)) | 22 | import Data.Sequence (Seq, ViewR(..), (|>)) |
| 25 | import qualified Data.Sequence as Seq | 23 | import qualified Data.Sequence as Seq |
| 26 | 24 | ||
| 25 | import Data.CaseInsensitive ( CI ) | ||
| 26 | import qualified Data.CaseInsensitive as CI | ||
| 27 | |||
| 27 | import Types | 28 | import Types |
| 28 | 29 | ||
| 29 | showEntity :: Entity -> Text | 30 | showEntity :: Entity -> Text |
| 30 | showEntity (Entity name number) | 31 | showEntity (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 | |||
| 34 | apply' :: MonadState Context m => Alteration -> Comment -> m () | ||
| 35 | apply' 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 | |||
| 39 | apply :: Alteration -> Comment -> Sequence -> (Sequence, History) | ||
| 40 | apply alteration comment seq = undefined | ||
| 41 | |||
| 42 | entities :: MonadState Sequence m => m (Set Entity) | ||
| 43 | entities = Set.fromList . MaxPQueue.elems <$> get | ||
| 44 | 34 | ||
| 45 | takeR :: Integer -> Seq a -> Seq a | 35 | takeR :: Integer -> Seq a -> Seq a |
| 46 | takeR _ (Seq.viewr -> EmptyR) = Seq.empty | 36 | takeR _ (Seq.viewr -> EmptyR) = Seq.empty |
