{-# LANGUAGE StrictData #-}
{-# LANGUAGE TemplateHaskell #-}
module Text.BBCode.Internal.Types where
import Control.Lens hiding (List)
import Data.String (IsString (..))
import Data.Text (Text)
data BBCode where
ElVoid :: El -> BBCode
ElSimple :: El -> BBCode -> BBCode
ElArg :: El -> Text -> BBCode -> BBCode
ElText :: Text -> BBCode
ElDocument :: [BBCode] -> BBCode
deriving
( BBCode -> BBCode -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BBCode -> BBCode -> Bool
$c/= :: BBCode -> BBCode -> Bool
== :: BBCode -> BBCode -> Bool
$c== :: BBCode -> BBCode -> Bool
Eq
,
Int -> BBCode -> ShowS
[BBCode] -> ShowS
BBCode -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BBCode] -> ShowS
$cshowList :: [BBCode] -> ShowS
show :: BBCode -> String
$cshow :: BBCode -> String
showsPrec :: Int -> BBCode -> ShowS
$cshowsPrec :: Int -> BBCode -> ShowS
Show
)
instance Semigroup BBCode where
(<>) :: BBCode -> BBCode -> BBCode
<> :: BBCode -> BBCode -> BBCode
(<>) (ElText Text
x) (ElText Text
y) = Text -> BBCode
ElText forall a b. (a -> b) -> a -> b
$ Text
x forall a. Semigroup a => a -> a -> a
<> Text
y
(<>) (ElText Text
"") BBCode
y = BBCode
y
(<>) BBCode
x (ElText Text
"") = BBCode
x
(<>) (ElDocument [BBCode]
xs) (ElDocument [BBCode]
ys) = [BBCode] -> BBCode
ElDocument forall a b. (a -> b) -> a -> b
$ [BBCode]
xs forall a. Semigroup a => a -> a -> a
<> [BBCode]
ys
(<>) (ElDocument [BBCode]
xs) BBCode
y = [BBCode] -> BBCode
ElDocument forall a b. (a -> b) -> a -> b
$ [BBCode]
xs forall a. Semigroup a => a -> a -> a
<> [BBCode
y]
(<>) BBCode
x (ElDocument [BBCode]
ys) = [BBCode] -> BBCode
ElDocument forall a b. (a -> b) -> a -> b
$ [BBCode
x] forall a. Semigroup a => a -> a -> a
<> [BBCode]
ys
(<>) BBCode
x BBCode
y = [BBCode] -> BBCode
ElDocument [BBCode
x, BBCode
y]
{-# INLINEABLE (<>) #-}
instance Monoid BBCode where
mempty :: BBCode
mempty :: BBCode
mempty = Text -> BBCode
ElText Text
""
{-# INLINE mempty #-}
instance IsString BBCode where
fromString :: String -> BBCode
fromString :: String -> BBCode
fromString = Text -> BBCode
ElText forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsString a => String -> a
fromString
{-# INLINE fromString #-}
data El
= HR
| BR
| Clear
| ListElement
| Bold
| Italic
| Underline
| Strikethrough
| Indent
| NFO
| Oneline
| Code
| Preformatted
| Box
| Image
| Quote
| Spoiler
| List
| Color
| URL
| Size
| Align
| Font
deriving
( El -> El -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: El -> El -> Bool
$c/= :: El -> El -> Bool
== :: El -> El -> Bool
$c== :: El -> El -> Bool
Eq
, Eq El
El -> El -> Bool
El -> El -> Ordering
El -> El -> El
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: El -> El -> El
$cmin :: El -> El -> El
max :: El -> El -> El
$cmax :: El -> El -> El
>= :: El -> El -> Bool
$c>= :: El -> El -> Bool
> :: El -> El -> Bool
$c> :: El -> El -> Bool
<= :: El -> El -> Bool
$c<= :: El -> El -> Bool
< :: El -> El -> Bool
$c< :: El -> El -> Bool
compare :: El -> El -> Ordering
$ccompare :: El -> El -> Ordering
Ord
, Int -> El -> ShowS
[El] -> ShowS
El -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [El] -> ShowS
$cshowList :: [El] -> ShowS
show :: El -> String
$cshow :: El -> String
showsPrec :: Int -> El -> ShowS
$cshowsPrec :: Int -> El -> ShowS
Show
, Int -> El
El -> Int
El -> [El]
El -> El
El -> El -> [El]
El -> El -> El -> [El]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: El -> El -> El -> [El]
$cenumFromThenTo :: El -> El -> El -> [El]
enumFromTo :: El -> El -> [El]
$cenumFromTo :: El -> El -> [El]
enumFromThen :: El -> El -> [El]
$cenumFromThen :: El -> El -> [El]
enumFrom :: El -> [El]
$cenumFrom :: El -> [El]
fromEnum :: El -> Int
$cfromEnum :: El -> Int
toEnum :: Int -> El
$ctoEnum :: Int -> El
pred :: El -> El
$cpred :: El -> El
succ :: El -> El
$csucc :: El -> El
Enum
, El
forall a. a -> a -> Bounded a
maxBound :: El
$cmaxBound :: El
minBound :: El
$cminBound :: El
Bounded
)
class IsArgument a where
toArgument :: a -> Text
data AlignPosition where
AlignLeft :: AlignPosition
AlignRight :: AlignPosition
AlignCenter :: AlignPosition
AlignJustify :: AlignPosition
deriving (AlignPosition -> AlignPosition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AlignPosition -> AlignPosition -> Bool
$c/= :: AlignPosition -> AlignPosition -> Bool
== :: AlignPosition -> AlignPosition -> Bool
$c== :: AlignPosition -> AlignPosition -> Bool
Eq, Int -> AlignPosition -> ShowS
[AlignPosition] -> ShowS
AlignPosition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AlignPosition] -> ShowS
$cshowList :: [AlignPosition] -> ShowS
show :: AlignPosition -> String
$cshow :: AlignPosition -> String
showsPrec :: Int -> AlignPosition -> ShowS
$cshowsPrec :: Int -> AlignPosition -> ShowS
Show)
instance IsArgument AlignPosition where
toArgument :: AlignPosition -> Text
toArgument :: AlignPosition -> Text
toArgument AlignPosition
AlignLeft = Text
"left"
toArgument AlignPosition
AlignRight = Text
"right"
toArgument AlignPosition
AlignCenter = Text
"center"
toArgument AlignPosition
AlignJustify = Text
"justify"
{-# INLINEABLE toArgument #-}
data ListFlavor where
Roman :: ListFlavor
ArabicUpper :: ListFlavor
ArabicLower :: ListFlavor
LatinUpper :: ListFlavor
LatinLower :: ListFlavor
deriving (ListFlavor -> ListFlavor -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListFlavor -> ListFlavor -> Bool
$c/= :: ListFlavor -> ListFlavor -> Bool
== :: ListFlavor -> ListFlavor -> Bool
$c== :: ListFlavor -> ListFlavor -> Bool
Eq, Int -> ListFlavor -> ShowS
[ListFlavor] -> ShowS
ListFlavor -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListFlavor] -> ShowS
$cshowList :: [ListFlavor] -> ShowS
show :: ListFlavor -> String
$cshow :: ListFlavor -> String
showsPrec :: Int -> ListFlavor -> ShowS
$cshowsPrec :: Int -> ListFlavor -> ShowS
Show)
instance IsArgument ListFlavor where
toArgument :: ListFlavor -> Text
toArgument :: ListFlavor -> Text
toArgument ListFlavor
Roman = Text
"1"
toArgument ListFlavor
ArabicUpper = Text
"I"
toArgument ListFlavor
ArabicLower = Text
"i"
toArgument ListFlavor
LatinUpper = Text
"A"
toArgument ListFlavor
LatinLower = Text
"a"
{-# INLINEABLE toArgument #-}
data ImagePosition where
ImageLeft :: ImagePosition
ImageRight :: ImagePosition
deriving (ImagePosition -> ImagePosition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImagePosition -> ImagePosition -> Bool
$c/= :: ImagePosition -> ImagePosition -> Bool
== :: ImagePosition -> ImagePosition -> Bool
$c== :: ImagePosition -> ImagePosition -> Bool
Eq, Int -> ImagePosition -> ShowS
[ImagePosition] -> ShowS
ImagePosition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImagePosition] -> ShowS
$cshowList :: [ImagePosition] -> ShowS
show :: ImagePosition -> String
$cshow :: ImagePosition -> String
showsPrec :: Int -> ImagePosition -> ShowS
$cshowsPrec :: Int -> ImagePosition -> ShowS
Show)
instance IsArgument ImagePosition where
toArgument :: ImagePosition -> Text
toArgument :: ImagePosition -> Text
toArgument ImagePosition
ImageLeft = Text
"left"
toArgument ImagePosition
ImageRight = Text
"right"
{-# INLINEABLE toArgument #-}
data BoxPosition where
BoxLeft :: BoxPosition
BoxCenter :: BoxPosition
BoxRight :: BoxPosition
deriving (BoxPosition -> BoxPosition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BoxPosition -> BoxPosition -> Bool
$c/= :: BoxPosition -> BoxPosition -> Bool
== :: BoxPosition -> BoxPosition -> Bool
$c== :: BoxPosition -> BoxPosition -> Bool
Eq, Int -> BoxPosition -> ShowS
[BoxPosition] -> ShowS
BoxPosition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BoxPosition] -> ShowS
$cshowList :: [BoxPosition] -> ShowS
show :: BoxPosition -> String
$cshow :: BoxPosition -> String
showsPrec :: Int -> BoxPosition -> ShowS
$cshowsPrec :: Int -> BoxPosition -> ShowS
Show)
instance IsArgument BoxPosition where
toArgument :: BoxPosition -> Text
toArgument :: BoxPosition -> Text
toArgument BoxPosition
BoxLeft = Text
"left"
toArgument BoxPosition
BoxCenter = Text
"center"
toArgument BoxPosition
BoxRight = Text
"right"
{-# INLINEABLE toArgument #-}
makePrisms ''BBCode
makePrisms ''AlignPosition
makePrisms ''ListFlavor
makePrisms ''ImagePosition
makePrisms ''El