summaryrefslogtreecommitdiff
path: root/src/Utils.hs
blob: 2254fde344de918b52fef4919011e30b8ef353fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{-# LANGUAGE ViewPatterns, OverloadedStrings, FlexibleContexts #-}

module Utils
       ( showEntity
       , apply, apply'
       ) where

import Data.Text (Text)
import qualified Data.Text as Text

import Data.Monoid (Monoid(..), (<>))

import Control.Monad.State.Class
import Control.Monad.Writer.Class

import Types

showEntity :: Entity -> Text
showEntity (Entity name number)
  | (Just (show -> n)) <- number = name <> " № " <> Text.pack n
  | otherwise = name

apply' :: (MonadState Sequence m, MonadWriter History m) => Alteration -> m ()
apply' alteration = do
  (newSt, hist) <- apply alteration <$> get
  tell hist
  put newSt

apply :: Alteration -> Sequence -> (Sequence, History)
apply alteration seq = undefined