{-# LANGUAGE PatternSynonyms #-}
{-# OPTIONS_HADDOCK not-home #-}
module Yamlet.Internal.Syntax
(
Document (..)
, YamlVersion (..)
, document
, Node (..)
, Content (.., ScalarContent)
, Props (..)
, noProps
, Tag (..)
, ScalarStyle (..)
, isBlockScalar
, CollectionStyle (..)
, contentNode
, scalarNode
, plainNode
, sequenceNode
, mappingNode
, Comments (..)
, noComments
, withComments
, Commented (..)
, Line (.., Comment)
, Offset (..)
, noOffset
, Located (..)
, copyDocument
, copyNode
, copyComments
) where
import Control.DeepSeq
import Data.Text qualified as T
import GHC.Generics
import Yamlet.Internal.Utils
data Document = Document
{ Document -> Maybe YamlVersion
version :: !(Maybe YamlVersion)
, Document -> Bool
explicitStart :: !Bool
, Document -> Bool
explicitEnd :: !Bool
, :: !Comments
, Document -> Node
root :: !Node
}
deriving stock (Document -> Document -> Bool
(Document -> Document -> Bool)
-> (Document -> Document -> Bool) -> Eq Document
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Document -> Document -> Bool
== :: Document -> Document -> Bool
$c/= :: Document -> Document -> Bool
/= :: Document -> Document -> Bool
Eq, Int -> Document -> ShowS
[Document] -> ShowS
Document -> String
(Int -> Document -> ShowS)
-> (Document -> String) -> ([Document] -> ShowS) -> Show Document
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Document -> ShowS
showsPrec :: Int -> Document -> ShowS
$cshow :: Document -> String
show :: Document -> String
$cshowList :: [Document] -> ShowS
showList :: [Document] -> ShowS
Show, (forall x. Document -> Rep Document x)
-> (forall x. Rep Document x -> Document) -> Generic Document
forall x. Rep Document x -> Document
forall x. Document -> Rep Document x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Document -> Rep Document x
from :: forall x. Document -> Rep Document x
$cto :: forall x. Rep Document x -> Document
to :: forall x. Rep Document x -> Document
Generic)
deriving anyclass (Document -> ()
(Document -> ()) -> NFData Document
forall a. (a -> ()) -> NFData a
$crnf :: Document -> ()
rnf :: Document -> ()
NFData)
data YamlVersion = YamlVersion
{ YamlVersion -> Int
major :: !Int
, YamlVersion -> Int
minor :: !Int
}
deriving stock (YamlVersion -> YamlVersion -> Bool
(YamlVersion -> YamlVersion -> Bool)
-> (YamlVersion -> YamlVersion -> Bool) -> Eq YamlVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: YamlVersion -> YamlVersion -> Bool
== :: YamlVersion -> YamlVersion -> Bool
$c/= :: YamlVersion -> YamlVersion -> Bool
/= :: YamlVersion -> YamlVersion -> Bool
Eq, Eq YamlVersion
Eq YamlVersion =>
(YamlVersion -> YamlVersion -> Ordering)
-> (YamlVersion -> YamlVersion -> Bool)
-> (YamlVersion -> YamlVersion -> Bool)
-> (YamlVersion -> YamlVersion -> Bool)
-> (YamlVersion -> YamlVersion -> Bool)
-> (YamlVersion -> YamlVersion -> YamlVersion)
-> (YamlVersion -> YamlVersion -> YamlVersion)
-> Ord YamlVersion
YamlVersion -> YamlVersion -> Bool
YamlVersion -> YamlVersion -> Ordering
YamlVersion -> YamlVersion -> YamlVersion
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
$ccompare :: YamlVersion -> YamlVersion -> Ordering
compare :: YamlVersion -> YamlVersion -> Ordering
$c< :: YamlVersion -> YamlVersion -> Bool
< :: YamlVersion -> YamlVersion -> Bool
$c<= :: YamlVersion -> YamlVersion -> Bool
<= :: YamlVersion -> YamlVersion -> Bool
$c> :: YamlVersion -> YamlVersion -> Bool
> :: YamlVersion -> YamlVersion -> Bool
$c>= :: YamlVersion -> YamlVersion -> Bool
>= :: YamlVersion -> YamlVersion -> Bool
$cmax :: YamlVersion -> YamlVersion -> YamlVersion
max :: YamlVersion -> YamlVersion -> YamlVersion
$cmin :: YamlVersion -> YamlVersion -> YamlVersion
min :: YamlVersion -> YamlVersion -> YamlVersion
Ord, Int -> YamlVersion -> ShowS
[YamlVersion] -> ShowS
YamlVersion -> String
(Int -> YamlVersion -> ShowS)
-> (YamlVersion -> String)
-> ([YamlVersion] -> ShowS)
-> Show YamlVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> YamlVersion -> ShowS
showsPrec :: Int -> YamlVersion -> ShowS
$cshow :: YamlVersion -> String
show :: YamlVersion -> String
$cshowList :: [YamlVersion] -> ShowS
showList :: [YamlVersion] -> ShowS
Show, (forall x. YamlVersion -> Rep YamlVersion x)
-> (forall x. Rep YamlVersion x -> YamlVersion)
-> Generic YamlVersion
forall x. Rep YamlVersion x -> YamlVersion
forall x. YamlVersion -> Rep YamlVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. YamlVersion -> Rep YamlVersion x
from :: forall x. YamlVersion -> Rep YamlVersion x
$cto :: forall x. Rep YamlVersion x -> YamlVersion
to :: forall x. Rep YamlVersion x -> YamlVersion
Generic)
deriving anyclass (YamlVersion -> ()
(YamlVersion -> ()) -> NFData YamlVersion
forall a. (a -> ()) -> NFData a
$crnf :: YamlVersion -> ()
rnf :: YamlVersion -> ()
NFData)
document :: Node -> Document
document :: Node -> Document
document Node
n =
Document
{ version :: Maybe YamlVersion
version = Maybe YamlVersion
forall a. Maybe a
Nothing
, explicitStart :: Bool
explicitStart = Bool
False
, explicitEnd :: Bool
explicitEnd = Bool
False
, docComments :: Comments
docComments = Comments
noComments
, root :: Node
root = Node
n
}
data Node = Node
{ Node -> Offset
offset :: !Offset
, Node -> Offset
endOffset :: !Offset
, Node -> Props
props :: !Props
, :: !Comments
, Node -> Content
content :: !Content
}
deriving stock (Node -> Node -> Bool
(Node -> Node -> Bool) -> (Node -> Node -> Bool) -> Eq Node
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Node -> Node -> Bool
== :: Node -> Node -> Bool
$c/= :: Node -> Node -> Bool
/= :: Node -> Node -> Bool
Eq, Int -> Node -> ShowS
[Node] -> ShowS
Node -> String
(Int -> Node -> ShowS)
-> (Node -> String) -> ([Node] -> ShowS) -> Show Node
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Node -> ShowS
showsPrec :: Int -> Node -> ShowS
$cshow :: Node -> String
show :: Node -> String
$cshowList :: [Node] -> ShowS
showList :: [Node] -> ShowS
Show, (forall x. Node -> Rep Node x)
-> (forall x. Rep Node x -> Node) -> Generic Node
forall x. Rep Node x -> Node
forall x. Node -> Rep Node x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Node -> Rep Node x
from :: forall x. Node -> Rep Node x
$cto :: forall x. Rep Node x -> Node
to :: forall x. Rep Node x -> Node
Generic)
deriving anyclass (Node -> ()
(Node -> ()) -> NFData Node
forall a. (a -> ()) -> NFData a
$crnf :: Node -> ()
rnf :: Node -> ()
NFData)
data Content
=
ScalarLinesContent !ScalarStyle !T.Text ![Int]
| SequenceContent !CollectionStyle ![Node]
| MappingContent !CollectionStyle ![(Node, Node)]
|
AliasContent !T.Text
deriving stock (Content -> Content -> Bool
(Content -> Content -> Bool)
-> (Content -> Content -> Bool) -> Eq Content
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Content -> Content -> Bool
== :: Content -> Content -> Bool
$c/= :: Content -> Content -> Bool
/= :: Content -> Content -> Bool
Eq, Int -> Content -> ShowS
[Content] -> ShowS
Content -> String
(Int -> Content -> ShowS)
-> (Content -> String) -> ([Content] -> ShowS) -> Show Content
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Content -> ShowS
showsPrec :: Int -> Content -> ShowS
$cshow :: Content -> String
show :: Content -> String
$cshowList :: [Content] -> ShowS
showList :: [Content] -> ShowS
Show, (forall x. Content -> Rep Content x)
-> (forall x. Rep Content x -> Content) -> Generic Content
forall x. Rep Content x -> Content
forall x. Content -> Rep Content x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Content -> Rep Content x
from :: forall x. Content -> Rep Content x
$cto :: forall x. Rep Content x -> Content
to :: forall x. Rep Content x -> Content
Generic)
pattern ScalarContent :: ScalarStyle -> T.Text -> Content
pattern $bScalarContent :: ScalarStyle -> Text -> Content
$mScalarContent :: forall {r}.
Content -> (ScalarStyle -> Text -> r) -> ((# #) -> r) -> r
ScalarContent style t <- ScalarLinesContent style t _
where
ScalarContent ScalarStyle
style Text
t = ScalarStyle -> Text -> [Int] -> Content
ScalarLinesContent ScalarStyle
style Text
t []
{-# COMPLETE ScalarContent, SequenceContent, MappingContent, AliasContent #-}
instance NFData Content where
rnf :: Content -> ()
rnf = \case
ScalarLinesContent ScalarStyle
_ Text
_ [Int]
ls -> [Int] -> ()
forall a. NFData a => a -> ()
rnf [Int]
ls
SequenceContent CollectionStyle
_ [Node]
xs -> [Node] -> ()
forall a. NFData a => a -> ()
rnf [Node]
xs
MappingContent CollectionStyle
_ [(Node, Node)]
kvs -> [(Node, Node)] -> ()
forall a. NFData a => a -> ()
rnf [(Node, Node)]
kvs
AliasContent Text
_ -> ()
data Props = Props
{ Props -> Maybe Text
anchor :: !(Maybe T.Text)
, Props -> Tag
tag :: !Tag
}
deriving stock (Props -> Props -> Bool
(Props -> Props -> Bool) -> (Props -> Props -> Bool) -> Eq Props
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Props -> Props -> Bool
== :: Props -> Props -> Bool
$c/= :: Props -> Props -> Bool
/= :: Props -> Props -> Bool
Eq, Int -> Props -> ShowS
[Props] -> ShowS
Props -> String
(Int -> Props -> ShowS)
-> (Props -> String) -> ([Props] -> ShowS) -> Show Props
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Props -> ShowS
showsPrec :: Int -> Props -> ShowS
$cshow :: Props -> String
show :: Props -> String
$cshowList :: [Props] -> ShowS
showList :: [Props] -> ShowS
Show, (forall x. Props -> Rep Props x)
-> (forall x. Rep Props x -> Props) -> Generic Props
forall x. Rep Props x -> Props
forall x. Props -> Rep Props x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Props -> Rep Props x
from :: forall x. Props -> Rep Props x
$cto :: forall x. Rep Props x -> Props
to :: forall x. Rep Props x -> Props
Generic)
deriving anyclass (Props -> ()
(Props -> ()) -> NFData Props
forall a. (a -> ()) -> NFData a
$crnf :: Props -> ()
rnf :: Props -> ()
NFData)
noProps :: Props
noProps :: Props
noProps = Maybe Text -> Tag -> Props
Props Maybe Text
forall a. Maybe a
Nothing Tag
NoTag
data Tag
=
NoTag
|
NonSpecificTag
|
Tag !T.Text
deriving stock (Tag -> Tag -> Bool
(Tag -> Tag -> Bool) -> (Tag -> Tag -> Bool) -> Eq Tag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Tag -> Tag -> Bool
== :: Tag -> Tag -> Bool
$c/= :: Tag -> Tag -> Bool
/= :: Tag -> Tag -> Bool
Eq, Eq Tag
Eq Tag =>
(Tag -> Tag -> Ordering)
-> (Tag -> Tag -> Bool)
-> (Tag -> Tag -> Bool)
-> (Tag -> Tag -> Bool)
-> (Tag -> Tag -> Bool)
-> (Tag -> Tag -> Tag)
-> (Tag -> Tag -> Tag)
-> Ord Tag
Tag -> Tag -> Bool
Tag -> Tag -> Ordering
Tag -> Tag -> Tag
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
$ccompare :: Tag -> Tag -> Ordering
compare :: Tag -> Tag -> Ordering
$c< :: Tag -> Tag -> Bool
< :: Tag -> Tag -> Bool
$c<= :: Tag -> Tag -> Bool
<= :: Tag -> Tag -> Bool
$c> :: Tag -> Tag -> Bool
> :: Tag -> Tag -> Bool
$c>= :: Tag -> Tag -> Bool
>= :: Tag -> Tag -> Bool
$cmax :: Tag -> Tag -> Tag
max :: Tag -> Tag -> Tag
$cmin :: Tag -> Tag -> Tag
min :: Tag -> Tag -> Tag
Ord, Int -> Tag -> ShowS
[Tag] -> ShowS
Tag -> String
(Int -> Tag -> ShowS)
-> (Tag -> String) -> ([Tag] -> ShowS) -> Show Tag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Tag -> ShowS
showsPrec :: Int -> Tag -> ShowS
$cshow :: Tag -> String
show :: Tag -> String
$cshowList :: [Tag] -> ShowS
showList :: [Tag] -> ShowS
Show, (forall x. Tag -> Rep Tag x)
-> (forall x. Rep Tag x -> Tag) -> Generic Tag
forall x. Rep Tag x -> Tag
forall x. Tag -> Rep Tag x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Tag -> Rep Tag x
from :: forall x. Tag -> Rep Tag x
$cto :: forall x. Rep Tag x -> Tag
to :: forall x. Rep Tag x -> Tag
Generic)
instance NFData Tag where
rnf :: Tag -> ()
rnf = Tag -> ()
forall a. a -> ()
rwhnf
data ScalarStyle
= Plain
| SingleQuoted
| DoubleQuoted
| Literal
| Folded
deriving stock (ScalarStyle -> ScalarStyle -> Bool
(ScalarStyle -> ScalarStyle -> Bool)
-> (ScalarStyle -> ScalarStyle -> Bool) -> Eq ScalarStyle
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ScalarStyle -> ScalarStyle -> Bool
== :: ScalarStyle -> ScalarStyle -> Bool
$c/= :: ScalarStyle -> ScalarStyle -> Bool
/= :: ScalarStyle -> ScalarStyle -> Bool
Eq, Eq ScalarStyle
Eq ScalarStyle =>
(ScalarStyle -> ScalarStyle -> Ordering)
-> (ScalarStyle -> ScalarStyle -> Bool)
-> (ScalarStyle -> ScalarStyle -> Bool)
-> (ScalarStyle -> ScalarStyle -> Bool)
-> (ScalarStyle -> ScalarStyle -> Bool)
-> (ScalarStyle -> ScalarStyle -> ScalarStyle)
-> (ScalarStyle -> ScalarStyle -> ScalarStyle)
-> Ord ScalarStyle
ScalarStyle -> ScalarStyle -> Bool
ScalarStyle -> ScalarStyle -> Ordering
ScalarStyle -> ScalarStyle -> ScalarStyle
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
$ccompare :: ScalarStyle -> ScalarStyle -> Ordering
compare :: ScalarStyle -> ScalarStyle -> Ordering
$c< :: ScalarStyle -> ScalarStyle -> Bool
< :: ScalarStyle -> ScalarStyle -> Bool
$c<= :: ScalarStyle -> ScalarStyle -> Bool
<= :: ScalarStyle -> ScalarStyle -> Bool
$c> :: ScalarStyle -> ScalarStyle -> Bool
> :: ScalarStyle -> ScalarStyle -> Bool
$c>= :: ScalarStyle -> ScalarStyle -> Bool
>= :: ScalarStyle -> ScalarStyle -> Bool
$cmax :: ScalarStyle -> ScalarStyle -> ScalarStyle
max :: ScalarStyle -> ScalarStyle -> ScalarStyle
$cmin :: ScalarStyle -> ScalarStyle -> ScalarStyle
min :: ScalarStyle -> ScalarStyle -> ScalarStyle
Ord, Int -> ScalarStyle -> ShowS
[ScalarStyle] -> ShowS
ScalarStyle -> String
(Int -> ScalarStyle -> ShowS)
-> (ScalarStyle -> String)
-> ([ScalarStyle] -> ShowS)
-> Show ScalarStyle
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ScalarStyle -> ShowS
showsPrec :: Int -> ScalarStyle -> ShowS
$cshow :: ScalarStyle -> String
show :: ScalarStyle -> String
$cshowList :: [ScalarStyle] -> ShowS
showList :: [ScalarStyle] -> ShowS
Show, Int -> ScalarStyle
ScalarStyle -> Int
ScalarStyle -> [ScalarStyle]
ScalarStyle -> ScalarStyle
ScalarStyle -> ScalarStyle -> [ScalarStyle]
ScalarStyle -> ScalarStyle -> ScalarStyle -> [ScalarStyle]
(ScalarStyle -> ScalarStyle)
-> (ScalarStyle -> ScalarStyle)
-> (Int -> ScalarStyle)
-> (ScalarStyle -> Int)
-> (ScalarStyle -> [ScalarStyle])
-> (ScalarStyle -> ScalarStyle -> [ScalarStyle])
-> (ScalarStyle -> ScalarStyle -> [ScalarStyle])
-> (ScalarStyle -> ScalarStyle -> ScalarStyle -> [ScalarStyle])
-> Enum ScalarStyle
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: ScalarStyle -> ScalarStyle
succ :: ScalarStyle -> ScalarStyle
$cpred :: ScalarStyle -> ScalarStyle
pred :: ScalarStyle -> ScalarStyle
$ctoEnum :: Int -> ScalarStyle
toEnum :: Int -> ScalarStyle
$cfromEnum :: ScalarStyle -> Int
fromEnum :: ScalarStyle -> Int
$cenumFrom :: ScalarStyle -> [ScalarStyle]
enumFrom :: ScalarStyle -> [ScalarStyle]
$cenumFromThen :: ScalarStyle -> ScalarStyle -> [ScalarStyle]
enumFromThen :: ScalarStyle -> ScalarStyle -> [ScalarStyle]
$cenumFromTo :: ScalarStyle -> ScalarStyle -> [ScalarStyle]
enumFromTo :: ScalarStyle -> ScalarStyle -> [ScalarStyle]
$cenumFromThenTo :: ScalarStyle -> ScalarStyle -> ScalarStyle -> [ScalarStyle]
enumFromThenTo :: ScalarStyle -> ScalarStyle -> ScalarStyle -> [ScalarStyle]
Enum, ScalarStyle
ScalarStyle -> ScalarStyle -> Bounded ScalarStyle
forall a. a -> a -> Bounded a
$cminBound :: ScalarStyle
minBound :: ScalarStyle
$cmaxBound :: ScalarStyle
maxBound :: ScalarStyle
Bounded, (forall x. ScalarStyle -> Rep ScalarStyle x)
-> (forall x. Rep ScalarStyle x -> ScalarStyle)
-> Generic ScalarStyle
forall x. Rep ScalarStyle x -> ScalarStyle
forall x. ScalarStyle -> Rep ScalarStyle x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ScalarStyle -> Rep ScalarStyle x
from :: forall x. ScalarStyle -> Rep ScalarStyle x
$cto :: forall x. Rep ScalarStyle x -> ScalarStyle
to :: forall x. Rep ScalarStyle x -> ScalarStyle
Generic)
instance NFData ScalarStyle where
rnf :: ScalarStyle -> ()
rnf = ScalarStyle -> ()
forall a. a -> ()
rwhnf
isBlockScalar :: ScalarStyle -> Bool
isBlockScalar :: ScalarStyle -> Bool
isBlockScalar ScalarStyle
s = ScalarStyle
s ScalarStyle -> ScalarStyle -> Bool
forall a. Eq a => a -> a -> Bool
== ScalarStyle
Literal Bool -> Bool -> Bool
|| ScalarStyle
s ScalarStyle -> ScalarStyle -> Bool
forall a. Eq a => a -> a -> Bool
== ScalarStyle
Folded
data CollectionStyle
= Block
| Flow
deriving stock (CollectionStyle -> CollectionStyle -> Bool
(CollectionStyle -> CollectionStyle -> Bool)
-> (CollectionStyle -> CollectionStyle -> Bool)
-> Eq CollectionStyle
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CollectionStyle -> CollectionStyle -> Bool
== :: CollectionStyle -> CollectionStyle -> Bool
$c/= :: CollectionStyle -> CollectionStyle -> Bool
/= :: CollectionStyle -> CollectionStyle -> Bool
Eq, Eq CollectionStyle
Eq CollectionStyle =>
(CollectionStyle -> CollectionStyle -> Ordering)
-> (CollectionStyle -> CollectionStyle -> Bool)
-> (CollectionStyle -> CollectionStyle -> Bool)
-> (CollectionStyle -> CollectionStyle -> Bool)
-> (CollectionStyle -> CollectionStyle -> Bool)
-> (CollectionStyle -> CollectionStyle -> CollectionStyle)
-> (CollectionStyle -> CollectionStyle -> CollectionStyle)
-> Ord CollectionStyle
CollectionStyle -> CollectionStyle -> Bool
CollectionStyle -> CollectionStyle -> Ordering
CollectionStyle -> CollectionStyle -> CollectionStyle
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
$ccompare :: CollectionStyle -> CollectionStyle -> Ordering
compare :: CollectionStyle -> CollectionStyle -> Ordering
$c< :: CollectionStyle -> CollectionStyle -> Bool
< :: CollectionStyle -> CollectionStyle -> Bool
$c<= :: CollectionStyle -> CollectionStyle -> Bool
<= :: CollectionStyle -> CollectionStyle -> Bool
$c> :: CollectionStyle -> CollectionStyle -> Bool
> :: CollectionStyle -> CollectionStyle -> Bool
$c>= :: CollectionStyle -> CollectionStyle -> Bool
>= :: CollectionStyle -> CollectionStyle -> Bool
$cmax :: CollectionStyle -> CollectionStyle -> CollectionStyle
max :: CollectionStyle -> CollectionStyle -> CollectionStyle
$cmin :: CollectionStyle -> CollectionStyle -> CollectionStyle
min :: CollectionStyle -> CollectionStyle -> CollectionStyle
Ord, Int -> CollectionStyle -> ShowS
[CollectionStyle] -> ShowS
CollectionStyle -> String
(Int -> CollectionStyle -> ShowS)
-> (CollectionStyle -> String)
-> ([CollectionStyle] -> ShowS)
-> Show CollectionStyle
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CollectionStyle -> ShowS
showsPrec :: Int -> CollectionStyle -> ShowS
$cshow :: CollectionStyle -> String
show :: CollectionStyle -> String
$cshowList :: [CollectionStyle] -> ShowS
showList :: [CollectionStyle] -> ShowS
Show, Int -> CollectionStyle
CollectionStyle -> Int
CollectionStyle -> [CollectionStyle]
CollectionStyle -> CollectionStyle
CollectionStyle -> CollectionStyle -> [CollectionStyle]
CollectionStyle
-> CollectionStyle -> CollectionStyle -> [CollectionStyle]
(CollectionStyle -> CollectionStyle)
-> (CollectionStyle -> CollectionStyle)
-> (Int -> CollectionStyle)
-> (CollectionStyle -> Int)
-> (CollectionStyle -> [CollectionStyle])
-> (CollectionStyle -> CollectionStyle -> [CollectionStyle])
-> (CollectionStyle -> CollectionStyle -> [CollectionStyle])
-> (CollectionStyle
-> CollectionStyle -> CollectionStyle -> [CollectionStyle])
-> Enum CollectionStyle
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: CollectionStyle -> CollectionStyle
succ :: CollectionStyle -> CollectionStyle
$cpred :: CollectionStyle -> CollectionStyle
pred :: CollectionStyle -> CollectionStyle
$ctoEnum :: Int -> CollectionStyle
toEnum :: Int -> CollectionStyle
$cfromEnum :: CollectionStyle -> Int
fromEnum :: CollectionStyle -> Int
$cenumFrom :: CollectionStyle -> [CollectionStyle]
enumFrom :: CollectionStyle -> [CollectionStyle]
$cenumFromThen :: CollectionStyle -> CollectionStyle -> [CollectionStyle]
enumFromThen :: CollectionStyle -> CollectionStyle -> [CollectionStyle]
$cenumFromTo :: CollectionStyle -> CollectionStyle -> [CollectionStyle]
enumFromTo :: CollectionStyle -> CollectionStyle -> [CollectionStyle]
$cenumFromThenTo :: CollectionStyle
-> CollectionStyle -> CollectionStyle -> [CollectionStyle]
enumFromThenTo :: CollectionStyle
-> CollectionStyle -> CollectionStyle -> [CollectionStyle]
Enum, CollectionStyle
CollectionStyle -> CollectionStyle -> Bounded CollectionStyle
forall a. a -> a -> Bounded a
$cminBound :: CollectionStyle
minBound :: CollectionStyle
$cmaxBound :: CollectionStyle
maxBound :: CollectionStyle
Bounded, (forall x. CollectionStyle -> Rep CollectionStyle x)
-> (forall x. Rep CollectionStyle x -> CollectionStyle)
-> Generic CollectionStyle
forall x. Rep CollectionStyle x -> CollectionStyle
forall x. CollectionStyle -> Rep CollectionStyle x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CollectionStyle -> Rep CollectionStyle x
from :: forall x. CollectionStyle -> Rep CollectionStyle x
$cto :: forall x. Rep CollectionStyle x -> CollectionStyle
to :: forall x. Rep CollectionStyle x -> CollectionStyle
Generic)
instance NFData CollectionStyle where
rnf :: CollectionStyle -> ()
rnf = CollectionStyle -> ()
forall a. a -> ()
rwhnf
contentNode :: Content -> Node
contentNode :: Content -> Node
contentNode Content
c =
Node
{ offset :: Offset
offset = Offset
noOffset
, endOffset :: Offset
endOffset = Offset
noOffset
, props :: Props
props = Props
noProps
, comments :: Comments
comments = Comments
noComments
, content :: Content
content = Content
c
}
scalarNode :: ScalarStyle -> T.Text -> Node
scalarNode :: ScalarStyle -> Text -> Node
scalarNode ScalarStyle
style = Content -> Node
contentNode (Content -> Node) -> (Text -> Content) -> Text -> Node
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ScalarStyle -> Text -> Content
ScalarContent ScalarStyle
style
plainNode :: T.Text -> Node
plainNode :: Text -> Node
plainNode = ScalarStyle -> Text -> Node
scalarNode ScalarStyle
Plain
sequenceNode :: [Node] -> Node
sequenceNode :: [Node] -> Node
sequenceNode = Content -> Node
contentNode (Content -> Node) -> ([Node] -> Content) -> [Node] -> Node
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CollectionStyle -> [Node] -> Content
SequenceContent CollectionStyle
Block
mappingNode :: [(Node, Node)] -> Node
mappingNode :: [(Node, Node)] -> Node
mappingNode = Content -> Node
contentNode (Content -> Node)
-> ([(Node, Node)] -> Content) -> [(Node, Node)] -> Node
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CollectionStyle -> [(Node, Node)] -> Content
MappingContent CollectionStyle
Block
data =
{ Comments -> [Line]
before :: ![Line]
, Comments -> Maybe Text
inline :: !(Maybe T.Text)
, Comments -> [Line]
after :: ![Line]
}
deriving stock (Comments -> Comments -> Bool
(Comments -> Comments -> Bool)
-> (Comments -> Comments -> Bool) -> Eq Comments
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Comments -> Comments -> Bool
== :: Comments -> Comments -> Bool
$c/= :: Comments -> Comments -> Bool
/= :: Comments -> Comments -> Bool
Eq, Eq Comments
Eq Comments =>
(Comments -> Comments -> Ordering)
-> (Comments -> Comments -> Bool)
-> (Comments -> Comments -> Bool)
-> (Comments -> Comments -> Bool)
-> (Comments -> Comments -> Bool)
-> (Comments -> Comments -> Comments)
-> (Comments -> Comments -> Comments)
-> Ord Comments
Comments -> Comments -> Bool
Comments -> Comments -> Ordering
Comments -> Comments -> Comments
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
$ccompare :: Comments -> Comments -> Ordering
compare :: Comments -> Comments -> Ordering
$c< :: Comments -> Comments -> Bool
< :: Comments -> Comments -> Bool
$c<= :: Comments -> Comments -> Bool
<= :: Comments -> Comments -> Bool
$c> :: Comments -> Comments -> Bool
> :: Comments -> Comments -> Bool
$c>= :: Comments -> Comments -> Bool
>= :: Comments -> Comments -> Bool
$cmax :: Comments -> Comments -> Comments
max :: Comments -> Comments -> Comments
$cmin :: Comments -> Comments -> Comments
min :: Comments -> Comments -> Comments
Ord, Int -> Comments -> ShowS
[Comments] -> ShowS
Comments -> String
(Int -> Comments -> ShowS)
-> (Comments -> String) -> ([Comments] -> ShowS) -> Show Comments
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Comments -> ShowS
showsPrec :: Int -> Comments -> ShowS
$cshow :: Comments -> String
show :: Comments -> String
$cshowList :: [Comments] -> ShowS
showList :: [Comments] -> ShowS
Show, (forall x. Comments -> Rep Comments x)
-> (forall x. Rep Comments x -> Comments) -> Generic Comments
forall x. Rep Comments x -> Comments
forall x. Comments -> Rep Comments x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Comments -> Rep Comments x
from :: forall x. Comments -> Rep Comments x
$cto :: forall x. Rep Comments x -> Comments
to :: forall x. Rep Comments x -> Comments
Generic)
deriving anyclass (Comments -> ()
(Comments -> ()) -> NFData Comments
forall a. (a -> ()) -> NFData a
$crnf :: Comments -> ()
rnf :: Comments -> ()
NFData)
noComments :: Comments
= Comments {before :: [Line]
before = [], inline :: Maybe Text
inline = Maybe Text
forall a. Maybe a
Nothing, after :: [Line]
after = []}
withComments :: Comments -> Node -> Node
Comments
c Node
n =
Node
{ offset :: Offset
offset = Node
n.offset
, endOffset :: Offset
endOffset = Node
n.endOffset
, props :: Props
props = Node
n.props
, comments :: Comments
comments = Comments
c
, content :: Content
content = Node
n.content
}
data a =
{ forall a. Commented a -> a
value :: !a
, :: !Comments
}
deriving stock (Commented a -> Commented a -> Bool
(Commented a -> Commented a -> Bool)
-> (Commented a -> Commented a -> Bool) -> Eq (Commented a)
forall a. Eq a => Commented a -> Commented a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => Commented a -> Commented a -> Bool
== :: Commented a -> Commented a -> Bool
$c/= :: forall a. Eq a => Commented a -> Commented a -> Bool
/= :: Commented a -> Commented a -> Bool
Eq, Eq (Commented a)
Eq (Commented a) =>
(Commented a -> Commented a -> Ordering)
-> (Commented a -> Commented a -> Bool)
-> (Commented a -> Commented a -> Bool)
-> (Commented a -> Commented a -> Bool)
-> (Commented a -> Commented a -> Bool)
-> (Commented a -> Commented a -> Commented a)
-> (Commented a -> Commented a -> Commented a)
-> Ord (Commented a)
Commented a -> Commented a -> Bool
Commented a -> Commented a -> Ordering
Commented a -> Commented a -> Commented a
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
forall a. Ord a => Eq (Commented a)
forall a. Ord a => Commented a -> Commented a -> Bool
forall a. Ord a => Commented a -> Commented a -> Ordering
forall a. Ord a => Commented a -> Commented a -> Commented a
$ccompare :: forall a. Ord a => Commented a -> Commented a -> Ordering
compare :: Commented a -> Commented a -> Ordering
$c< :: forall a. Ord a => Commented a -> Commented a -> Bool
< :: Commented a -> Commented a -> Bool
$c<= :: forall a. Ord a => Commented a -> Commented a -> Bool
<= :: Commented a -> Commented a -> Bool
$c> :: forall a. Ord a => Commented a -> Commented a -> Bool
> :: Commented a -> Commented a -> Bool
$c>= :: forall a. Ord a => Commented a -> Commented a -> Bool
>= :: Commented a -> Commented a -> Bool
$cmax :: forall a. Ord a => Commented a -> Commented a -> Commented a
max :: Commented a -> Commented a -> Commented a
$cmin :: forall a. Ord a => Commented a -> Commented a -> Commented a
min :: Commented a -> Commented a -> Commented a
Ord, Int -> Commented a -> ShowS
[Commented a] -> ShowS
Commented a -> String
(Int -> Commented a -> ShowS)
-> (Commented a -> String)
-> ([Commented a] -> ShowS)
-> Show (Commented a)
forall a. Show a => Int -> Commented a -> ShowS
forall a. Show a => [Commented a] -> ShowS
forall a. Show a => Commented a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> Commented a -> ShowS
showsPrec :: Int -> Commented a -> ShowS
$cshow :: forall a. Show a => Commented a -> String
show :: Commented a -> String
$cshowList :: forall a. Show a => [Commented a] -> ShowS
showList :: [Commented a] -> ShowS
Show, (forall a b. (a -> b) -> Commented a -> Commented b)
-> (forall a b. a -> Commented b -> Commented a)
-> Functor Commented
forall a b. a -> Commented b -> Commented a
forall a b. (a -> b) -> Commented a -> Commented b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> Commented a -> Commented b
fmap :: forall a b. (a -> b) -> Commented a -> Commented b
$c<$ :: forall a b. a -> Commented b -> Commented a
<$ :: forall a b. a -> Commented b -> Commented a
Functor, (forall m. Monoid m => Commented m -> m)
-> (forall m a. Monoid m => (a -> m) -> Commented a -> m)
-> (forall m a. Monoid m => (a -> m) -> Commented a -> m)
-> (forall a b. (a -> b -> b) -> b -> Commented a -> b)
-> (forall a b. (a -> b -> b) -> b -> Commented a -> b)
-> (forall b a. (b -> a -> b) -> b -> Commented a -> b)
-> (forall b a. (b -> a -> b) -> b -> Commented a -> b)
-> (forall a. (a -> a -> a) -> Commented a -> a)
-> (forall a. (a -> a -> a) -> Commented a -> a)
-> (forall a. Commented a -> [a])
-> (forall a. Commented a -> Bool)
-> (forall a. Commented a -> Int)
-> (forall a. Eq a => a -> Commented a -> Bool)
-> (forall a. Ord a => Commented a -> a)
-> (forall a. Ord a => Commented a -> a)
-> (forall a. Num a => Commented a -> a)
-> (forall a. Num a => Commented a -> a)
-> Foldable Commented
forall a. Eq a => a -> Commented a -> Bool
forall a. Num a => Commented a -> a
forall a. Ord a => Commented a -> a
forall m. Monoid m => Commented m -> m
forall a. Commented a -> Bool
forall a. Commented a -> Int
forall a. Commented a -> [a]
forall a. (a -> a -> a) -> Commented a -> a
forall m a. Monoid m => (a -> m) -> Commented a -> m
forall b a. (b -> a -> b) -> b -> Commented a -> b
forall a b. (a -> b -> b) -> b -> Commented a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall m. Monoid m => Commented m -> m
fold :: forall m. Monoid m => Commented m -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Commented a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Commented a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Commented a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> Commented a -> m
$cfoldr :: forall a b. (a -> b -> b) -> b -> Commented a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Commented a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Commented a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Commented a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Commented a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Commented a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Commented a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> Commented a -> b
$cfoldr1 :: forall a. (a -> a -> a) -> Commented a -> a
foldr1 :: forall a. (a -> a -> a) -> Commented a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Commented a -> a
foldl1 :: forall a. (a -> a -> a) -> Commented a -> a
$ctoList :: forall a. Commented a -> [a]
toList :: forall a. Commented a -> [a]
$cnull :: forall a. Commented a -> Bool
null :: forall a. Commented a -> Bool
$clength :: forall a. Commented a -> Int
length :: forall a. Commented a -> Int
$celem :: forall a. Eq a => a -> Commented a -> Bool
elem :: forall a. Eq a => a -> Commented a -> Bool
$cmaximum :: forall a. Ord a => Commented a -> a
maximum :: forall a. Ord a => Commented a -> a
$cminimum :: forall a. Ord a => Commented a -> a
minimum :: forall a. Ord a => Commented a -> a
$csum :: forall a. Num a => Commented a -> a
sum :: forall a. Num a => Commented a -> a
$cproduct :: forall a. Num a => Commented a -> a
product :: forall a. Num a => Commented a -> a
Foldable, Functor Commented
Foldable Commented
(Functor Commented, Foldable Commented) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Commented a -> f (Commented b))
-> (forall (f :: * -> *) a.
Applicative f =>
Commented (f a) -> f (Commented a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Commented a -> m (Commented b))
-> (forall (m :: * -> *) a.
Monad m =>
Commented (m a) -> m (Commented a))
-> Traversable Commented
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
Commented (m a) -> m (Commented a)
forall (f :: * -> *) a.
Applicative f =>
Commented (f a) -> f (Commented a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Commented a -> m (Commented b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Commented a -> f (Commented b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Commented a -> f (Commented b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Commented a -> f (Commented b)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
Commented (f a) -> f (Commented a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
Commented (f a) -> f (Commented a)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Commented a -> m (Commented b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Commented a -> m (Commented b)
$csequence :: forall (m :: * -> *) a.
Monad m =>
Commented (m a) -> m (Commented a)
sequence :: forall (m :: * -> *) a.
Monad m =>
Commented (m a) -> m (Commented a)
Traversable, (forall x. Commented a -> Rep (Commented a) x)
-> (forall x. Rep (Commented a) x -> Commented a)
-> Generic (Commented a)
forall x. Rep (Commented a) x -> Commented a
forall x. Commented a -> Rep (Commented a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Commented a) x -> Commented a
forall a x. Commented a -> Rep (Commented a) x
$cfrom :: forall a x. Commented a -> Rep (Commented a) x
from :: forall x. Commented a -> Rep (Commented a) x
$cto :: forall a x. Rep (Commented a) x -> Commented a
to :: forall x. Rep (Commented a) x -> Commented a
Generic)
deriving anyclass (Commented a -> ()
(Commented a -> ()) -> NFData (Commented a)
forall a. NFData a => Commented a -> ()
forall a. (a -> ()) -> NFData a
$crnf :: forall a. NFData a => Commented a -> ()
rnf :: Commented a -> ()
NFData)
data Located a = Located
{ forall a. Located a -> a
value :: !a
, forall a. Located a -> Offset
offset :: !Offset
}
deriving stock (Located a -> Located a -> Bool
(Located a -> Located a -> Bool)
-> (Located a -> Located a -> Bool) -> Eq (Located a)
forall a. Eq a => Located a -> Located a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => Located a -> Located a -> Bool
== :: Located a -> Located a -> Bool
$c/= :: forall a. Eq a => Located a -> Located a -> Bool
/= :: Located a -> Located a -> Bool
Eq, Eq (Located a)
Eq (Located a) =>
(Located a -> Located a -> Ordering)
-> (Located a -> Located a -> Bool)
-> (Located a -> Located a -> Bool)
-> (Located a -> Located a -> Bool)
-> (Located a -> Located a -> Bool)
-> (Located a -> Located a -> Located a)
-> (Located a -> Located a -> Located a)
-> Ord (Located a)
Located a -> Located a -> Bool
Located a -> Located a -> Ordering
Located a -> Located a -> Located a
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
forall a. Ord a => Eq (Located a)
forall a. Ord a => Located a -> Located a -> Bool
forall a. Ord a => Located a -> Located a -> Ordering
forall a. Ord a => Located a -> Located a -> Located a
$ccompare :: forall a. Ord a => Located a -> Located a -> Ordering
compare :: Located a -> Located a -> Ordering
$c< :: forall a. Ord a => Located a -> Located a -> Bool
< :: Located a -> Located a -> Bool
$c<= :: forall a. Ord a => Located a -> Located a -> Bool
<= :: Located a -> Located a -> Bool
$c> :: forall a. Ord a => Located a -> Located a -> Bool
> :: Located a -> Located a -> Bool
$c>= :: forall a. Ord a => Located a -> Located a -> Bool
>= :: Located a -> Located a -> Bool
$cmax :: forall a. Ord a => Located a -> Located a -> Located a
max :: Located a -> Located a -> Located a
$cmin :: forall a. Ord a => Located a -> Located a -> Located a
min :: Located a -> Located a -> Located a
Ord, Int -> Located a -> ShowS
[Located a] -> ShowS
Located a -> String
(Int -> Located a -> ShowS)
-> (Located a -> String)
-> ([Located a] -> ShowS)
-> Show (Located a)
forall a. Show a => Int -> Located a -> ShowS
forall a. Show a => [Located a] -> ShowS
forall a. Show a => Located a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> Located a -> ShowS
showsPrec :: Int -> Located a -> ShowS
$cshow :: forall a. Show a => Located a -> String
show :: Located a -> String
$cshowList :: forall a. Show a => [Located a] -> ShowS
showList :: [Located a] -> ShowS
Show, (forall a b. (a -> b) -> Located a -> Located b)
-> (forall a b. a -> Located b -> Located a) -> Functor Located
forall a b. a -> Located b -> Located a
forall a b. (a -> b) -> Located a -> Located b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> Located a -> Located b
fmap :: forall a b. (a -> b) -> Located a -> Located b
$c<$ :: forall a b. a -> Located b -> Located a
<$ :: forall a b. a -> Located b -> Located a
Functor, (forall m. Monoid m => Located m -> m)
-> (forall m a. Monoid m => (a -> m) -> Located a -> m)
-> (forall m a. Monoid m => (a -> m) -> Located a -> m)
-> (forall a b. (a -> b -> b) -> b -> Located a -> b)
-> (forall a b. (a -> b -> b) -> b -> Located a -> b)
-> (forall b a. (b -> a -> b) -> b -> Located a -> b)
-> (forall b a. (b -> a -> b) -> b -> Located a -> b)
-> (forall a. (a -> a -> a) -> Located a -> a)
-> (forall a. (a -> a -> a) -> Located a -> a)
-> (forall a. Located a -> [a])
-> (forall a. Located a -> Bool)
-> (forall a. Located a -> Int)
-> (forall a. Eq a => a -> Located a -> Bool)
-> (forall a. Ord a => Located a -> a)
-> (forall a. Ord a => Located a -> a)
-> (forall a. Num a => Located a -> a)
-> (forall a. Num a => Located a -> a)
-> Foldable Located
forall a. Eq a => a -> Located a -> Bool
forall a. Num a => Located a -> a
forall a. Ord a => Located a -> a
forall m. Monoid m => Located m -> m
forall a. Located a -> Bool
forall a. Located a -> Int
forall a. Located a -> [a]
forall a. (a -> a -> a) -> Located a -> a
forall m a. Monoid m => (a -> m) -> Located a -> m
forall b a. (b -> a -> b) -> b -> Located a -> b
forall a b. (a -> b -> b) -> b -> Located a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall m. Monoid m => Located m -> m
fold :: forall m. Monoid m => Located m -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Located a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Located a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Located a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> Located a -> m
$cfoldr :: forall a b. (a -> b -> b) -> b -> Located a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Located a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Located a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Located a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Located a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Located a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Located a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> Located a -> b
$cfoldr1 :: forall a. (a -> a -> a) -> Located a -> a
foldr1 :: forall a. (a -> a -> a) -> Located a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Located a -> a
foldl1 :: forall a. (a -> a -> a) -> Located a -> a
$ctoList :: forall a. Located a -> [a]
toList :: forall a. Located a -> [a]
$cnull :: forall a. Located a -> Bool
null :: forall a. Located a -> Bool
$clength :: forall a. Located a -> Int
length :: forall a. Located a -> Int
$celem :: forall a. Eq a => a -> Located a -> Bool
elem :: forall a. Eq a => a -> Located a -> Bool
$cmaximum :: forall a. Ord a => Located a -> a
maximum :: forall a. Ord a => Located a -> a
$cminimum :: forall a. Ord a => Located a -> a
minimum :: forall a. Ord a => Located a -> a
$csum :: forall a. Num a => Located a -> a
sum :: forall a. Num a => Located a -> a
$cproduct :: forall a. Num a => Located a -> a
product :: forall a. Num a => Located a -> a
Foldable, Functor Located
Foldable Located
(Functor Located, Foldable Located) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Located a -> f (Located b))
-> (forall (f :: * -> *) a.
Applicative f =>
Located (f a) -> f (Located a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Located a -> m (Located b))
-> (forall (m :: * -> *) a.
Monad m =>
Located (m a) -> m (Located a))
-> Traversable Located
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Located (m a) -> m (Located a)
forall (f :: * -> *) a.
Applicative f =>
Located (f a) -> f (Located a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Located a -> m (Located b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Located a -> f (Located b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Located a -> f (Located b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Located a -> f (Located b)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
Located (f a) -> f (Located a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
Located (f a) -> f (Located a)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Located a -> m (Located b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Located a -> m (Located b)
$csequence :: forall (m :: * -> *) a. Monad m => Located (m a) -> m (Located a)
sequence :: forall (m :: * -> *) a. Monad m => Located (m a) -> m (Located a)
Traversable, (forall x. Located a -> Rep (Located a) x)
-> (forall x. Rep (Located a) x -> Located a)
-> Generic (Located a)
forall x. Rep (Located a) x -> Located a
forall x. Located a -> Rep (Located a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Located a) x -> Located a
forall a x. Located a -> Rep (Located a) x
$cfrom :: forall a x. Located a -> Rep (Located a) x
from :: forall x. Located a -> Rep (Located a) x
$cto :: forall a x. Rep (Located a) x -> Located a
to :: forall x. Rep (Located a) x -> Located a
Generic)
deriving anyclass (Located a -> ()
(Located a -> ()) -> NFData (Located a)
forall a. NFData a => Located a -> ()
forall a. (a -> ()) -> NFData a
$crnf :: forall a. NFData a => Located a -> ()
rnf :: Located a -> ()
NFData)
data Line
= EmptyLine
|
!Int !T.Text
deriving stock (Line -> Line -> Bool
(Line -> Line -> Bool) -> (Line -> Line -> Bool) -> Eq Line
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Line -> Line -> Bool
== :: Line -> Line -> Bool
$c/= :: Line -> Line -> Bool
/= :: Line -> Line -> Bool
Eq, Eq Line
Eq Line =>
(Line -> Line -> Ordering)
-> (Line -> Line -> Bool)
-> (Line -> Line -> Bool)
-> (Line -> Line -> Bool)
-> (Line -> Line -> Bool)
-> (Line -> Line -> Line)
-> (Line -> Line -> Line)
-> Ord Line
Line -> Line -> Bool
Line -> Line -> Ordering
Line -> Line -> Line
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
$ccompare :: Line -> Line -> Ordering
compare :: Line -> Line -> Ordering
$c< :: Line -> Line -> Bool
< :: Line -> Line -> Bool
$c<= :: Line -> Line -> Bool
<= :: Line -> Line -> Bool
$c> :: Line -> Line -> Bool
> :: Line -> Line -> Bool
$c>= :: Line -> Line -> Bool
>= :: Line -> Line -> Bool
$cmax :: Line -> Line -> Line
max :: Line -> Line -> Line
$cmin :: Line -> Line -> Line
min :: Line -> Line -> Line
Ord, (forall x. Line -> Rep Line x)
-> (forall x. Rep Line x -> Line) -> Generic Line
forall x. Rep Line x -> Line
forall x. Line -> Rep Line x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Line -> Rep Line x
from :: forall x. Line -> Rep Line x
$cto :: forall x. Rep Line x -> Line
to :: forall x. Rep Line x -> Line
Generic)
pattern Comment :: T.Text -> Line
pattern t <- CommentLine _ t
where
Comment Text
t = Int -> Text -> Line
CommentLine Int
1 Text
t
{-# COMPLETE EmptyLine, Comment #-}
instance Show Line where
showsPrec :: Int -> Line -> ShowS
showsPrec Int
d = \case
Line
EmptyLine -> String -> ShowS
showString String
"EmptyLine"
CommentLine Int
1 Text
t -> Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"Comment " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Text -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 Text
t
CommentLine Int
n Text
t ->
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"CommentLine " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Int -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 Int
n ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
' ' ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Text -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 Text
t
instance NFData Line where
rnf :: Line -> ()
rnf = Line -> ()
forall a. a -> ()
rwhnf
newtype Offset = Offset Int
deriving stock ((forall x. Offset -> Rep Offset x)
-> (forall x. Rep Offset x -> Offset) -> Generic Offset
forall x. Rep Offset x -> Offset
forall x. Offset -> Rep Offset x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Offset -> Rep Offset x
from :: forall x. Offset -> Rep Offset x
$cto :: forall x. Rep Offset x -> Offset
to :: forall x. Rep Offset x -> Offset
Generic)
deriving newtype (Offset -> Offset -> Bool
(Offset -> Offset -> Bool)
-> (Offset -> Offset -> Bool) -> Eq Offset
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Offset -> Offset -> Bool
== :: Offset -> Offset -> Bool
$c/= :: Offset -> Offset -> Bool
/= :: Offset -> Offset -> Bool
Eq, Eq Offset
Eq Offset =>
(Offset -> Offset -> Ordering)
-> (Offset -> Offset -> Bool)
-> (Offset -> Offset -> Bool)
-> (Offset -> Offset -> Bool)
-> (Offset -> Offset -> Bool)
-> (Offset -> Offset -> Offset)
-> (Offset -> Offset -> Offset)
-> Ord Offset
Offset -> Offset -> Bool
Offset -> Offset -> Ordering
Offset -> Offset -> Offset
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
$ccompare :: Offset -> Offset -> Ordering
compare :: Offset -> Offset -> Ordering
$c< :: Offset -> Offset -> Bool
< :: Offset -> Offset -> Bool
$c<= :: Offset -> Offset -> Bool
<= :: Offset -> Offset -> Bool
$c> :: Offset -> Offset -> Bool
> :: Offset -> Offset -> Bool
$c>= :: Offset -> Offset -> Bool
>= :: Offset -> Offset -> Bool
$cmax :: Offset -> Offset -> Offset
max :: Offset -> Offset -> Offset
$cmin :: Offset -> Offset -> Offset
min :: Offset -> Offset -> Offset
Ord, Int -> Offset -> ShowS
[Offset] -> ShowS
Offset -> String
(Int -> Offset -> ShowS)
-> (Offset -> String) -> ([Offset] -> ShowS) -> Show Offset
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Offset -> ShowS
showsPrec :: Int -> Offset -> ShowS
$cshow :: Offset -> String
show :: Offset -> String
$cshowList :: [Offset] -> ShowS
showList :: [Offset] -> ShowS
Show, Offset -> ()
(Offset -> ()) -> NFData Offset
forall a. (a -> ()) -> NFData a
$crnf :: Offset -> ()
rnf :: Offset -> ()
NFData)
noOffset :: Offset
noOffset :: Offset
noOffset = Int -> Offset
Offset (-Int
1)
copyDocument :: Document -> Document
copyDocument :: Document -> Document
copyDocument Document
doc =
Document
doc
{ docComments = copyComments doc.docComments
, root = copyNode doc.root
}
copyNode :: Node -> Node
copyNode :: Node -> Node
copyNode Node
n =
Node
n
{ props = case n.props of
Props Maybe Text
Nothing (Tag Text
t) -> Maybe Text -> Tag -> Props
Props Maybe Text
forall a. Maybe a
Nothing (Text -> Tag
Tag (Text -> Text
T.copy Text
t))
Props Maybe Text
Nothing Tag
_ -> Node
n.props
Props Maybe Text
anchor Tag
tag ->
Props
{ anchor :: Maybe Text
anchor = Maybe Text -> Maybe Text
copyMaybe Maybe Text
anchor
, tag :: Tag
tag = case Tag
tag of
Tag Text
t -> Text -> Tag
Tag (Text -> Text
T.copy Text
t)
Tag
t -> Tag
t
}
, comments = case n.comments of
c :: Comments
c@(Comments [] Maybe Text
Nothing []) -> Comments
c
Comments
c -> Comments -> Comments
copyComments Comments
c
, content = case n.content of
ScalarLinesContent ScalarStyle
style Text
t [Int]
ls -> ScalarStyle -> Text -> [Int] -> Content
ScalarLinesContent ScalarStyle
style (Text -> Text
T.copy Text
t) [Int]
ls
SequenceContent CollectionStyle
style [Node]
xs -> CollectionStyle -> [Node] -> Content
SequenceContent CollectionStyle
style ((Node -> Node) -> [Node] -> [Node]
forall a b. (a -> b) -> [a] -> [b]
strictMap Node -> Node
copyNode [Node]
xs)
MappingContent CollectionStyle
style [(Node, Node)]
kvs ->
CollectionStyle -> [(Node, Node)] -> Content
MappingContent
CollectionStyle
style
(((Node, Node) -> (Node, Node)) -> [(Node, Node)] -> [(Node, Node)]
forall a b. (a -> b) -> [a] -> [b]
strictMap (\(Node
k, Node
v) -> Node -> Node -> (Node, Node)
forall a b. a -> b -> (a, b)
strictPair (Node -> Node
copyNode Node
k) (Node -> Node
copyNode Node
v)) [(Node, Node)]
kvs)
AliasContent Text
name -> Text -> Content
AliasContent (Text -> Text
T.copy Text
name)
}
copyComments :: Comments -> Comments
Comments
c = case Comments
c of
Comments [] Maybe Text
Nothing [] -> Comments
c
Comments
_ ->
Comments
{ before :: [Line]
before = (Line -> Line) -> [Line] -> [Line]
forall a b. (a -> b) -> [a] -> [b]
strictMap Line -> Line
copyLine Comments
c.before
, inline :: Maybe Text
inline = Maybe Text -> Maybe Text
copyMaybe Comments
c.inline
, after :: [Line]
after = (Line -> Line) -> [Line] -> [Line]
forall a b. (a -> b) -> [a] -> [b]
strictMap Line -> Line
copyLine Comments
c.after
}
where
copyLine :: Line -> Line
copyLine :: Line -> Line
copyLine = \case
CommentLine Int
n Text
t -> Int -> Text -> Line
CommentLine Int
n (Text -> Text
T.copy Text
t)
Line
EmptyLine -> Line
EmptyLine
copyMaybe :: Maybe T.Text -> Maybe T.Text
copyMaybe :: Maybe Text -> Maybe Text
copyMaybe = \case
Just Text
t -> Text -> Maybe Text
forall a. a -> Maybe a
Just (Text -> Maybe Text) -> Text -> Maybe Text
forall a b. (a -> b) -> a -> b
$! Text -> Text
T.copy Text
t
Maybe Text
Nothing -> Maybe Text
forall a. Maybe a
Nothing