{-# LANGUAGE CPP #-}
module Development.IDE.GHC.Dump(showAstDataHtml) where
import qualified Data.ByteString as B
import Data.Data hiding (Fixity)
import Development.IDE.GHC.Compat hiding (LocatedA,
NameAnn)
import Development.IDE.GHC.Compat.ExactPrint
import Development.IDE.GHC.Compat.Util
import Generics.SYB (ext1Q, ext2Q, extQ)
import GHC.Hs hiding (AnnLet)
import GHC.Hs.Dump
import GHC.Plugins hiding (AnnLet)
import Prelude hiding ((<>))
showAstDataHtml :: (Data a, ExactPrint a) => a -> SDoc
showAstDataHtml :: forall a. (Data a, ExactPrint a) => a -> SDoc
showAstDataHtml a
a0 = SDoc -> SDoc
html (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
SDoc
header SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$
SDoc -> SDoc
body ([(String, SDoc)] -> String -> SDoc -> SDoc
forall {doc}. IsLine doc => [(String, doc)] -> String -> doc -> doc
tag' [(String
"id",String -> SDoc
forall doc. IsLine doc => String -> doc
text (forall a. Show a => a -> String
show @String String
"myUL"))] String
"ul" (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat
[
SDoc -> SDoc
li (SDoc -> SDoc
pre (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ String -> SDoc
forall doc. IsLine doc => String -> doc
text (a -> String
forall ast. ExactPrint ast => ast -> String
exactPrint a
a0)),
SDoc -> SDoc
li (a -> SDoc
forall a. Data a => a -> SDoc
showAstDataHtml' a
a0),
SDoc -> SDoc
li (SDoc -> SDoc -> SDoc
nested SDoc
"Raw" (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ SDoc -> SDoc
pre (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ BlankSrcSpan -> BlankEpAnnotations -> a -> SDoc
forall a. Data a => BlankSrcSpan -> BlankEpAnnotations -> a -> SDoc
showAstData BlankSrcSpan
NoBlankSrcSpan BlankEpAnnotations
NoBlankEpAnnotations a
a0)
])
where
tag :: String -> SDoc -> SDoc
tag = [(String, SDoc)] -> String -> SDoc -> SDoc
forall {doc}. IsLine doc => [(String, doc)] -> String -> doc -> doc
tag' []
tag' :: [(String, doc)] -> String -> doc -> doc
tag' [(String, doc)]
attrs String
t doc
cont =
doc -> doc
forall doc. IsLine doc => doc -> doc
angleBrackets (String -> doc
forall doc. IsLine doc => String -> doc
text String
t doc -> doc -> doc
forall doc. IsLine doc => doc -> doc -> doc
<+> [doc] -> doc
forall doc. IsLine doc => [doc] -> doc
hcat [String -> doc
forall doc. IsLine doc => String -> doc
text String
adoc -> doc -> doc
forall doc. IsLine doc => doc -> doc -> doc
<>Char -> doc
forall doc. IsLine doc => Char -> doc
char Char
'=' doc -> doc -> doc
forall doc. IsLine doc => doc -> doc -> doc
<>doc
v | (String
a,doc
v) <- [(String, doc)]
attrs])
doc -> doc -> doc
forall doc. IsLine doc => doc -> doc -> doc
<> doc
cont
doc -> doc -> doc
forall doc. IsLine doc => doc -> doc -> doc
<> doc -> doc
forall doc. IsLine doc => doc -> doc
angleBrackets (Char -> doc
forall doc. IsLine doc => Char -> doc
char Char
'/' doc -> doc -> doc
forall doc. IsLine doc => doc -> doc -> doc
<> String -> doc
forall doc. IsLine doc => String -> doc
text String
t)
ul :: SDoc -> SDoc
ul = [(String, SDoc)] -> String -> SDoc -> SDoc
forall {doc}. IsLine doc => [(String, doc)] -> String -> doc -> doc
tag' [(String
"class", String -> SDoc
forall doc. IsLine doc => String -> doc
text (forall a. Show a => a -> String
show @String String
"nested"))] String
"ul"
li :: SDoc -> SDoc
li = String -> SDoc -> SDoc
tag String
"li"
caret :: doc -> doc
caret doc
x = [(String, doc)] -> String -> doc -> doc
forall {doc}. IsLine doc => [(String, doc)] -> String -> doc -> doc
tag' [(String
"class", String -> doc
forall doc. IsLine doc => String -> doc
text String
"caret")] String
"span" doc
"" doc -> doc -> doc
forall doc. IsLine doc => doc -> doc -> doc
<+> doc
x
nested :: SDoc -> SDoc -> SDoc
nested SDoc
foo SDoc
cts
#if !MIN_VERSION_ghc(9,3,0)
| cts == empty = foo
#endif
| Bool
otherwise = SDoc
foo SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ (SDoc -> SDoc
forall {doc}. (IsLine doc, IsString doc) => doc -> doc
caret (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ SDoc -> SDoc
ul SDoc
cts)
body :: SDoc -> SDoc
body SDoc
cts = String -> SDoc -> SDoc
tag String
"body" (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ SDoc
cts SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ String -> SDoc -> SDoc
tag String
"script" (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
js)
header :: SDoc
header = String -> SDoc -> SDoc
tag String
"head" (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ String -> SDoc -> SDoc
tag String
"style" (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ String -> SDoc
forall doc. IsLine doc => String -> doc
text String
css
html :: SDoc -> SDoc
html = String -> SDoc -> SDoc
tag String
"html"
pre :: SDoc -> SDoc
pre = String -> SDoc -> SDoc
tag String
"pre"
showAstDataHtml' :: Data a => a -> SDoc
showAstDataHtml' :: forall a. Data a => a -> SDoc
showAstDataHtml' =
a -> SDoc
forall a. Data a => a -> SDoc
generic
(a -> SDoc) -> (forall e. Data e => [e] -> SDoc) -> a -> SDoc
forall d (t :: * -> *) q.
(Data d, Typeable t) =>
(d -> q) -> (forall e. Data e => t e -> q) -> d -> q
`ext1Q` [e] -> SDoc
forall e. Data e => [e] -> SDoc
list
(a -> SDoc) -> (String -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` String -> SDoc
string (a -> SDoc) -> (FastString -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` FastString -> SDoc
fastString (a -> SDoc) -> (SrcSpan -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` SrcSpan -> SDoc
srcSpan (a -> SDoc) -> (RealSrcSpan -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` RealSrcSpan -> SDoc
realSrcSpan
(a -> SDoc) -> (EpAnn [AddEpAnn] -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` EpAnn [AddEpAnn] -> SDoc
annotation
(a -> SDoc) -> (EpAnn AnnsModule -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` EpAnn AnnsModule -> SDoc
annotationModule
(a -> SDoc) -> (EpAnn AddEpAnn -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` EpAnn AddEpAnn -> SDoc
annotationAddEpAnn
(a -> SDoc) -> (EpAnn GrhsAnn -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` EpAnn GrhsAnn -> SDoc
annotationGrhsAnn
(a -> SDoc) -> (EpAnn EpAnnHsCase -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` EpAnn EpAnnHsCase -> SDoc
annotationEpAnnHsCase
(a -> SDoc) -> (EpAnn NoEpAnns -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` EpAnn NoEpAnns -> SDoc
annotationEpAnnHsLet
(a -> SDoc) -> (EpAnn AnnList -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` EpAnn AnnList -> SDoc
annotationAnnList
(a -> SDoc) -> (EpAnn EpAnnImportDecl -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` EpAnn EpAnnImportDecl -> SDoc
annotationEpAnnImportDecl
(a -> SDoc) -> (EpAnn AnnParen -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` EpAnn AnnParen -> SDoc
annotationAnnParen
(a -> SDoc) -> (EpAnn TrailingAnn -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` EpAnn TrailingAnn -> SDoc
annotationTrailingAnn
(a -> SDoc) -> (EpAnn EpaLocation -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` EpAnn EpaLocation -> SDoc
annotationEpaLocation
(a -> SDoc) -> (AddEpAnn -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` AddEpAnn -> SDoc
addEpAnn
(a -> SDoc) -> (HsLit GhcPs -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` HsLit GhcPs -> SDoc
lit (a -> SDoc) -> (HsLit GhcRn -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` HsLit GhcRn -> SDoc
litr (a -> SDoc) -> (HsLit GhcTc -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` HsLit GhcTc -> SDoc
litt
(a -> SDoc) -> (SourceText -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` SourceText -> SDoc
sourceText
(a -> SDoc) -> (DeltaPos -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` DeltaPos -> SDoc
deltaPos
(a -> SDoc) -> (EpaLocation -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` EpaLocation -> SDoc
epaAnchor
(a -> SDoc) -> (AnchorOperation -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` AnchorOperation -> SDoc
anchorOp
(a -> SDoc) -> (ByteString -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` ByteString -> SDoc
bytestring
(a -> SDoc) -> (Name -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` Name -> SDoc
name (a -> SDoc) -> (OccName -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` OccName -> SDoc
forall {doc}. IsLine doc => OccName -> doc
occName (a -> SDoc) -> (ModuleName -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` ModuleName -> SDoc
moduleName (a -> SDoc) -> (Var -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` Var -> SDoc
var
(a -> SDoc) -> (DataCon -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` DataCon -> SDoc
dataCon
(a -> SDoc) -> (Bag (LocatedA (HsBind GhcRn)) -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` Bag (LocatedA (HsBind GhcRn)) -> SDoc
bagName (a -> SDoc) -> (Bag (LocatedA (HsBind GhcPs)) -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` Bag (LocatedA (HsBind GhcPs)) -> SDoc
bagRdrName (a -> SDoc) -> (Bag (LocatedA (HsBind GhcTc)) -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` Bag (LocatedA (HsBind GhcTc)) -> SDoc
bagVar (a -> SDoc) -> (NameSet -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` NameSet -> SDoc
nameSet
(a -> SDoc) -> (Fixity -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` Fixity -> SDoc
fixity
(a -> SDoc)
-> (forall d1 d2. (Data d1, Data d2) => GenLocated d1 d2 -> SDoc)
-> a
-> SDoc
forall d (t :: * -> * -> *) q.
(Data d, Typeable t) =>
(d -> q)
-> (forall d1 d2. (Data d1, Data d2) => t d1 d2 -> q) -> d -> q
`ext2Q` GenLocated d1 d2 -> SDoc
forall d1 d2. (Data d1, Data d2) => GenLocated d1 d2 -> SDoc
located
(a -> SDoc)
-> (SrcSpanAnn' (EpAnn AnnListItem) -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` SrcSpanAnn' (EpAnn AnnListItem) -> SDoc
srcSpanAnnA
(a -> SDoc) -> (SrcSpanAnn' (EpAnn AnnList) -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` SrcSpanAnn' (EpAnn AnnList) -> SDoc
srcSpanAnnL
(a -> SDoc) -> (SrcSpanAnn' (EpAnn AnnPragma) -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` SrcSpanAnn' (EpAnn AnnPragma) -> SDoc
srcSpanAnnP
(a -> SDoc)
-> (SrcSpanAnn' (EpAnn AnnContext) -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` SrcSpanAnn' (EpAnn AnnContext) -> SDoc
srcSpanAnnC
(a -> SDoc) -> (SrcSpanAnn' (EpAnn NameAnn) -> SDoc) -> a -> SDoc
forall a b r.
(Typeable a, Typeable b) =>
(a -> r) -> (b -> r) -> a -> r
`extQ` SrcSpanAnn' (EpAnn NameAnn) -> SDoc
srcSpanAnnN
where generic :: Data a => a -> SDoc
generic :: forall a. Data a => a -> SDoc
generic a
t = SDoc -> SDoc -> SDoc
nested (String -> SDoc
forall doc. IsLine doc => String -> doc
text (String -> SDoc) -> String -> SDoc
forall a b. (a -> b) -> a -> b
$ Constr -> String
showConstr (a -> Constr
forall a. Data a => a -> Constr
toConstr a
t))
([SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat ((forall a. Data a => a -> SDoc) -> a -> [SDoc]
forall a u. Data a => (forall d. Data d => d -> u) -> a -> [u]
forall u. (forall d. Data d => d -> u) -> a -> [u]
gmapQ (SDoc -> SDoc
li (SDoc -> SDoc) -> (d -> SDoc) -> d -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. d -> SDoc
forall a. Data a => a -> SDoc
showAstDataHtml') a
t))
string :: String -> SDoc
string :: String -> SDoc
string = String -> SDoc
forall doc. IsLine doc => String -> doc
text (String -> SDoc) -> (String -> String) -> String -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
normalize_newlines (String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
forall a. Show a => a -> String
show
fastString :: FastString -> SDoc
fastString :: FastString -> SDoc
fastString FastString
s = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"FastString:"
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
forall doc. IsLine doc => String -> doc
text (String -> String
normalize_newlines (String -> String)
-> (FastString -> String) -> FastString -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FastString -> String
forall a. Show a => a -> String
show (FastString -> String) -> FastString -> String
forall a b. (a -> b) -> a -> b
$ FastString
s)
bytestring :: B.ByteString -> SDoc
bytestring :: ByteString -> SDoc
bytestring = String -> SDoc
forall doc. IsLine doc => String -> doc
text (String -> SDoc) -> (ByteString -> String) -> ByteString -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
normalize_newlines (String -> String)
-> (ByteString -> String) -> ByteString -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> String
forall a. Show a => a -> String
show
list :: [a] -> SDoc
list [] = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
brackets SDoc
forall doc. IsOutput doc => doc
empty
list [a
x] = SDoc
"[]" SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ a -> SDoc
forall a. Data a => a -> SDoc
showAstDataHtml' a
x
list [a]
xs = SDoc -> SDoc -> SDoc
nested SDoc
"[]" ([SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat ([SDoc] -> SDoc) -> [SDoc] -> SDoc
forall a b. (a -> b) -> a -> b
$ (a -> SDoc) -> [a] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (SDoc -> SDoc
li (SDoc -> SDoc) -> (a -> SDoc) -> a -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> SDoc
forall a. Data a => a -> SDoc
showAstDataHtml') [a]
xs)
lit :: HsLit GhcPs -> SDoc
lit :: HsLit GhcPs -> SDoc
lit (HsWordPrim XHsWordPrim GhcPs
s Integer
x) = String -> Integer -> SourceText -> SDoc
numericLit String
"HsWord{64}Prim" Integer
x XHsWordPrim GhcPs
SourceText
s
lit (HsWord64Prim XHsWord64Prim GhcPs
s Integer
x) = String -> Integer -> SourceText -> SDoc
numericLit String
"HsWord{64}Prim" Integer
x XHsWord64Prim GhcPs
SourceText
s
lit (HsIntPrim XHsIntPrim GhcPs
s Integer
x) = String -> Integer -> SourceText -> SDoc
numericLit String
"HsInt{64}Prim" Integer
x XHsIntPrim GhcPs
SourceText
s
lit (HsInt64Prim XHsInt64Prim GhcPs
s Integer
x) = String -> Integer -> SourceText -> SDoc
numericLit String
"HsInt{64}Prim" Integer
x XHsInt64Prim GhcPs
SourceText
s
lit HsLit GhcPs
l = HsLit GhcPs -> SDoc
forall a. Data a => a -> SDoc
generic HsLit GhcPs
l
litr :: HsLit GhcRn -> SDoc
litr :: HsLit GhcRn -> SDoc
litr (HsWordPrim XHsWordPrim GhcRn
s Integer
x) = String -> Integer -> SourceText -> SDoc
numericLit String
"HsWord{64}Prim" Integer
x XHsWordPrim GhcRn
SourceText
s
litr (HsWord64Prim XHsWord64Prim GhcRn
s Integer
x) = String -> Integer -> SourceText -> SDoc
numericLit String
"HsWord{64}Prim" Integer
x XHsWord64Prim GhcRn
SourceText
s
litr (HsIntPrim XHsIntPrim GhcRn
s Integer
x) = String -> Integer -> SourceText -> SDoc
numericLit String
"HsInt{64}Prim" Integer
x XHsIntPrim GhcRn
SourceText
s
litr (HsInt64Prim XHsInt64Prim GhcRn
s Integer
x) = String -> Integer -> SourceText -> SDoc
numericLit String
"HsInt{64}Prim" Integer
x XHsInt64Prim GhcRn
SourceText
s
litr HsLit GhcRn
l = HsLit GhcRn -> SDoc
forall a. Data a => a -> SDoc
generic HsLit GhcRn
l
litt :: HsLit GhcTc -> SDoc
litt :: HsLit GhcTc -> SDoc
litt (HsWordPrim XHsWordPrim GhcTc
s Integer
x) = String -> Integer -> SourceText -> SDoc
numericLit String
"HsWord{64}Prim" Integer
x XHsWordPrim GhcTc
SourceText
s
litt (HsWord64Prim XHsWord64Prim GhcTc
s Integer
x) = String -> Integer -> SourceText -> SDoc
numericLit String
"HsWord{64}Prim" Integer
x XHsWord64Prim GhcTc
SourceText
s
litt (HsIntPrim XHsIntPrim GhcTc
s Integer
x) = String -> Integer -> SourceText -> SDoc
numericLit String
"HsInt{64}Prim" Integer
x XHsIntPrim GhcTc
SourceText
s
litt (HsInt64Prim XHsInt64Prim GhcTc
s Integer
x) = String -> Integer -> SourceText -> SDoc
numericLit String
"HsInt{64}Prim" Integer
x XHsInt64Prim GhcTc
SourceText
s
litt HsLit GhcTc
l = HsLit GhcTc -> SDoc
forall a. Data a => a -> SDoc
generic HsLit GhcTc
l
numericLit :: String -> Integer -> SourceText -> SDoc
numericLit :: String -> Integer -> SourceText -> SDoc
numericLit String
tag Integer
x SourceText
s = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [ String -> SDoc
forall doc. IsLine doc => String -> doc
text String
tag
, Integer -> SDoc
forall a. Data a => a -> SDoc
generic Integer
x
, SourceText -> SDoc
forall a. Data a => a -> SDoc
generic SourceText
s ]
sourceText :: SourceText -> SDoc
sourceText :: SourceText -> SDoc
sourceText SourceText
NoSourceText = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"NoSourceText"
#if MIN_VERSION_ghc(9,7,0)
sourceText (SourceText src) = text "SourceText" <+> ftext src
#else
sourceText (SourceText String
src) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"SourceText" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
src
#endif
epaAnchor :: EpaLocation -> SDoc
#if MIN_VERSION_ghc(9,5,0)
epaAnchor :: EpaLocation -> SDoc
epaAnchor (EpaSpan RealSrcSpan
r Maybe BufSpan
_) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"EpaSpan" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> RealSrcSpan -> SDoc
realSrcSpan RealSrcSpan
r
#else
epaAnchor (EpaSpan r) = text "EpaSpan" <+> realSrcSpan r
#endif
epaAnchor (EpaDelta DeltaPos
d [LEpaComment]
cs) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"EpaDelta" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> DeltaPos -> SDoc
deltaPos DeltaPos
d SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [LEpaComment] -> SDoc
forall a. Data a => a -> SDoc
showAstDataHtml' [LEpaComment]
cs
anchorOp :: AnchorOperation -> SDoc
anchorOp :: AnchorOperation -> SDoc
anchorOp AnchorOperation
UnchangedAnchor = SDoc
"UnchangedAnchor"
anchorOp (MovedAnchor DeltaPos
dp) = SDoc
"MovedAnchor " SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> DeltaPos -> SDoc
deltaPos DeltaPos
dp
deltaPos :: DeltaPos -> SDoc
deltaPos :: DeltaPos -> SDoc
deltaPos (SameLine Int
c) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"SameLine" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Int -> SDoc
forall a. Outputable a => a -> SDoc
ppr Int
c
deltaPos (DifferentLine Int
l Int
c) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"DifferentLine" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Int -> SDoc
forall a. Outputable a => a -> SDoc
ppr Int
l SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Int -> SDoc
forall a. Outputable a => a -> SDoc
ppr Int
c
name :: Name -> SDoc
name :: Name -> SDoc
name Name
nm = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Name:" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr Name
nm
occName :: OccName -> doc
occName OccName
n = doc -> doc
forall doc. IsLine doc => doc -> doc
braces (doc -> doc) -> doc -> doc
forall a b. (a -> b) -> a -> b
$
String -> doc
forall doc. IsLine doc => String -> doc
text String
"OccName:"
doc -> doc -> doc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> doc
forall doc. IsLine doc => String -> doc
text (OccName -> String
occNameString OccName
n)
moduleName :: ModuleName -> SDoc
moduleName :: ModuleName -> SDoc
moduleName ModuleName
m = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"ModuleName:" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> ModuleName -> SDoc
forall a. Outputable a => a -> SDoc
ppr ModuleName
m
srcSpan :: SrcSpan -> SDoc
srcSpan :: SrcSpan -> SDoc
srcSpan SrcSpan
ss = Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
' ' SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<>
SDoc -> Int -> SDoc -> SDoc
hang (SrcSpan -> SDoc
forall a. Outputable a => a -> SDoc
ppr SrcSpan
ss) Int
1
(String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"")
realSrcSpan :: RealSrcSpan -> SDoc
realSrcSpan :: RealSrcSpan -> SDoc
realSrcSpan RealSrcSpan
ss = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
' ' SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<>
SDoc -> Int -> SDoc -> SDoc
hang (RealSrcSpan -> SDoc
forall a. Outputable a => a -> SDoc
ppr RealSrcSpan
ss) Int
1
(String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"")
addEpAnn :: AddEpAnn -> SDoc
addEpAnn :: AddEpAnn -> SDoc
addEpAnn (AddEpAnn AnnKeywordId
a EpaLocation
s) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"AddEpAnn" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> AnnKeywordId -> SDoc
forall a. Outputable a => a -> SDoc
ppr AnnKeywordId
a SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> EpaLocation -> SDoc
epaAnchor EpaLocation
s
var :: Var -> SDoc
var :: Var -> SDoc
var Var
v = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Var:" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Var -> SDoc
forall a. Outputable a => a -> SDoc
ppr Var
v
dataCon :: DataCon -> SDoc
dataCon :: DataCon -> SDoc
dataCon DataCon
c = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"DataCon:" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> DataCon -> SDoc
forall a. Outputable a => a -> SDoc
ppr DataCon
c
bagRdrName:: Bag (LocatedA (HsBind GhcPs)) -> SDoc
bagRdrName :: Bag (LocatedA (HsBind GhcPs)) -> SDoc
bagRdrName Bag (LocatedA (HsBind GhcPs))
bg = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Bag(LocatedA (HsBind GhcPs)):"
SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ ([LocatedA (HsBind GhcPs)] -> SDoc
forall e. Data e => [e] -> SDoc
list ([LocatedA (HsBind GhcPs)] -> SDoc)
-> (Bag (LocatedA (HsBind GhcPs)) -> [LocatedA (HsBind GhcPs)])
-> Bag (LocatedA (HsBind GhcPs))
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bag (LocatedA (HsBind GhcPs)) -> [LocatedA (HsBind GhcPs)]
forall a. Bag a -> [a]
bagToList (Bag (LocatedA (HsBind GhcPs)) -> SDoc)
-> Bag (LocatedA (HsBind GhcPs)) -> SDoc
forall a b. (a -> b) -> a -> b
$ Bag (LocatedA (HsBind GhcPs))
bg)
bagName :: Bag (LocatedA (HsBind GhcRn)) -> SDoc
bagName :: Bag (LocatedA (HsBind GhcRn)) -> SDoc
bagName Bag (LocatedA (HsBind GhcRn))
bg = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Bag(LocatedA (HsBind Name)):"
SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ ([LocatedA (HsBind GhcRn)] -> SDoc
forall e. Data e => [e] -> SDoc
list ([LocatedA (HsBind GhcRn)] -> SDoc)
-> (Bag (LocatedA (HsBind GhcRn)) -> [LocatedA (HsBind GhcRn)])
-> Bag (LocatedA (HsBind GhcRn))
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bag (LocatedA (HsBind GhcRn)) -> [LocatedA (HsBind GhcRn)]
forall a. Bag a -> [a]
bagToList (Bag (LocatedA (HsBind GhcRn)) -> SDoc)
-> Bag (LocatedA (HsBind GhcRn)) -> SDoc
forall a b. (a -> b) -> a -> b
$ Bag (LocatedA (HsBind GhcRn))
bg)
bagVar :: Bag (LocatedA (HsBind GhcTc)) -> SDoc
bagVar :: Bag (LocatedA (HsBind GhcTc)) -> SDoc
bagVar Bag (LocatedA (HsBind GhcTc))
bg = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Bag(LocatedA (HsBind Var)):"
SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ ([LocatedA (HsBind GhcTc)] -> SDoc
forall e. Data e => [e] -> SDoc
list ([LocatedA (HsBind GhcTc)] -> SDoc)
-> (Bag (LocatedA (HsBind GhcTc)) -> [LocatedA (HsBind GhcTc)])
-> Bag (LocatedA (HsBind GhcTc))
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bag (LocatedA (HsBind GhcTc)) -> [LocatedA (HsBind GhcTc)]
forall a. Bag a -> [a]
bagToList (Bag (LocatedA (HsBind GhcTc)) -> SDoc)
-> Bag (LocatedA (HsBind GhcTc)) -> SDoc
forall a b. (a -> b) -> a -> b
$ Bag (LocatedA (HsBind GhcTc))
bg)
nameSet :: NameSet -> SDoc
nameSet NameSet
ns = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"NameSet:"
SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ ([Name] -> SDoc
forall e. Data e => [e] -> SDoc
list ([Name] -> SDoc) -> (NameSet -> [Name]) -> NameSet -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NameSet -> [Name]
nameSetElemsStable (NameSet -> SDoc) -> NameSet -> SDoc
forall a b. (a -> b) -> a -> b
$ NameSet
ns)
fixity :: Fixity -> SDoc
fixity :: Fixity -> SDoc
fixity Fixity
fx = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Fixity:"
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Fixity -> SDoc
forall a. Outputable a => a -> SDoc
ppr Fixity
fx
located :: (Data a, Data b) => GenLocated a b -> SDoc
located :: forall d1 d2. (Data d1, Data d2) => GenLocated d1 d2 -> SDoc
located (L a
ss b
a)
= SDoc -> SDoc -> SDoc
nested SDoc
"L" (SDoc -> SDoc
li (a -> SDoc
forall a. Data a => a -> SDoc
showAstDataHtml' a
ss) SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ SDoc -> SDoc
li (b -> SDoc
forall a. Data a => a -> SDoc
showAstDataHtml' b
a))
annotation :: EpAnn [AddEpAnn] -> SDoc
annotation :: EpAnn [AddEpAnn] -> SDoc
annotation = SDoc -> EpAnn [AddEpAnn] -> SDoc
forall a. Data a => SDoc -> EpAnn a -> SDoc
annotation' (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"EpAnn [AddEpAnn]")
annotationModule :: EpAnn AnnsModule -> SDoc
annotationModule :: EpAnn AnnsModule -> SDoc
annotationModule = SDoc -> EpAnn AnnsModule -> SDoc
forall a. Data a => SDoc -> EpAnn a -> SDoc
annotation' (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"EpAnn AnnsModule")
annotationAddEpAnn :: EpAnn AddEpAnn -> SDoc
annotationAddEpAnn :: EpAnn AddEpAnn -> SDoc
annotationAddEpAnn = SDoc -> EpAnn AddEpAnn -> SDoc
forall a. Data a => SDoc -> EpAnn a -> SDoc
annotation' (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"EpAnn AddEpAnn")
annotationGrhsAnn :: EpAnn GrhsAnn -> SDoc
annotationGrhsAnn :: EpAnn GrhsAnn -> SDoc
annotationGrhsAnn = SDoc -> EpAnn GrhsAnn -> SDoc
forall a. Data a => SDoc -> EpAnn a -> SDoc
annotation' (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"EpAnn GrhsAnn")
annotationEpAnnHsCase :: EpAnn EpAnnHsCase -> SDoc
annotationEpAnnHsCase :: EpAnn EpAnnHsCase -> SDoc
annotationEpAnnHsCase = SDoc -> EpAnn EpAnnHsCase -> SDoc
forall a. Data a => SDoc -> EpAnn a -> SDoc
annotation' (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"EpAnn EpAnnHsCase")
#if MIN_VERSION_ghc(9,4,0)
annotationEpAnnHsLet :: EpAnn NoEpAnns -> SDoc
annotationEpAnnHsLet :: EpAnn NoEpAnns -> SDoc
annotationEpAnnHsLet = SDoc -> EpAnn NoEpAnns -> SDoc
forall a. Data a => SDoc -> EpAnn a -> SDoc
annotation' (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"EpAnn NoEpAnns")
#else
annotationEpAnnHsLet :: EpAnn AnnsLet -> SDoc
annotationEpAnnHsLet = annotation' (text "EpAnn AnnsLet")
#endif
annotationAnnList :: EpAnn AnnList -> SDoc
annotationAnnList :: EpAnn AnnList -> SDoc
annotationAnnList = SDoc -> EpAnn AnnList -> SDoc
forall a. Data a => SDoc -> EpAnn a -> SDoc
annotation' (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"EpAnn AnnList")
annotationEpAnnImportDecl :: EpAnn EpAnnImportDecl -> SDoc
annotationEpAnnImportDecl :: EpAnn EpAnnImportDecl -> SDoc
annotationEpAnnImportDecl = SDoc -> EpAnn EpAnnImportDecl -> SDoc
forall a. Data a => SDoc -> EpAnn a -> SDoc
annotation' (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"EpAnn EpAnnImportDecl")
annotationAnnParen :: EpAnn AnnParen -> SDoc
annotationAnnParen :: EpAnn AnnParen -> SDoc
annotationAnnParen = SDoc -> EpAnn AnnParen -> SDoc
forall a. Data a => SDoc -> EpAnn a -> SDoc
annotation' (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"EpAnn AnnParen")
annotationTrailingAnn :: EpAnn TrailingAnn -> SDoc
annotationTrailingAnn :: EpAnn TrailingAnn -> SDoc
annotationTrailingAnn = SDoc -> EpAnn TrailingAnn -> SDoc
forall a. Data a => SDoc -> EpAnn a -> SDoc
annotation' (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"EpAnn TrailingAnn")
annotationEpaLocation :: EpAnn EpaLocation -> SDoc
annotationEpaLocation :: EpAnn EpaLocation -> SDoc
annotationEpaLocation = SDoc -> EpAnn EpaLocation -> SDoc
forall a. Data a => SDoc -> EpAnn a -> SDoc
annotation' (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"EpAnn EpaLocation")
annotation' :: forall a. Data a => SDoc -> EpAnn a -> SDoc
annotation' :: forall a. Data a => SDoc -> EpAnn a -> SDoc
annotation' SDoc
_tag EpAnn a
anns = SDoc -> SDoc -> SDoc
nested (String -> SDoc
forall doc. IsLine doc => String -> doc
text (String -> SDoc) -> String -> SDoc
forall a b. (a -> b) -> a -> b
$ Constr -> String
showConstr (EpAnn a -> Constr
forall a. Data a => a -> Constr
toConstr EpAnn a
anns))
([SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat ((SDoc -> SDoc) -> [SDoc] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map SDoc -> SDoc
li ([SDoc] -> [SDoc]) -> [SDoc] -> [SDoc]
forall a b. (a -> b) -> a -> b
$ (forall a. Data a => a -> SDoc) -> EpAnn a -> [SDoc]
forall a u. Data a => (forall d. Data d => d -> u) -> a -> [u]
forall u. (forall d. Data d => d -> u) -> EpAnn a -> [u]
gmapQ d -> SDoc
forall a. Data a => a -> SDoc
showAstDataHtml' EpAnn a
anns))
srcSpanAnnA :: SrcSpanAnn' (EpAnn AnnListItem) -> SDoc
srcSpanAnnA :: SrcSpanAnn' (EpAnn AnnListItem) -> SDoc
srcSpanAnnA = SDoc -> SrcSpanAnn' (EpAnn AnnListItem) -> SDoc
forall a. Data a => SDoc -> SrcSpanAnn' a -> SDoc
locatedAnn'' (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"SrcSpanAnnA")
srcSpanAnnL :: SrcSpanAnn' (EpAnn AnnList) -> SDoc
srcSpanAnnL :: SrcSpanAnn' (EpAnn AnnList) -> SDoc
srcSpanAnnL = SDoc -> SrcSpanAnn' (EpAnn AnnList) -> SDoc
forall a. Data a => SDoc -> SrcSpanAnn' a -> SDoc
locatedAnn'' (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"SrcSpanAnnL")
srcSpanAnnP :: SrcSpanAnn' (EpAnn AnnPragma) -> SDoc
srcSpanAnnP :: SrcSpanAnn' (EpAnn AnnPragma) -> SDoc
srcSpanAnnP = SDoc -> SrcSpanAnn' (EpAnn AnnPragma) -> SDoc
forall a. Data a => SDoc -> SrcSpanAnn' a -> SDoc
locatedAnn'' (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"SrcSpanAnnP")
srcSpanAnnC :: SrcSpanAnn' (EpAnn AnnContext) -> SDoc
srcSpanAnnC :: SrcSpanAnn' (EpAnn AnnContext) -> SDoc
srcSpanAnnC = SDoc -> SrcSpanAnn' (EpAnn AnnContext) -> SDoc
forall a. Data a => SDoc -> SrcSpanAnn' a -> SDoc
locatedAnn'' (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"SrcSpanAnnC")
srcSpanAnnN :: SrcSpanAnn' (EpAnn NameAnn) -> SDoc
srcSpanAnnN :: SrcSpanAnn' (EpAnn NameAnn) -> SDoc
srcSpanAnnN = SDoc -> SrcSpanAnn' (EpAnn NameAnn) -> SDoc
forall a. Data a => SDoc -> SrcSpanAnn' a -> SDoc
locatedAnn'' (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"SrcSpanAnnN")
locatedAnn'' :: forall a. Data a
=> SDoc -> SrcSpanAnn' a -> SDoc
locatedAnn'' :: forall a. Data a => SDoc -> SrcSpanAnn' a -> SDoc
locatedAnn'' SDoc
tag SrcSpanAnn' a
ss =
case SrcSpanAnn' a -> Maybe (SrcSpanAnn' a)
forall a b. (Typeable a, Typeable b) => a -> Maybe b
cast SrcSpanAnn' a
ss of
Just ((SrcSpanAnn a
ann SrcSpan
s) :: SrcSpanAnn' a) ->
SDoc -> SDoc -> SDoc
nested SDoc
"SrcSpanAnn" (
SDoc -> SDoc
li(a -> SDoc
forall a. Data a => a -> SDoc
showAstDataHtml' a
ann)
SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ SDoc -> SDoc
li(SrcSpan -> SDoc
srcSpan SrcSpan
s))
Maybe (SrcSpanAnn' a)
Nothing -> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"locatedAnn:unmatched" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
tag
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
forall doc. IsLine doc => String -> doc
text (Constr -> String
showConstr (SrcSpanAnn' a -> Constr
forall a. Data a => a -> Constr
toConstr SrcSpanAnn' a
ss))
normalize_newlines :: String -> String
normalize_newlines :: String -> String
normalize_newlines (Char
'\\':Char
'r':Char
'\\':Char
'n':String
xs) = Char
'\\'Char -> String -> String
forall a. a -> [a] -> [a]
:Char
'n'Char -> String -> String
forall a. a -> [a] -> [a]
:String -> String
normalize_newlines String
xs
normalize_newlines (Char
x:String
xs) = Char
xChar -> String -> String
forall a. a -> [a] -> [a]
:String -> String
normalize_newlines String
xs
normalize_newlines [] = []
css :: String
css :: String
css = [String] -> String
unlines
[ String
"body {background-color: black; color: white ;}"
, String
"/* Remove default bullets */"
, String
"ul, #myUL {"
, String
" list-style-type: none;"
, String
"}"
, String
"/* Remove margins and padding from the parent ul */"
, String
"#myUL {"
, String
" margin: 0; "
, String
" padding: 0; "
, String
"} "
, String
"/* Style the caret/arrow */ "
, String
".caret { "
, String
" cursor: pointer; "
, String
" user-select: none; /* Prevent text selection */"
, String
"} "
, String
"/* Create the caret/arrow with a unicode, and style it */"
, String
".caret::before { "
, String
" content: \"\\25B6 \"; "
, String
" color: white; "
, String
" display: inline-block; "
, String
" margin-right: 6px; "
, String
"} "
, String
"/* Rotate the caret/arrow icon when clicked on (using JavaScript) */"
, String
".caret-down::before { "
, String
" transform: rotate(90deg); "
, String
"} "
, String
"/* Hide the nested list */ "
, String
".nested { "
, String
" display: none; "
, String
"} "
, String
"/* Show the nested list when the user clicks on the caret/arrow (with JavaScript) */"
, String
".active { "
, String
" display: block;}"
]
js :: String
js :: String
js = [String] -> String
unlines
[ String
"var toggler = document.getElementsByClassName(\"caret\");"
, String
"var i;"
, String
"for (i = 0; i < toggler.length; i++) {"
, String
" toggler[i].addEventListener(\"click\", function() {"
, String
" this.parentElement.querySelector(\".nested\").classList.toggle(\"active\");"
, String
" this.classList.toggle(\"caret-down\");"
, String
" }); }"
]