module Solkattu.Dsl.Section (
section
, startOn, endOn, eddupu
, commentS, dateS
, devel, ending, var, local
, times, x2, x3, x4
, variations
, withTypeS
) where
import qualified Util.CallStack as CallStack
import qualified Util.Num as Num
import qualified Solkattu.Korvai as Korvai
import Solkattu.Korvai (Section, section)
import qualified Solkattu.Metadata as Metadata
import qualified Solkattu.S as S
import qualified Solkattu.Solkattu as Solkattu
import qualified Solkattu.Tags as Tags
import Global
startOn, endOn :: S.Duration -> Section sollu -> Section sollu
startOn :: forall sollu. Duration -> Section sollu -> Section sollu
startOn Duration
dur Section sollu
section = Section sollu
section { sectionStart :: Duration
Korvai.sectionStart = Duration
dur }
endOn :: forall sollu. Duration -> Section sollu -> Section sollu
endOn Duration
dur Section sollu
section = Section sollu
section { sectionEnd :: Duration
Korvai.sectionEnd = Duration
dur }
eddupu :: S.Duration -> Section sollu -> Section sollu
eddupu :: forall sollu. Duration -> Section sollu -> Section sollu
eddupu Duration
dur = forall sollu. Text -> Text -> Section sollu -> Section sollu
withTag Text
Tags.eddupu (forall a. Pretty a => a -> Text
pretty Duration
dur) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall sollu. Duration -> Section sollu -> Section sollu
endOn Duration
dur
dateS :: CallStack.Stack => Int -> Int -> Int -> Section sollu -> Section sollu
dateS :: forall sollu.
Stack =>
Int -> Int -> Int -> Section sollu -> Section sollu
dateS Int
y Int
m Int
d = forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall a. Stack => Text -> a
Solkattu.throw (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall sollu. Text -> Text -> Section sollu -> Section sollu
withTag Text
Tags.date Text
date) forall a b. (a -> b) -> a -> b
$
Int -> Int -> Int -> Either Text Day
Metadata.checkDate Int
y Int
m Int
d
where date :: Text
date = forall a. Show a => a -> Text
showt Int
y forall a. Semigroup a => a -> a -> a
<> Text
"-" forall a. Semigroup a => a -> a -> a
<> forall a. Show a => Int -> a -> Text
Num.zeroPad Int
2 Int
m forall a. Semigroup a => a -> a -> a
<> Text
"-" forall a. Semigroup a => a -> a -> a
<> forall a. Show a => Int -> a -> Text
Num.zeroPad Int
2 Int
d
commentS :: Text -> Section sollu -> Section sollu
= forall sollu. Text -> Text -> Section sollu -> Section sollu
withTag Text
Tags.comment
devel, ending :: sollu -> Section sollu
devel :: forall sollu. sollu -> Section sollu
devel = forall sollu. Text -> Section sollu -> Section sollu
withTypeS Text
Tags.development forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall sollu. sollu -> Section sollu
Korvai.section
ending :: forall sollu. sollu -> Section sollu
ending = forall sollu. Text -> Section sollu -> Section sollu
withTypeS Text
Tags.ending forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall sollu. sollu -> Section sollu
Korvai.section
var :: Section sollu -> Section sollu
var :: forall sollu. Section sollu -> Section sollu
var = forall sollu. Text -> Section sollu -> Section sollu
withTypeS Text
Tags.variation
local :: Section sollu -> Section sollu
local :: forall sollu. Section sollu -> Section sollu
local = forall sollu. Text -> Text -> Section sollu -> Section sollu
withTag Text
"local" Text
""
times :: Int -> Section sollu -> Section sollu
times :: forall sollu. Int -> Section sollu -> Section sollu
times Int
n = forall sollu. Text -> Text -> Section sollu -> Section sollu
withTag Text
Tags.times (forall a. Show a => a -> Text
showt Int
n)
x2, x3, x4 :: Section sollu -> Section sollu
x2 :: forall sollu. Section sollu -> Section sollu
x2 = forall sollu. Int -> Section sollu -> Section sollu
times Int
2
x3 :: forall sollu. Section sollu -> Section sollu
x3 = forall sollu. Int -> Section sollu -> Section sollu
times Int
3
x4 :: forall sollu. Section sollu -> Section sollu
x4 = forall sollu. Int -> Section sollu -> Section sollu
times Int
4
withTypeS :: Text -> Section sollu -> Section sollu
withTypeS :: forall sollu. Text -> Section sollu -> Section sollu
withTypeS = forall sollu. Text -> Text -> Section sollu -> Section sollu
withTag Text
Tags.type_
withTag :: Text -> Text -> Section sollu -> Section sollu
withTag :: forall sollu. Text -> Text -> Section sollu -> Section sollu
withTag Text
k Text
v = forall a. Tags -> Section a -> Section a
Korvai.addSectionTags (Text -> Text -> Tags
Tags.tag Text
k Text
v)
variations :: [sollu] -> [Section sollu]
variations :: forall sollu. [sollu] -> [Section sollu]
variations = forall a b. (a -> b) -> [a] -> [b]
map (forall sollu. Section sollu -> Section sollu
var forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall sollu. sollu -> Section sollu
Korvai.section)