Safe Haskell | None |
---|---|
Language | GHC2021 |
GTVM.SCP.TL
Description
We need sum types if we want to handle everything in one place. CSVs don't support sum types. YAML does. And with sum types, we can also generate comments from a source SCP -- to e.g. say when another SCP is loaded.
TODO
* Aeson won't ever omit fields for generic parsing or serializing, except in
the specific case where you have a concrete
. To work around
that, I need to write a separate, structurally simplified type, which can be
used for the JSON, and converted to the more powerful internal data type for
operating on.Maybe
a
Synopsis
- type Seg' = Seg 'Weak Text
- type SCP' = [Seg']
- type SCPTL (f :: Type -> Type) a = [TLSeg f a]
- type SCPTL' = SCPTL Identity Text
- data Env = Env {}
- data TLSeg (f :: Type -> Type) a
- = TLSegTextbox' (TLSegTextbox f a)
- | TLSegChoice' [TLSegChoice f a]
- | TLSeg22Choice' (TLSeg22 f a)
- | TLSeg35Choice' (TLSegChoice f a)
- | TLSegComment' TLSegComment
- jcTLSeg :: Options
- data TLSegComment = TLSegComment {}
- data TLSegTextbox (f :: Type -> Type) a = TLSegTextbox {
- tlSegTextboxSource :: f a
- tlSegTextboxTranslation :: a
- tlSegTextboxOverflow :: Maybe a
- data TLSegChoice (f :: Type -> Type) a = TLSegChoice {
- tlSegChoiceSource :: f a
- tlSegChoiceTranslation :: a
- data TLSeg22 (f :: Type -> Type) a = TLSeg22 {
- tlSeg22TopicSource :: f a
- tlSeg22TopicTranslation :: a
- tlSeg22Choices :: [TLSegChoice f a]
- genTL :: Env -> SCP' -> [TLSeg Identity Text]
- genTLTextbox :: Env -> Seg05Text 'Weak Text -> [TLSeg Identity Text]
- genTLChoiceOuter :: Env -> Natural -> [Text] -> [TLSeg Identity Text]
- genTLChoice :: Env -> Text -> TLSegChoice Identity Text
- genTL22Choices :: Env -> Text -> [Text] -> TLSeg22 Identity Text
- meta :: forall (c :: Type -> Type) s. [Text] -> [(Text, Text)] -> TLSeg c s
- data Error
- apply :: SCP' -> [TLSeg Identity Text] -> Either Error SCP'
- skipToNextTL :: forall (c :: Type -> Type) a. [TLSeg c a] -> [TLSeg c a]
- applySeg :: MonadState [TLSeg Identity Text] m => Seg' -> m (Either Error [Seg'])
- tryExtractTextbox :: forall (c :: Type -> Type) a. TLSeg c a -> Maybe (TLSegTextbox c a)
- tryExtractChoice :: forall (c :: Type -> Type) a. TLSeg c a -> Maybe [TLSegChoice c a]
- tryExtract22 :: forall (c :: Type -> Type) a. TLSeg c a -> Maybe (TLSeg22 c a)
- tryExtract35 :: forall (c :: Type -> Type) a. TLSeg c a -> Maybe (TLSegChoice c a)
- tryApplySeg :: MonadState [TLSeg Identity Text] m => (TLSeg Identity Text -> Maybe a) -> (a -> Either Error [Seg']) -> m (Either Error [Seg'])
- tryApplySegTextbox :: Seg05Text 'Weak Text -> TLSegTextbox Identity Text -> Either Error [Seg']
- tryApplySegChoice :: Natural -> [(Text, Natural)] -> [TLSegChoice Identity Text] -> Either Error [Seg']
- tryApplySeg22 :: Text -> [(Text, Natural)] -> TLSeg22 Identity Text -> Either Error [Seg']
- tryApplySeg35 :: Text -> TLSegChoice Identity Text -> Either Error [Seg']
- traverseM :: (Traversable t, Applicative f, Monad m) => (v -> m (f v')) -> t v -> m (f (t v'))
- tlSegFieldOrdering :: Text -> Text -> Ordering
- segIsTlTarget :: forall (f :: Strength) a. Seg f a -> Bool
- segDropMeta :: forall (f :: Type -> Type) a. TLSeg f a -> TLSeg (Const () :: Type -> Type) a
Documentation
Constructors
Env | |
Fields
|
Instances
Generic Env Source # | |||||
Defined in GTVM.SCP.TL Associated Types
| |||||
type Rep Env Source # | |||||
Defined in GTVM.SCP.TL type Rep Env = D1 ('MetaData "Env" "GTVM.SCP.TL" "gtvm-hs-1.0.0-inplace" 'False) (C1 ('MetaCons "Env" 'PrefixI 'True) (S1 ('MetaSel ('Just "envPendingPlaceholder") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "envSpeakerIDMap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Natural -> Maybe Text)))) |
data TLSeg (f :: Type -> Type) a Source #
Constructors
TLSegTextbox' (TLSegTextbox f a) | |
TLSegChoice' [TLSegChoice f a] | |
TLSeg22Choice' (TLSeg22 f a) | |
TLSeg35Choice' (TLSegChoice f a) | |
TLSegComment' TLSegComment |
Instances
data TLSegComment Source #
Constructors
TLSegComment | |
Fields |
Instances
FromJSON TLSegComment Source # | |||||
Defined in GTVM.SCP.TL | |||||
ToJSON TLSegComment Source # | |||||
Defined in GTVM.SCP.TL Methods toJSON :: TLSegComment -> Value # toEncoding :: TLSegComment -> Encoding # toJSONList :: [TLSegComment] -> Value # toEncodingList :: [TLSegComment] -> Encoding # omitField :: TLSegComment -> Bool # | |||||
Generic TLSegComment Source # | |||||
Defined in GTVM.SCP.TL Associated Types
| |||||
Show TLSegComment Source # | |||||
Defined in GTVM.SCP.TL Methods showsPrec :: Int -> TLSegComment -> ShowS # show :: TLSegComment -> String # showList :: [TLSegComment] -> ShowS # | |||||
Eq TLSegComment Source # | |||||
Defined in GTVM.SCP.TL | |||||
type Rep TLSegComment Source # | |||||
Defined in GTVM.SCP.TL type Rep TLSegComment = D1 ('MetaData "TLSegComment" "GTVM.SCP.TL" "gtvm-hs-1.0.0-inplace" 'False) (C1 ('MetaCons "TLSegComment" 'PrefixI 'True) (S1 ('MetaSel ('Just "scpTLCommentCommentary") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Text]) :*: S1 ('MetaSel ('Just "scpTLCommentMeta") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map Text Text)))) |
data TLSegTextbox (f :: Type -> Type) a Source #
Constructors
TLSegTextbox | |
Fields
|
Instances
Functor f => Functor (TLSegTextbox f) Source # | |||||
Defined in GTVM.SCP.TL Methods fmap :: (a -> b) -> TLSegTextbox f a -> TLSegTextbox f b # (<$) :: a -> TLSegTextbox f b -> TLSegTextbox f a # | |||||
Foldable f => Foldable (TLSegTextbox f) Source # | |||||
Defined in GTVM.SCP.TL Methods fold :: Monoid m => TLSegTextbox f m -> m # foldMap :: Monoid m => (a -> m) -> TLSegTextbox f a -> m # foldMap' :: Monoid m => (a -> m) -> TLSegTextbox f a -> m # foldr :: (a -> b -> b) -> b -> TLSegTextbox f a -> b # foldr' :: (a -> b -> b) -> b -> TLSegTextbox f a -> b # foldl :: (b -> a -> b) -> b -> TLSegTextbox f a -> b # foldl' :: (b -> a -> b) -> b -> TLSegTextbox f a -> b # foldr1 :: (a -> a -> a) -> TLSegTextbox f a -> a # foldl1 :: (a -> a -> a) -> TLSegTextbox f a -> a # toList :: TLSegTextbox f a -> [a] # null :: TLSegTextbox f a -> Bool # length :: TLSegTextbox f a -> Int # elem :: Eq a => a -> TLSegTextbox f a -> Bool # maximum :: Ord a => TLSegTextbox f a -> a # minimum :: Ord a => TLSegTextbox f a -> a # sum :: Num a => TLSegTextbox f a -> a # product :: Num a => TLSegTextbox f a -> a # | |||||
Traversable f => Traversable (TLSegTextbox f) Source # | |||||
Defined in GTVM.SCP.TL Methods traverse :: Applicative f0 => (a -> f0 b) -> TLSegTextbox f a -> f0 (TLSegTextbox f b) # sequenceA :: Applicative f0 => TLSegTextbox f (f0 a) -> f0 (TLSegTextbox f a) # mapM :: Monad m => (a -> m b) -> TLSegTextbox f a -> m (TLSegTextbox f b) # sequence :: Monad m => TLSegTextbox f (m a) -> m (TLSegTextbox f a) # | |||||
(FromJSON (f a), FromJSON a) => FromJSON (TLSegTextbox f a) Source # | |||||
Defined in GTVM.SCP.TL Methods parseJSON :: Value -> Parser (TLSegTextbox f a) # parseJSONList :: Value -> Parser [TLSegTextbox f a] # omittedField :: Maybe (TLSegTextbox f a) # | |||||
(ToJSON (f a), ToJSON a) => ToJSON (TLSegTextbox f a) Source # | |||||
Defined in GTVM.SCP.TL Methods toJSON :: TLSegTextbox f a -> Value # toEncoding :: TLSegTextbox f a -> Encoding # toJSONList :: [TLSegTextbox f a] -> Value # toEncodingList :: [TLSegTextbox f a] -> Encoding # omitField :: TLSegTextbox f a -> Bool # | |||||
Generic (TLSegTextbox f a) Source # | |||||
Defined in GTVM.SCP.TL Associated Types
Methods from :: TLSegTextbox f a -> Rep (TLSegTextbox f a) x # to :: Rep (TLSegTextbox f a) x -> TLSegTextbox f a # | |||||
(Show (f a), Show a) => Show (TLSegTextbox f a) Source # | |||||
Defined in GTVM.SCP.TL Methods showsPrec :: Int -> TLSegTextbox f a -> ShowS # show :: TLSegTextbox f a -> String # showList :: [TLSegTextbox f a] -> ShowS # | |||||
(Eq (f a), Eq a) => Eq (TLSegTextbox f a) Source # | |||||
Defined in GTVM.SCP.TL Methods (==) :: TLSegTextbox f a -> TLSegTextbox f a -> Bool # (/=) :: TLSegTextbox f a -> TLSegTextbox f a -> Bool # | |||||
type Rep (TLSegTextbox f a) Source # | |||||
Defined in GTVM.SCP.TL type Rep (TLSegTextbox f a) = D1 ('MetaData "TLSegTextbox" "GTVM.SCP.TL" "gtvm-hs-1.0.0-inplace" 'False) (C1 ('MetaCons "TLSegTextbox" 'PrefixI 'True) (S1 ('MetaSel ('Just "tlSegTextboxSource") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a)) :*: (S1 ('MetaSel ('Just "tlSegTextboxTranslation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Just "tlSegTextboxOverflow") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe a))))) |
data TLSegChoice (f :: Type -> Type) a Source #
Constructors
TLSegChoice | |
Fields
|
Instances
Functor f => Functor (TLSegChoice f) Source # | |||||
Defined in GTVM.SCP.TL Methods fmap :: (a -> b) -> TLSegChoice f a -> TLSegChoice f b # (<$) :: a -> TLSegChoice f b -> TLSegChoice f a # | |||||
Foldable f => Foldable (TLSegChoice f) Source # | |||||
Defined in GTVM.SCP.TL Methods fold :: Monoid m => TLSegChoice f m -> m # foldMap :: Monoid m => (a -> m) -> TLSegChoice f a -> m # foldMap' :: Monoid m => (a -> m) -> TLSegChoice f a -> m # foldr :: (a -> b -> b) -> b -> TLSegChoice f a -> b # foldr' :: (a -> b -> b) -> b -> TLSegChoice f a -> b # foldl :: (b -> a -> b) -> b -> TLSegChoice f a -> b # foldl' :: (b -> a -> b) -> b -> TLSegChoice f a -> b # foldr1 :: (a -> a -> a) -> TLSegChoice f a -> a # foldl1 :: (a -> a -> a) -> TLSegChoice f a -> a # toList :: TLSegChoice f a -> [a] # null :: TLSegChoice f a -> Bool # length :: TLSegChoice f a -> Int # elem :: Eq a => a -> TLSegChoice f a -> Bool # maximum :: Ord a => TLSegChoice f a -> a # minimum :: Ord a => TLSegChoice f a -> a # sum :: Num a => TLSegChoice f a -> a # product :: Num a => TLSegChoice f a -> a # | |||||
Traversable f => Traversable (TLSegChoice f) Source # | |||||
Defined in GTVM.SCP.TL Methods traverse :: Applicative f0 => (a -> f0 b) -> TLSegChoice f a -> f0 (TLSegChoice f b) # sequenceA :: Applicative f0 => TLSegChoice f (f0 a) -> f0 (TLSegChoice f a) # mapM :: Monad m => (a -> m b) -> TLSegChoice f a -> m (TLSegChoice f b) # sequence :: Monad m => TLSegChoice f (m a) -> m (TLSegChoice f a) # | |||||
(FromJSON (f a), FromJSON a) => FromJSON (TLSegChoice f a) Source # | |||||
Defined in GTVM.SCP.TL Methods parseJSON :: Value -> Parser (TLSegChoice f a) # parseJSONList :: Value -> Parser [TLSegChoice f a] # omittedField :: Maybe (TLSegChoice f a) # | |||||
(ToJSON (f a), ToJSON a) => ToJSON (TLSegChoice f a) Source # | |||||
Defined in GTVM.SCP.TL Methods toJSON :: TLSegChoice f a -> Value # toEncoding :: TLSegChoice f a -> Encoding # toJSONList :: [TLSegChoice f a] -> Value # toEncodingList :: [TLSegChoice f a] -> Encoding # omitField :: TLSegChoice f a -> Bool # | |||||
Generic (TLSegChoice f a) Source # | |||||
Defined in GTVM.SCP.TL Associated Types
Methods from :: TLSegChoice f a -> Rep (TLSegChoice f a) x # to :: Rep (TLSegChoice f a) x -> TLSegChoice f a # | |||||
(Show (f a), Show a) => Show (TLSegChoice f a) Source # | |||||
Defined in GTVM.SCP.TL Methods showsPrec :: Int -> TLSegChoice f a -> ShowS # show :: TLSegChoice f a -> String # showList :: [TLSegChoice f a] -> ShowS # | |||||
(Eq (f a), Eq a) => Eq (TLSegChoice f a) Source # | |||||
Defined in GTVM.SCP.TL Methods (==) :: TLSegChoice f a -> TLSegChoice f a -> Bool # (/=) :: TLSegChoice f a -> TLSegChoice f a -> Bool # | |||||
type Rep (TLSegChoice f a) Source # | |||||
Defined in GTVM.SCP.TL type Rep (TLSegChoice f a) = D1 ('MetaData "TLSegChoice" "GTVM.SCP.TL" "gtvm-hs-1.0.0-inplace" 'False) (C1 ('MetaCons "TLSegChoice" 'PrefixI 'True) (S1 ('MetaSel ('Just "tlSegChoiceSource") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a)) :*: S1 ('MetaSel ('Just "tlSegChoiceTranslation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) |
data TLSeg22 (f :: Type -> Type) a Source #
Constructors
TLSeg22 | |
Fields
|
Instances
Functor f => Functor (TLSeg22 f) Source # | |||||
Foldable f => Foldable (TLSeg22 f) Source # | |||||
Defined in GTVM.SCP.TL Methods fold :: Monoid m => TLSeg22 f m -> m # foldMap :: Monoid m => (a -> m) -> TLSeg22 f a -> m # foldMap' :: Monoid m => (a -> m) -> TLSeg22 f a -> m # foldr :: (a -> b -> b) -> b -> TLSeg22 f a -> b # foldr' :: (a -> b -> b) -> b -> TLSeg22 f a -> b # foldl :: (b -> a -> b) -> b -> TLSeg22 f a -> b # foldl' :: (b -> a -> b) -> b -> TLSeg22 f a -> b # foldr1 :: (a -> a -> a) -> TLSeg22 f a -> a # foldl1 :: (a -> a -> a) -> TLSeg22 f a -> a # toList :: TLSeg22 f a -> [a] # length :: TLSeg22 f a -> Int # elem :: Eq a => a -> TLSeg22 f a -> Bool # maximum :: Ord a => TLSeg22 f a -> a # minimum :: Ord a => TLSeg22 f a -> a # | |||||
Traversable f => Traversable (TLSeg22 f) Source # | |||||
Defined in GTVM.SCP.TL | |||||
(FromJSON (f a), FromJSON a) => FromJSON (TLSeg22 f a) Source # | |||||
Defined in GTVM.SCP.TL | |||||
(ToJSON (f a), ToJSON a) => ToJSON (TLSeg22 f a) Source # | |||||
Generic (TLSeg22 f a) Source # | |||||
Defined in GTVM.SCP.TL Associated Types
| |||||
(Show (f a), Show a) => Show (TLSeg22 f a) Source # | |||||
(Eq (f a), Eq a) => Eq (TLSeg22 f a) Source # | |||||
type Rep (TLSeg22 f a) Source # | |||||
Defined in GTVM.SCP.TL type Rep (TLSeg22 f a) = D1 ('MetaData "TLSeg22" "GTVM.SCP.TL" "gtvm-hs-1.0.0-inplace" 'False) (C1 ('MetaCons "TLSeg22" 'PrefixI 'True) (S1 ('MetaSel ('Just "tlSeg22TopicSource") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a)) :*: (S1 ('MetaSel ('Just "tlSeg22TopicTranslation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Just "tlSeg22Choices") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TLSegChoice f a])))) |
genTLChoice :: Env -> Text -> TLSegChoice Identity Text Source #
Constructors
ErrorTLSegOverlong | |
ErrorSourceMismatch | |
ErrorTLSegTooShort | |
ErrorTypeMismatch | |
ErrorUnimplemented |
Instances
Generic Error Source # | |||||
Defined in GTVM.SCP.TL Associated Types
| |||||
Show Error Source # | |||||
Eq Error Source # | |||||
type Rep Error Source # | |||||
Defined in GTVM.SCP.TL type Rep Error = D1 ('MetaData "Error" "GTVM.SCP.TL" "gtvm-hs-1.0.0-inplace" 'False) ((C1 ('MetaCons "ErrorTLSegOverlong" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ErrorSourceMismatch" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "ErrorTLSegTooShort" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ErrorTypeMismatch" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ErrorUnimplemented" 'PrefixI 'False) (U1 :: Type -> Type)))) |
tryExtractTextbox :: forall (c :: Type -> Type) a. TLSeg c a -> Maybe (TLSegTextbox c a) Source #
tryExtractChoice :: forall (c :: Type -> Type) a. TLSeg c a -> Maybe [TLSegChoice c a] Source #
tryExtract35 :: forall (c :: Type -> Type) a. TLSeg c a -> Maybe (TLSegChoice c a) Source #
tryApplySeg :: MonadState [TLSeg Identity Text] m => (TLSeg Identity Text -> Maybe a) -> (a -> Either Error [Seg']) -> m (Either Error [Seg']) Source #
tryApplySegTextbox :: Seg05Text 'Weak Text -> TLSegTextbox Identity Text -> Either Error [Seg'] Source #
tryApplySegChoice :: Natural -> [(Text, Natural)] -> [TLSegChoice Identity Text] -> Either Error [Seg'] Source #
tryApplySeg35 :: Text -> TLSegChoice Identity Text -> Either Error [Seg'] Source #
traverseM :: (Traversable t, Applicative f, Monad m) => (v -> m (f v')) -> t v -> m (f (t v')) Source #