module Futhark.Doc.Generator (renderFiles) where
import CMarkGFM qualified as GFM
import Control.Arrow ((***))
import Control.Monad
import Control.Monad.Reader
import Control.Monad.Writer (Writer, WriterT, runWriter, runWriterT, tell)
import Data.Bifunctor (second)
import Data.Char (isAlpha, isSpace, toUpper)
import Data.List (find, groupBy, inits, intersperse, isPrefixOf, partition, sort, sortOn, tails)
import Data.Map qualified as M
import Data.Maybe
import Data.Ord
import Data.Set qualified as S
import Data.String (fromString)
import Data.Text qualified as T
import Data.Version
import Futhark.Util.Pretty (Doc, docText, pretty)
import Futhark.Version
import Language.Futhark
import Language.Futhark.Semantic
import Language.Futhark.TypeChecker.Monad hiding (warn)
import System.FilePath (makeRelative, splitPath, (-<.>), (</>))
import Text.Blaze.Html5 (AttributeValue, Html, toHtml, (!))
import Text.Blaze.Html5 qualified as H
import Text.Blaze.Html5.Attributes qualified as A
import Prelude hiding (abs)
docToHtml :: Doc a -> Html
docToHtml :: forall a. Doc a -> Html
docToHtml = Text -> Html
forall a. ToMarkup a => a -> Html
toHtml (Text -> Html) -> (Doc a -> Text) -> Doc a -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc a -> Text
forall a. Doc a -> Text
docText
primTypeHtml :: PrimType -> Html
primTypeHtml :: PrimType -> Html
primTypeHtml = Doc Any -> Html
forall a. Doc a -> Html
docToHtml (Doc Any -> Html) -> (PrimType -> Doc Any) -> PrimType -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrimType -> Doc Any
forall a ann. Pretty a => a -> Doc ann
forall ann. PrimType -> Doc ann
pretty
prettyU :: Uniqueness -> Html
prettyU :: Uniqueness -> Html
prettyU = Doc Any -> Html
forall a. Doc a -> Html
docToHtml (Doc Any -> Html) -> (Uniqueness -> Doc Any) -> Uniqueness -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Uniqueness -> Doc Any
forall a ann. Pretty a => a -> Doc ann
forall ann. Uniqueness -> Doc ann
pretty
renderName :: Name -> Html
renderName :: Name -> Html
renderName Name
name = Doc Any -> Html
forall a. Doc a -> Html
docToHtml (Name -> Doc Any
forall a ann. Pretty a => a -> Doc ann
forall ann. Name -> Doc ann
pretty Name
name)
joinBy :: Html -> [Html] -> Html
joinBy :: Html -> [Html] -> Html
joinBy Html
_ [] = Html
forall a. Monoid a => a
mempty
joinBy Html
_ [Html
x] = Html
x
joinBy Html
sep (Html
x : [Html]
xs) = Html
x Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html) -> [Html] -> Html
forall m a. Monoid m => (a -> m) -> [a] -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (Html
sep <>) [Html]
xs
commas :: [Html] -> Html
commas :: [Html] -> Html
commas = Html -> [Html] -> Html
joinBy Html
", "
parens :: Html -> Html
parens :: Html -> Html
parens Html
x = Html
"(" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
x Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
")"
braces :: Html -> Html
braces :: Html -> Html
braces Html
x = Html
"{" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
x Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
"}"
brackets :: Html -> Html
brackets :: Html -> Html
brackets Html
x = Html
"[" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
x Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
"]"
pipes :: [Html] -> Html
pipes :: [Html] -> Html
pipes = Html -> [Html] -> Html
joinBy Html
" | "
type NoLink = S.Set VName
data Context = Context
{ Context -> [Char]
ctxCurrent :: String,
Context -> FileModule
ctxFileMod :: FileModule,
Context -> Imports
ctxImports :: Imports,
Context -> NoLink
ctxNoLink :: NoLink,
Context -> FileMap
ctxFileMap :: FileMap,
Context -> NoLink
ctxVisibleMTys :: S.Set VName
}
type FileMap = M.Map VName (FilePath, Namespace)
type DocM = ReaderT Context (WriterT Documented (Writer Warnings))
data IndexWhat = IndexValue | IndexFunction | IndexModule | IndexModuleType | IndexType
type Documented = M.Map VName IndexWhat
warn :: SrcLoc -> Doc () -> DocM ()
warn :: SrcLoc -> Doc () -> DocM ()
warn SrcLoc
loc Doc ()
s = WriterT Documented (Writer Warnings) () -> DocM ()
forall (m :: * -> *) a. Monad m => m a -> ReaderT Context m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (WriterT Documented (Writer Warnings) () -> DocM ())
-> WriterT Documented (Writer Warnings) () -> DocM ()
forall a b. (a -> b) -> a -> b
$ Writer Warnings () -> WriterT Documented (Writer Warnings) ()
forall (m :: * -> *) a. Monad m => m a -> WriterT Documented m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Writer Warnings () -> WriterT Documented (Writer Warnings) ())
-> Writer Warnings () -> WriterT Documented (Writer Warnings) ()
forall a b. (a -> b) -> a -> b
$ Warnings -> Writer Warnings ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Warnings -> Writer Warnings ()) -> Warnings -> Writer Warnings ()
forall a b. (a -> b) -> a -> b
$ SrcLoc -> Doc () -> Warnings
singleWarning SrcLoc
loc Doc ()
s
document :: VName -> IndexWhat -> DocM ()
document :: VName -> IndexWhat -> DocM ()
document VName
v IndexWhat
what = Documented -> DocM ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Documented -> DocM ()) -> Documented -> DocM ()
forall a b. (a -> b) -> a -> b
$ VName -> IndexWhat -> Documented
forall k a. k -> a -> Map k a
M.singleton VName
v IndexWhat
what
noLink :: [VName] -> DocM a -> DocM a
noLink :: forall a. [VName] -> DocM a -> DocM a
noLink [VName]
names = (Context -> Context)
-> ReaderT Context (WriterT Documented (Writer Warnings)) a
-> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall a.
(Context -> Context)
-> ReaderT Context (WriterT Documented (Writer Warnings)) a
-> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local ((Context -> Context)
-> ReaderT Context (WriterT Documented (Writer Warnings)) a
-> ReaderT Context (WriterT Documented (Writer Warnings)) a)
-> (Context -> Context)
-> ReaderT Context (WriterT Documented (Writer Warnings)) a
-> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall a b. (a -> b) -> a -> b
$ \Context
ctx ->
Context
ctx {ctxNoLink = S.fromList names <> ctxNoLink ctx}
selfLink :: AttributeValue -> Html -> Html
selfLink :: AttributeValue -> Html -> Html
selfLink AttributeValue
s = Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
s (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href (AttributeValue
"#" AttributeValue -> AttributeValue -> AttributeValue
forall a. Semigroup a => a -> a -> a
<> AttributeValue
s) (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"self_link"
fullRow :: Html -> Html
fullRow :: Html -> Html
fullRow = Html -> Html
H.tr (Html -> Html) -> (Html -> Html) -> Html -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Html -> Html
H.td (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.colspan AttributeValue
"3")
emptyRow :: Html
emptyRow :: Html
emptyRow = Html -> Html
H.tr (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
H.td Html
forall a. Monoid a => a
mempty Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html -> Html
H.td Html
forall a. Monoid a => a
mempty Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html -> Html
H.td Html
forall a. Monoid a => a
mempty
specRow :: Html -> Html -> Html -> Html
specRow :: Html -> Html -> Html -> Html
specRow Html
a Html
b Html
c =
Html -> Html
H.tr (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
(Html -> Html
H.td (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"spec_lhs") Html
a
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.td (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"spec_eql") Html
b
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.td (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"spec_rhs") Html
c
vnameToFileMap :: Imports -> FileMap
vnameToFileMap :: Imports -> FileMap
vnameToFileMap = [FileMap] -> FileMap
forall a. Monoid a => [a] -> a
mconcat ([FileMap] -> FileMap)
-> (Imports -> [FileMap]) -> Imports -> FileMap
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((ImportName, FileModule) -> FileMap) -> Imports -> [FileMap]
forall a b. (a -> b) -> [a] -> [b]
map (ImportName, FileModule) -> FileMap
forFile
where
forFile :: (ImportName, FileModule) -> FileMap
forFile (ImportName
file, FileModule TySet
abs Env
file_env Prog
_prog Env
_) =
[FileMap] -> FileMap
forall a. Monoid a => [a] -> a
mconcat ((QualName VName -> FileMap) -> [QualName VName] -> [FileMap]
forall a b. (a -> b) -> [a] -> [b]
map (Namespace -> QualName VName -> FileMap
forall {b} {k}. b -> QualName k -> Map k ([Char], b)
vname Namespace
Type) (TySet -> [QualName VName]
forall k a. Map k a -> [k]
M.keys TySet
abs))
FileMap -> FileMap -> FileMap
forall a. Semigroup a => a -> a -> a
<> Env -> FileMap
forEnv Env
file_env
where
file' :: [Char]
file' = [Char] -> [Char] -> [Char]
makeRelative [Char]
"/" ([Char] -> [Char]) -> [Char] -> [Char]
forall a b. (a -> b) -> a -> b
$ ImportName -> [Char]
includeToFilePath ImportName
file
vname :: b -> QualName k -> Map k ([Char], b)
vname b
ns QualName k
v = k -> ([Char], b) -> Map k ([Char], b)
forall k a. k -> a -> Map k a
M.singleton (QualName k -> k
forall vn. QualName vn -> vn
qualLeaf QualName k
v) ([Char]
file', b
ns)
vname' :: ((b, b), QualName k) -> Map k ([Char], b)
vname' ((b
ns, b
_), QualName k
v) = b -> QualName k -> Map k ([Char], b)
forall {b} {k}. b -> QualName k -> Map k ([Char], b)
vname b
ns QualName k
v
forEnv :: Env -> FileMap
forEnv Env
env =
[FileMap] -> FileMap
forall a. Monoid a => [a] -> a
mconcat ((((Namespace, Name), QualName VName) -> FileMap)
-> [((Namespace, Name), QualName VName)] -> [FileMap]
forall a b. (a -> b) -> [a] -> [b]
map ((Namespace, Name), QualName VName) -> FileMap
forall {b} {b} {k}. ((b, b), QualName k) -> Map k ([Char], b)
vname' ([((Namespace, Name), QualName VName)] -> [FileMap])
-> [((Namespace, Name), QualName VName)] -> [FileMap]
forall a b. (a -> b) -> a -> b
$ Map (Namespace, Name) (QualName VName)
-> [((Namespace, Name), QualName VName)]
forall k a. Map k a -> [(k, a)]
M.toList (Map (Namespace, Name) (QualName VName)
-> [((Namespace, Name), QualName VName)])
-> Map (Namespace, Name) (QualName VName)
-> [((Namespace, Name), QualName VName)]
forall a b. (a -> b) -> a -> b
$ Env -> Map (Namespace, Name) (QualName VName)
envNameMap Env
env)
FileMap -> FileMap -> FileMap
forall a. Semigroup a => a -> a -> a
<> [FileMap] -> FileMap
forall a. Monoid a => [a] -> a
mconcat ((MTy -> FileMap) -> [MTy] -> [FileMap]
forall a b. (a -> b) -> [a] -> [b]
map MTy -> FileMap
forMty ([MTy] -> [FileMap]) -> [MTy] -> [FileMap]
forall a b. (a -> b) -> a -> b
$ Map VName MTy -> [MTy]
forall k a. Map k a -> [a]
M.elems (Map VName MTy -> [MTy]) -> Map VName MTy -> [MTy]
forall a b. (a -> b) -> a -> b
$ Env -> Map VName MTy
envModTypeTable Env
env)
forMod :: Mod -> FileMap
forMod (ModEnv Env
env) = Env -> FileMap
forEnv Env
env
forMod ModFun {} = FileMap
forall a. Monoid a => a
mempty
forMty :: MTy -> FileMap
forMty = Mod -> FileMap
forMod (Mod -> FileMap) -> (MTy -> Mod) -> MTy -> FileMap
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MTy -> Mod
mtyMod
renderFiles :: [ImportName] -> Imports -> ([(FilePath, Html)], Warnings)
renderFiles :: [ImportName] -> Imports -> ([([Char], Html)], Warnings)
renderFiles [ImportName]
important_imports Imports
imports = Writer Warnings [([Char], Html)] -> ([([Char], Html)], Warnings)
forall w a. Writer w a -> (a, w)
runWriter (Writer Warnings [([Char], Html)] -> ([([Char], Html)], Warnings))
-> Writer Warnings [([Char], Html)] -> ([([Char], Html)], Warnings)
forall a b. (a -> b) -> a -> b
$ do
([(ImportName, (Html, Html))]
import_pages, Documented
documented) <- WriterT Documented (Writer Warnings) [(ImportName, (Html, Html))]
-> WriterT
Warnings Identity ([(ImportName, (Html, Html))], Documented)
forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
runWriterT (WriterT Documented (Writer Warnings) [(ImportName, (Html, Html))]
-> WriterT
Warnings Identity ([(ImportName, (Html, Html))], Documented))
-> WriterT
Documented (Writer Warnings) [(ImportName, (Html, Html))]
-> WriterT
Warnings Identity ([(ImportName, (Html, Html))], Documented)
forall a b. (a -> b) -> a -> b
$
Imports
-> ((ImportName, FileModule)
-> WriterT Documented (Writer Warnings) (ImportName, (Html, Html)))
-> WriterT
Documented (Writer Warnings) [(ImportName, (Html, Html))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM Imports
imports (((ImportName, FileModule)
-> WriterT Documented (Writer Warnings) (ImportName, (Html, Html)))
-> WriterT
Documented (Writer Warnings) [(ImportName, (Html, Html))])
-> ((ImportName, FileModule)
-> WriterT Documented (Writer Warnings) (ImportName, (Html, Html)))
-> WriterT
Documented (Writer Warnings) [(ImportName, (Html, Html))]
forall a b. (a -> b) -> a -> b
$ \(ImportName
current, FileModule
fm) ->
let ctx :: Context
ctx =
Context
{ ctxCurrent :: [Char]
ctxCurrent = [Char] -> [Char] -> [Char]
makeRelative [Char]
"/" ([Char] -> [Char]) -> [Char] -> [Char]
forall a b. (a -> b) -> a -> b
$ ImportName -> [Char]
includeToFilePath ImportName
current,
ctxFileMod :: FileModule
ctxFileMod = FileModule
fm,
ctxImports :: Imports
ctxImports = Imports
imports,
ctxNoLink :: NoLink
ctxNoLink = NoLink
forall a. Monoid a => a
mempty,
ctxFileMap :: FileMap
ctxFileMap = FileMap
file_map,
ctxVisibleMTys :: NoLink
ctxVisibleMTys = Prog -> NoLink
progModuleTypes (Prog -> NoLink) -> Prog -> NoLink
forall a b. (a -> b) -> a -> b
$ FileModule -> Prog
fileProg FileModule
fm
}
in (ReaderT
Context
(WriterT Documented (Writer Warnings))
(ImportName, (Html, Html))
-> Context
-> WriterT Documented (Writer Warnings) (ImportName, (Html, Html)))
-> Context
-> ReaderT
Context
(WriterT Documented (Writer Warnings))
(ImportName, (Html, Html))
-> WriterT Documented (Writer Warnings) (ImportName, (Html, Html))
forall a b c. (a -> b -> c) -> b -> a -> c
flip ReaderT
Context
(WriterT Documented (Writer Warnings))
(ImportName, (Html, Html))
-> Context
-> WriterT Documented (Writer Warnings) (ImportName, (Html, Html))
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT Context
ctx (ReaderT
Context
(WriterT Documented (Writer Warnings))
(ImportName, (Html, Html))
-> WriterT Documented (Writer Warnings) (ImportName, (Html, Html)))
-> ReaderT
Context
(WriterT Documented (Writer Warnings))
(ImportName, (Html, Html))
-> WriterT Documented (Writer Warnings) (ImportName, (Html, Html))
forall a b. (a -> b) -> a -> b
$ do
(Html
first_paragraph, Html
maybe_abstract, Html
maybe_sections) <- Prog -> DocM (Html, Html, Html)
headerDoc (Prog -> DocM (Html, Html, Html))
-> Prog -> DocM (Html, Html, Html)
forall a b. (a -> b) -> a -> b
$ FileModule -> Prog
fileProg FileModule
fm
Html
synopsis <- (Html -> Html
H.div (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
"module") (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Dec]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisDecs (Prog -> [Dec]
forall (f :: * -> *) vn. ProgBase f vn -> [DecBase f vn]
progDecs (Prog -> [Dec]) -> Prog -> [Dec]
forall a b. (a -> b) -> a -> b
$ FileModule -> Prog
fileProg FileModule
fm)
Html
description <- [Dec]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeDecs ([Dec]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [Dec]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Prog -> [Dec]
forall (f :: * -> *) vn. ProgBase f vn -> [DecBase f vn]
progDecs (Prog -> [Dec]) -> Prog -> [Dec]
forall a b. (a -> b) -> a -> b
$ FileModule -> Prog
fileProg FileModule
fm
(ImportName, (Html, Html))
-> ReaderT
Context
(WriterT Documented (Writer Warnings))
(ImportName, (Html, Html))
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
( ImportName
current,
( Html -> Html
H.docTypeHtml (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.lang AttributeValue
"en"
(Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ [ImportName] -> Imports -> [Char] -> [Char] -> Html -> Html
addBoilerplateWithNav
[ImportName]
important_imports
Imports
imports
([Char]
"doc" [Char] -> [Char] -> [Char]
</> ImportName -> [Char]
includeToFilePath ImportName
current)
(ImportName -> [Char]
includeToString ImportName
current)
(Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
H.main
(Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
maybe_abstract
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> AttributeValue -> Html -> Html
selfLink AttributeValue
"synopsis" (Html -> Html
H.h2 Html
"Synopsis")
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.div (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
"overview") Html
synopsis
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> AttributeValue -> Html -> Html
selfLink AttributeValue
"description" (Html -> Html
H.h2 Html
"Description")
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
description
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
maybe_sections,
Html
first_paragraph
)
)
[([Char], Html)] -> Writer Warnings [([Char], Html)]
forall a. a -> WriterT Warnings Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([([Char], Html)] -> Writer Warnings [([Char], Html)])
-> [([Char], Html)] -> Writer Warnings [([Char], Html)]
forall a b. (a -> b) -> a -> b
$
[ ([Char]
"index.html", [ImportName] -> [(ImportName, Html)] -> Html
contentsPage [ImportName]
important_imports ([(ImportName, Html)] -> Html) -> [(ImportName, Html)] -> Html
forall a b. (a -> b) -> a -> b
$ ((ImportName, (Html, Html)) -> (ImportName, Html))
-> [(ImportName, (Html, Html))] -> [(ImportName, Html)]
forall a b. (a -> b) -> [a] -> [b]
map (((Html, Html) -> Html)
-> (ImportName, (Html, Html)) -> (ImportName, Html)
forall a b. (a -> b) -> (ImportName, a) -> (ImportName, b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Html, Html) -> Html
forall a b. (a, b) -> b
snd) [(ImportName, (Html, Html))]
import_pages),
([Char]
"doc-index.html", [ImportName] -> Imports -> Documented -> FileMap -> Html
indexPage [ImportName]
important_imports Imports
imports Documented
documented FileMap
file_map)
]
[([Char], Html)] -> [([Char], Html)] -> [([Char], Html)]
forall a. [a] -> [a] -> [a]
++ ((ImportName, (Html, Html)) -> ([Char], Html))
-> [(ImportName, (Html, Html))] -> [([Char], Html)]
forall a b. (a -> b) -> [a] -> [b]
map (ImportName -> [Char]
importHtml (ImportName -> [Char])
-> ((Html, Html) -> Html)
-> (ImportName, (Html, Html))
-> ([Char], Html)
forall b c b' c'. (b -> c) -> (b' -> c') -> (b, b') -> (c, c')
forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** (Html, Html) -> Html
forall a b. (a, b) -> a
fst) [(ImportName, (Html, Html))]
import_pages
where
file_map :: FileMap
file_map = Imports -> FileMap
vnameToFileMap Imports
imports
importHtml :: ImportName -> [Char]
importHtml ImportName
import_name =
[Char]
"doc" [Char] -> [Char] -> [Char]
</> [Char] -> [Char] -> [Char]
makeRelative [Char]
"/" ([Char] -> [Char]
forall a. IsString a => [Char] -> a
fromString (ImportName -> [Char]
includeToString ImportName
import_name)) [Char] -> [Char] -> [Char]
-<.> [Char]
"html"
headerDoc :: Prog -> DocM (Html, Html, Html)
Prog
prog =
case Prog -> Maybe DocComment
forall (f :: * -> *) vn. ProgBase f vn -> Maybe DocComment
progDoc Prog
prog of
Just (DocComment Text
doc SrcLoc
loc) -> do
let ([Char]
abstract, [Char]
more_sections) = [Char] -> ([Char], [Char])
splitHeaderDoc ([Char] -> ([Char], [Char])) -> [Char] -> ([Char], [Char])
forall a b. (a -> b) -> a -> b
$ Text -> [Char]
T.unpack Text
doc
Html
first_paragraph <- Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
docHtml (Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ DocComment -> Maybe DocComment
forall a. a -> Maybe a
Just (DocComment -> Maybe DocComment) -> DocComment -> Maybe DocComment
forall a b. (a -> b) -> a -> b
$ Text -> SrcLoc -> DocComment
DocComment ([Char] -> Text
firstParagraph [Char]
abstract) SrcLoc
loc
Html
abstract' <- Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
docHtml (Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ DocComment -> Maybe DocComment
forall a. a -> Maybe a
Just (DocComment -> Maybe DocComment) -> DocComment -> Maybe DocComment
forall a b. (a -> b) -> a -> b
$ Text -> SrcLoc -> DocComment
DocComment ([Char] -> Text
T.pack [Char]
abstract) SrcLoc
loc
Html
more_sections' <- Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
docHtml (Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ DocComment -> Maybe DocComment
forall a. a -> Maybe a
Just (DocComment -> Maybe DocComment) -> DocComment -> Maybe DocComment
forall a b. (a -> b) -> a -> b
$ Text -> SrcLoc -> DocComment
DocComment ([Char] -> Text
T.pack [Char]
more_sections) SrcLoc
loc
(Html, Html, Html) -> DocM (Html, Html, Html)
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
( Html
first_paragraph,
AttributeValue -> Html -> Html
selfLink AttributeValue
"abstract" (Html -> Html
H.h2 Html
"Abstract") Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
abstract',
Html
more_sections'
)
Maybe DocComment
_ -> (Html, Html, Html) -> DocM (Html, Html, Html)
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html, Html, Html)
forall a. Monoid a => a
mempty
where
splitHeaderDoc :: [Char] -> ([Char], [Char])
splitHeaderDoc [Char]
s =
([Char], [Char]) -> Maybe ([Char], [Char]) -> ([Char], [Char])
forall a. a -> Maybe a -> a
fromMaybe ([Char]
s, [Char]
forall a. Monoid a => a
mempty) (Maybe ([Char], [Char]) -> ([Char], [Char]))
-> Maybe ([Char], [Char]) -> ([Char], [Char])
forall a b. (a -> b) -> a -> b
$
(([Char], [Char]) -> Bool)
-> [([Char], [Char])] -> Maybe ([Char], [Char])
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
find (([Char]
"\n##" `isPrefixOf`) ([Char] -> Bool)
-> (([Char], [Char]) -> [Char]) -> ([Char], [Char]) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Char], [Char]) -> [Char]
forall a b. (a, b) -> b
snd) ([([Char], [Char])] -> Maybe ([Char], [Char]))
-> [([Char], [Char])] -> Maybe ([Char], [Char])
forall a b. (a -> b) -> a -> b
$
[[Char]] -> [[Char]] -> [([Char], [Char])]
forall a b. [a] -> [b] -> [(a, b)]
zip ([Char] -> [[Char]]
forall a. [a] -> [[a]]
inits [Char]
s) ([Char] -> [[Char]]
forall a. [a] -> [[a]]
tails [Char]
s)
firstParagraph :: [Char] -> Text
firstParagraph = [Char] -> Text
T.pack ([Char] -> Text) -> ([Char] -> [Char]) -> [Char] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Char]] -> [Char]
unlines ([[Char]] -> [Char]) -> ([Char] -> [[Char]]) -> [Char] -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Char] -> Bool) -> [[Char]] -> [[Char]]
forall a. (a -> Bool) -> [a] -> [a]
takeWhile (Bool -> Bool
not (Bool -> Bool) -> ([Char] -> Bool) -> [Char] -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Bool
paragraphSeparator) ([[Char]] -> [[Char]])
-> ([Char] -> [[Char]]) -> [Char] -> [[Char]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> [[Char]]
lines
paragraphSeparator :: [Char] -> Bool
paragraphSeparator = (Char -> Bool) -> [Char] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Char -> Bool
isSpace
contentsPage :: [ImportName] -> [(ImportName, Html)] -> Html
contentsPage :: [ImportName] -> [(ImportName, Html)] -> Html
contentsPage [ImportName]
important_imports [(ImportName, Html)]
pages =
Html -> Html
H.docTypeHtml (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
[Char] -> [Char] -> Html -> Html
addBoilerplate [Char]
"index.html" [Char]
"Futhark Library Documentation" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
Html -> Html
H.main (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
( if [(ImportName, Html)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(ImportName, Html)]
important_pages
then Html
forall a. Monoid a => a
mempty
else Html -> Html
H.h2 Html
"Main libraries" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [(ImportName, Html)] -> Html
fileList [(ImportName, Html)]
important_pages
)
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> ( if [(ImportName, Html)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(ImportName, Html)]
unimportant_pages
then Html
forall a. Monoid a => a
mempty
else Html -> Html
H.h2 Html
"Supporting libraries" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [(ImportName, Html)] -> Html
fileList [(ImportName, Html)]
unimportant_pages
)
where
([(ImportName, Html)]
important_pages, [(ImportName, Html)]
unimportant_pages) =
((ImportName, Html) -> Bool)
-> [(ImportName, Html)]
-> ([(ImportName, Html)], [(ImportName, Html)])
forall a. (a -> Bool) -> [a] -> ([a], [a])
partition ((ImportName -> [ImportName] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [ImportName]
important_imports) (ImportName -> Bool)
-> ((ImportName, Html) -> ImportName) -> (ImportName, Html) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ImportName, Html) -> ImportName
forall a b. (a, b) -> a
fst) [(ImportName, Html)]
pages
fileList :: [(ImportName, Html)] -> Html
fileList [(ImportName, Html)]
pages' =
Html -> Html
H.dl (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"file_list" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
[Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html) -> [Html] -> Html
forall a b. (a -> b) -> a -> b
$
((ImportName, Html) -> Html) -> [(ImportName, Html)] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map (ImportName, Html) -> Html
linkTo ([(ImportName, Html)] -> [Html]) -> [(ImportName, Html)] -> [Html]
forall a b. (a -> b) -> a -> b
$
((ImportName, Html) -> ImportName)
-> [(ImportName, Html)] -> [(ImportName, Html)]
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn (ImportName, Html) -> ImportName
forall a b. (a, b) -> a
fst [(ImportName, Html)]
pages'
linkTo :: (ImportName, Html) -> Html
linkTo (ImportName
name, Html
maybe_abstract) =
Html -> Html
H.div (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"file_desc" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
(Html -> Html
H.dt (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"desc_header") ([Char] -> ImportName -> Html
importLink [Char]
"index.html" ImportName
name)
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.dd (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"desc_doc") Html
maybe_abstract
importLink :: FilePath -> ImportName -> Html
importLink :: [Char] -> ImportName -> Html
importLink [Char]
current ImportName
name =
let file :: [Char]
file =
[Char] -> [Char] -> [Char]
relativise
([Char]
"doc" [Char] -> [Char] -> [Char]
</> [Char] -> [Char] -> [Char]
makeRelative [Char]
"/" (ImportName -> [Char]
includeToFilePath ImportName
name) [Char] -> [Char] -> [Char]
-<.> [Char]
"html")
[Char]
current
in (Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href ([Char] -> AttributeValue
forall a. IsString a => [Char] -> a
fromString [Char]
file) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ [Char] -> Html
forall a. IsString a => [Char] -> a
fromString (ImportName -> [Char]
includeToString ImportName
name))
indexPage :: [ImportName] -> Imports -> Documented -> FileMap -> Html
indexPage :: [ImportName] -> Imports -> Documented -> FileMap -> Html
indexPage [ImportName]
important_imports Imports
imports Documented
documented FileMap
fm =
Html -> Html
H.docTypeHtml (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
[ImportName] -> Imports -> [Char] -> [Char] -> Html -> Html
addBoilerplateWithNav [ImportName]
important_imports Imports
imports [Char]
"doc-index.html" [Char]
"Index" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
Html -> Html
H.main (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
( Html -> Html
H.ul (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
"doc_index_list" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
[Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html) -> [Html] -> Html
forall a b. (a -> b) -> a -> b
$
([Char] -> Html) -> [[Char]] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map [Char] -> Html
initialListEntry ([[Char]] -> [Html]) -> [[Char]] -> [Html]
forall a b. (a -> b) -> a -> b
$
[[Char]]
letter_group_links [[Char]] -> [[Char]] -> [[Char]]
forall a. [a] -> [a] -> [a]
++ [[Char]
symbol_group_link]
)
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> ( Html -> Html
H.table (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
"doc_index" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
Html -> Html
H.thead (Html -> Html
H.tr (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
H.td Html
"Who" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html -> Html
H.td Html
"What" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html -> Html
H.td Html
"Where")
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html]
letter_groups [Html] -> [Html] -> [Html]
forall a. [a] -> [a] -> [a]
++ [Html
symbol_group])
)
where
([(VName, ([Char], IndexWhat))]
letter_names, [(VName, ([Char], IndexWhat))]
sym_names) =
((VName, ([Char], IndexWhat)) -> Bool)
-> [(VName, ([Char], IndexWhat))]
-> ([(VName, ([Char], IndexWhat))], [(VName, ([Char], IndexWhat))])
forall a. (a -> Bool) -> [a] -> ([a], [a])
partition ([Char] -> Bool
isLetterName ([Char] -> Bool)
-> ((VName, ([Char], IndexWhat)) -> [Char])
-> (VName, ([Char], IndexWhat))
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VName -> [Char]
baseString (VName -> [Char])
-> ((VName, ([Char], IndexWhat)) -> VName)
-> (VName, ([Char], IndexWhat))
-> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (VName, ([Char], IndexWhat)) -> VName
forall a b. (a, b) -> a
fst) ([(VName, ([Char], IndexWhat))]
-> ([(VName, ([Char], IndexWhat))],
[(VName, ([Char], IndexWhat))]))
-> [(VName, ([Char], IndexWhat))]
-> ([(VName, ([Char], IndexWhat))], [(VName, ([Char], IndexWhat))])
forall a b. (a -> b) -> a -> b
$
((VName, ([Char], IndexWhat)) -> [Char])
-> [(VName, ([Char], IndexWhat))] -> [(VName, ([Char], IndexWhat))]
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn ((Char -> Char) -> [Char] -> [Char]
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toUpper ([Char] -> [Char])
-> ((VName, ([Char], IndexWhat)) -> [Char])
-> (VName, ([Char], IndexWhat))
-> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VName -> [Char]
baseString (VName -> [Char])
-> ((VName, ([Char], IndexWhat)) -> VName)
-> (VName, ([Char], IndexWhat))
-> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (VName, ([Char], IndexWhat)) -> VName
forall a b. (a, b) -> a
fst) ([(VName, ([Char], IndexWhat))] -> [(VName, ([Char], IndexWhat))])
-> [(VName, ([Char], IndexWhat))] -> [(VName, ([Char], IndexWhat))]
forall a b. (a -> b) -> a -> b
$
((VName, ([Char], Namespace))
-> Maybe (VName, ([Char], IndexWhat)))
-> [(VName, ([Char], Namespace))] -> [(VName, ([Char], IndexWhat))]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (VName, ([Char], Namespace)) -> Maybe (VName, ([Char], IndexWhat))
forall {a} {b}. (VName, (a, b)) -> Maybe (VName, (a, IndexWhat))
isDocumented ([(VName, ([Char], Namespace))] -> [(VName, ([Char], IndexWhat))])
-> [(VName, ([Char], Namespace))] -> [(VName, ([Char], IndexWhat))]
forall a b. (a -> b) -> a -> b
$
FileMap -> [(VName, ([Char], Namespace))]
forall k a. Map k a -> [(k, a)]
M.toList FileMap
fm
isDocumented :: (VName, (a, b)) -> Maybe (VName, (a, IndexWhat))
isDocumented (VName
k, (a
file, b
_)) = do
IndexWhat
what <- VName -> Documented -> Maybe IndexWhat
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup VName
k Documented
documented
(VName, (a, IndexWhat)) -> Maybe (VName, (a, IndexWhat))
forall a. a -> Maybe a
Just (VName
k, (a
file, IndexWhat
what))
([Html]
letter_groups, [[Char]]
letter_group_links) =
[(Html, [Char])] -> ([Html], [[Char]])
forall a b. [(a, b)] -> ([a], [b])
unzip ([(Html, [Char])] -> ([Html], [[Char]]))
-> [(Html, [Char])] -> ([Html], [[Char]])
forall a b. (a -> b) -> a -> b
$ ([(VName, ([Char], IndexWhat))] -> (Html, [Char]))
-> [[(VName, ([Char], IndexWhat))]] -> [(Html, [Char])]
forall a b. (a -> b) -> [a] -> [b]
map [(VName, ([Char], IndexWhat))] -> (Html, [Char])
tbodyForNames ([[(VName, ([Char], IndexWhat))]] -> [(Html, [Char])])
-> [[(VName, ([Char], IndexWhat))]] -> [(Html, [Char])]
forall a b. (a -> b) -> a -> b
$ ((VName, ([Char], IndexWhat))
-> (VName, ([Char], IndexWhat)) -> Bool)
-> [(VName, ([Char], IndexWhat))]
-> [[(VName, ([Char], IndexWhat))]]
forall a. (a -> a -> Bool) -> [a] -> [[a]]
groupBy (VName, ([Char], IndexWhat))
-> (VName, ([Char], IndexWhat)) -> Bool
forall {b} {b}. (VName, b) -> (VName, b) -> Bool
sameInitial [(VName, ([Char], IndexWhat))]
letter_names
(Html
symbol_group, [Char]
symbol_group_link) =
[Char] -> [(VName, ([Char], IndexWhat))] -> (Html, [Char])
tbodyForInitial [Char]
"Symbols" [(VName, ([Char], IndexWhat))]
sym_names
isLetterName :: [Char] -> Bool
isLetterName [] = Bool
False
isLetterName (Char
c : [Char]
_) = Char -> Bool
isAlpha Char
c
sameInitial :: (VName, b) -> (VName, b) -> Bool
sameInitial (VName
x, b
_) (VName
y, b
_) =
case (VName -> [Char]
baseString VName
x, VName -> [Char]
baseString VName
y) of
(Char
x' : [Char]
_, Char
y' : [Char]
_) -> Char -> Char
toUpper Char
x' Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char -> Char
toUpper Char
y'
([Char], [Char])
_ -> Bool
False
tbodyForNames :: [(VName, ([Char], IndexWhat))] -> (Html, [Char])
tbodyForNames names :: [(VName, ([Char], IndexWhat))]
names@((VName
s, ([Char], IndexWhat)
_) : [(VName, ([Char], IndexWhat))]
_) =
[Char] -> [(VName, ([Char], IndexWhat))] -> (Html, [Char])
tbodyForInitial ((Char -> Char) -> [Char] -> [Char]
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toUpper ([Char] -> [Char]) -> [Char] -> [Char]
forall a b. (a -> b) -> a -> b
$ Int -> [Char] -> [Char]
forall a. Int -> [a] -> [a]
take Int
1 ([Char] -> [Char]) -> [Char] -> [Char]
forall a b. (a -> b) -> a -> b
$ VName -> [Char]
baseString VName
s) [(VName, ([Char], IndexWhat))]
names
tbodyForNames [(VName, ([Char], IndexWhat))]
_ = (Html, [Char])
forall a. Monoid a => a
mempty
tbodyForInitial :: [Char] -> [(VName, ([Char], IndexWhat))] -> (Html, [Char])
tbodyForInitial [Char]
initial [(VName, ([Char], IndexWhat))]
names =
( Html -> Html
H.tbody (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html) -> [Html] -> Html
forall a b. (a -> b) -> a -> b
$ Html
initial' Html -> [Html] -> [Html]
forall a. a -> [a] -> [a]
: ((VName, ([Char], IndexWhat)) -> Html)
-> [(VName, ([Char], IndexWhat))] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map (VName, ([Char], IndexWhat)) -> Html
linkTo [(VName, ([Char], IndexWhat))]
names,
[Char]
initial
)
where
initial' :: Html
initial' =
Html -> Html
H.tr
(Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
H.td (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.colspan AttributeValue
"2" (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"doc_index_initial"
(Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
H.a
(Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id ([Char] -> AttributeValue
forall a. IsString a => [Char] -> a
fromString [Char]
initial)
(Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href ([Char] -> AttributeValue
forall a. IsString a => [Char] -> a
fromString ([Char] -> AttributeValue) -> [Char] -> AttributeValue
forall a b. (a -> b) -> a -> b
$ Char
'#' Char -> [Char] -> [Char]
forall a. a -> [a] -> [a]
: [Char]
initial)
(Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ [Char] -> Html
forall a. IsString a => [Char] -> a
fromString [Char]
initial
initialListEntry :: [Char] -> Html
initialListEntry [Char]
initial =
Html -> Html
H.li (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href ([Char] -> AttributeValue
forall a. IsString a => [Char] -> a
fromString ([Char] -> AttributeValue) -> [Char] -> AttributeValue
forall a b. (a -> b) -> a -> b
$ Char
'#' Char -> [Char] -> [Char]
forall a. a -> [a] -> [a]
: [Char]
initial) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ [Char] -> Html
forall a. IsString a => [Char] -> a
fromString [Char]
initial
linkTo :: (VName, ([Char], IndexWhat)) -> Html
linkTo (VName
name, ([Char]
file, IndexWhat
what)) =
let file' :: [Char]
file' = [Char] -> [Char] -> [Char]
makeRelative [Char]
"/" [Char]
file
link :: Html
link =
(Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href ([Char] -> AttributeValue
forall a. IsString a => [Char] -> a
fromString ([Char] -> [Char] -> [Char]
makeRelative [Char]
"/" ([Char] -> [Char]) -> [Char] -> [Char]
forall a b. (a -> b) -> a -> b
$ [Char]
"doc" [Char] -> [Char] -> [Char]
</> VName -> [Char] -> [Char] -> [Char]
vnameLink' VName
name [Char]
"" [Char]
file'))) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
[Char] -> Html
forall a. IsString a => [Char] -> a
fromString ([Char] -> Html) -> [Char] -> Html
forall a b. (a -> b) -> a -> b
$
VName -> [Char]
baseString VName
name
what' :: Html
what' = case IndexWhat
what of
IndexWhat
IndexValue -> Html
"value"
IndexWhat
IndexFunction -> Html
"function"
IndexWhat
IndexType -> Html
"type"
IndexWhat
IndexModuleType -> Html
"module type"
IndexWhat
IndexModule -> Html
"module"
html_file :: [Char]
html_file = [Char]
"doc" [Char] -> [Char] -> [Char]
</> [Char]
file' [Char] -> [Char] -> [Char]
-<.> [Char]
"html"
in Html -> Html
H.tr (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
(Html -> Html
H.td (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"doc_index_name" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
link)
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.td (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"doc_index_namespace" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
what')
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> ( Html -> Html
H.td (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"doc_index_file" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
(Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href ([Char] -> AttributeValue
forall a. IsString a => [Char] -> a
fromString [Char]
html_file) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ [Char] -> Html
forall a. IsString a => [Char] -> a
fromString [Char]
file)
)
addBoilerplate :: String -> String -> Html -> Html
addBoilerplate :: [Char] -> [Char] -> Html -> Html
addBoilerplate [Char]
current [Char]
titleText Html
content =
let headHtml :: Html
headHtml =
Html -> Html
H.head (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
Html
H.meta
Html -> Attribute -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.charset AttributeValue
"utf-8"
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html -> Html
H.title ([Char] -> Html
forall a. IsString a => [Char] -> a
fromString [Char]
titleText)
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
H.link
Html -> Attribute -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href ([Char] -> AttributeValue
forall a. IsString a => [Char] -> a
fromString ([Char] -> AttributeValue) -> [Char] -> AttributeValue
forall a b. (a -> b) -> a -> b
$ [Char] -> [Char] -> [Char]
relativise [Char]
"style.css" [Char]
current)
Html -> Attribute -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.rel AttributeValue
"stylesheet"
Html -> Attribute -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.type_ AttributeValue
"text/css"
navigation :: Html
navigation =
Html -> Html
H.ul (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
"navigation" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
Html -> Html
H.li (Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href ([Char] -> AttributeValue
forall a. IsString a => [Char] -> a
fromString ([Char] -> AttributeValue) -> [Char] -> AttributeValue
forall a b. (a -> b) -> a -> b
$ [Char] -> [Char] -> [Char]
relativise [Char]
"index.html" [Char]
current) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
"Contents")
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html -> Html
H.li (Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href ([Char] -> AttributeValue
forall a. IsString a => [Char] -> a
fromString ([Char] -> AttributeValue) -> [Char] -> AttributeValue
forall a b. (a -> b) -> a -> b
$ [Char] -> [Char] -> [Char]
relativise [Char]
"doc-index.html" [Char]
current) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
"Index")
madeByHtml :: Html
madeByHtml =
Html
"Generated by "
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href AttributeValue
futhark_doc_url) Html
"futhark-doc"
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" "
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Char] -> Html
forall a. IsString a => [Char] -> a
fromString (Version -> [Char]
showVersion Version
version)
in Html
headHtml
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html -> Html
H.body
( (Html -> Html
H.div (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
"header") (Html -> Html
H.h1 ([Char] -> Html
forall a. ToMarkup a => a -> Html
toHtml [Char]
titleText) Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
navigation)
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.div (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
"content") Html
content
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.div (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
"footer") Html
madeByHtml
)
where
futhark_doc_url :: AttributeValue
futhark_doc_url =
AttributeValue
"https://futhark.readthedocs.io/en/latest/man/futhark-doc.html"
addBoilerplateWithNav :: [ImportName] -> Imports -> String -> String -> Html -> Html
addBoilerplateWithNav :: [ImportName] -> Imports -> [Char] -> [Char] -> Html -> Html
addBoilerplateWithNav [ImportName]
important_imports Imports
imports [Char]
current [Char]
titleText Html
content =
[Char] -> [Char] -> Html -> Html
addBoilerplate [Char]
current [Char]
titleText (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
(Html -> Html
H.nav (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id AttributeValue
"filenav" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
files) Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
content
where
files :: Html
files = Html -> Html
H.ul (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html) -> [Html] -> Html
forall a b. (a -> b) -> a -> b
$ (ImportName -> Html) -> [ImportName] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map ImportName -> Html
pp ([ImportName] -> [Html]) -> [ImportName] -> [Html]
forall a b. (a -> b) -> a -> b
$ [ImportName] -> [ImportName]
forall a. Ord a => [a] -> [a]
sort ([ImportName] -> [ImportName]) -> [ImportName] -> [ImportName]
forall a b. (a -> b) -> a -> b
$ (ImportName -> Bool) -> [ImportName] -> [ImportName]
forall a. (a -> Bool) -> [a] -> [a]
filter ImportName -> Bool
visible [ImportName]
important_imports
pp :: ImportName -> Html
pp ImportName
name = Html -> Html
H.li (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ [Char] -> ImportName -> Html
importLink [Char]
current ImportName
name
visible :: ImportName -> Bool
visible = (ImportName -> [ImportName] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` ((ImportName, FileModule) -> ImportName) -> Imports -> [ImportName]
forall a b. (a -> b) -> [a] -> [b]
map (ImportName, FileModule) -> ImportName
forall a b. (a, b) -> a
fst Imports
imports)
synopsisDecs :: [Dec] -> DocM Html
synopsisDecs :: [Dec]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisDecs [Dec]
decs = do
NoLink
visible <- (Context -> NoLink)
-> ReaderT Context (WriterT Documented (Writer Warnings)) NoLink
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks Context -> NoLink
ctxVisibleMTys
FileModule
fm <- (Context -> FileModule)
-> ReaderT
Context (WriterT Documented (Writer Warnings)) FileModule
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks Context -> FileModule
ctxFileMod
(Html -> Html
H.table (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"specs") (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Html
emptyRow <>) (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat
([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [ReaderT Context (WriterT Documented (Writer Warnings)) Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
forall (m :: * -> *) a. Monad m => [m a] -> m [a]
sequence ((Dec
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> [Dec]
-> [ReaderT Context (WriterT Documented (Writer Warnings)) Html]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (NoLink
-> FileModule
-> Dec
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisDec NoLink
visible FileModule
fm) [Dec]
decs)
synopsisDec :: S.Set VName -> FileModule -> Dec -> Maybe (DocM Html)
synopsisDec :: NoLink
-> FileModule
-> Dec
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisDec NoLink
visible FileModule
fm Dec
dec = case Dec
dec of
ModTypeDec ModTypeBindBase Info VName
s -> Html
-> ModTypeBindBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisModType Html
forall a. Monoid a => a
mempty ModTypeBindBase Info VName
s
ModDec ModBindBase Info VName
m -> FileModule
-> ModBindBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisMod FileModule
fm ModBindBase Info VName
m
ValDec ValBindBase Info VName
v -> ValBindBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisValBind ValBindBase Info VName
v
TypeDec TypeBindBase Info VName
t -> TypeBindBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisType TypeBindBase Info VName
t
OpenDec ModExpBase Info VName
x SrcLoc
_
| Just ReaderT Context (WriterT Documented (Writer Warnings)) Html
opened <- ModExpBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisOpened ModExpBase Info VName
x -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$ do
Html
opened' <- ReaderT Context (WriterT Documented (Writer Warnings)) Html
opened
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
fullRow (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ [Char] -> Html
keyword [Char]
"open " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
opened'
| Bool
otherwise ->
ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$
Html -> Html
fullRow (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
[Char] -> Html
keyword [Char]
"open" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Char] -> Html
forall a. IsString a => [Char] -> a
fromString ([Char]
" <" [Char] -> [Char] -> [Char]
forall a. Semigroup a => a -> a -> a
<> ModExpBase Info VName -> [Char]
forall a. Pretty a => a -> [Char]
prettyString ModExpBase Info VName
x [Char] -> [Char] -> [Char]
forall a. Semigroup a => a -> a -> a
<> [Char]
">")
LocalDec (ModTypeDec ModTypeBindBase Info VName
s) SrcLoc
_
| ModTypeBindBase Info VName -> VName
forall (f :: * -> *) vn. ModTypeBindBase f vn -> vn
modTypeName ModTypeBindBase Info VName
s VName -> NoLink -> Bool
forall a. Ord a => a -> Set a -> Bool
`S.member` NoLink
visible ->
Html
-> ModTypeBindBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisModType ([Char] -> Html
keyword [Char]
"local" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" ") ModTypeBindBase Info VName
s
LocalDec {} -> Maybe (ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. Maybe a
Nothing
ImportDec {} -> Maybe (ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. Maybe a
Nothing
synopsisOpened :: ModExp -> Maybe (DocM Html)
synopsisOpened :: ModExpBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisOpened (ModVar QualName VName
qn SrcLoc
_) = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$ QualName VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
qualNameHtml QualName VName
qn
synopsisOpened (ModParens ModExpBase Info VName
me SrcLoc
_) = do
ReaderT Context (WriterT Documented (Writer Warnings)) Html
me' <- ModExpBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisOpened ModExpBase Info VName
me
ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$ Html -> Html
parens (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ReaderT Context (WriterT Documented (Writer Warnings)) Html
me'
synopsisOpened (ModImport [Char]
_ (Info ImportName
file) SrcLoc
_) = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$ do
[Char]
current <- (Context -> [Char])
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks Context -> [Char]
ctxCurrent
let dest :: AttributeValue
dest = [Char] -> AttributeValue
forall a. IsString a => [Char] -> a
fromString ([Char] -> AttributeValue) -> [Char] -> AttributeValue
forall a b. (a -> b) -> a -> b
$ [Char] -> [Char] -> [Char]
relativise (ImportName -> [Char]
includeToFilePath ImportName
file) [Char]
current [Char] -> [Char] -> [Char]
-<.> [Char]
"html"
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$
[Char] -> Html
keyword [Char]
"import "
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href AttributeValue
dest) ([Char] -> Html
forall a. IsString a => [Char] -> a
fromString ([Char] -> [Char]
forall a. Show a => a -> [Char]
show (ImportName -> [Char]
includeToString ImportName
file)))
synopsisOpened (ModAscript ModExpBase Info VName
_ ModTypeExpBase Info VName
se Info (Map VName VName)
_ SrcLoc
_) = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$ do
Html
se' <- ModTypeExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisModTypeExp ModTypeExpBase Info VName
se
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
"... : " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
se'
synopsisOpened ModExpBase Info VName
_ = Maybe (ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. Maybe a
Nothing
synopsisValBind :: ValBind -> Maybe (DocM Html)
synopsisValBind :: ValBindBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisValBind ValBindBase Info VName
vb = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$ do
let name' :: Html
name' = VName -> Html
vnameSynopsisDef (VName -> Html) -> VName -> Html
forall a b. (a -> b) -> a -> b
$ ValBindBase Info VName -> VName
forall (f :: * -> *) vn. ValBindBase f vn -> vn
valBindName ValBindBase Info VName
vb
(Html
lhs, Html
mhs, Html
rhs) <- Html -> ValBindBase Info VName -> DocM (Html, Html, Html)
valBindHtml Html
name' ValBindBase Info VName
vb
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html -> Html -> Html -> Html
specRow Html
lhs (Html
mhs Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" : ") Html
rhs
valBindHtml :: Html -> ValBind -> DocM (Html, Html, Html)
valBindHtml :: Html -> ValBindBase Info VName -> DocM (Html, Html, Html)
valBindHtml Html
name (ValBind Maybe (Info EntryPoint)
_ VName
_ Maybe (TypeExp Info VName)
retdecl (Info ResRetType
rettype) [TypeParamBase VName]
tparams [PatBase Info VName ParamType]
params Size
_ Maybe DocComment
_ [AttrInfo VName]
_ SrcLoc
_) = do
let tparams' :: Html
tparams' = [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html) -> [Html] -> Html
forall a b. (a -> b) -> a -> b
$ (TypeParamBase VName -> Html) -> [TypeParamBase VName] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map ((Html
" " <>) (Html -> Html)
-> (TypeParamBase VName -> Html) -> TypeParamBase VName -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeParamBase VName -> Html
typeParamHtml) [TypeParamBase VName]
tparams
noLink' :: DocM a -> DocM a
noLink' =
[VName] -> DocM a -> DocM a
forall a. [VName] -> DocM a -> DocM a
noLink ([VName] -> DocM a -> DocM a) -> [VName] -> DocM a -> DocM a
forall a b. (a -> b) -> a -> b
$ (TypeParamBase VName -> VName) -> [TypeParamBase VName] -> [VName]
forall a b. (a -> b) -> [a] -> [b]
map TypeParamBase VName -> VName
forall vn. TypeParamBase vn -> vn
typeParamName [TypeParamBase VName]
tparams [VName] -> [VName] -> [VName]
forall a. Semigroup a => a -> a -> a
<> (PatBase Info VName ParamType -> [VName])
-> [PatBase Info VName ParamType] -> [VName]
forall m a. Monoid m => (a -> m) -> [a] -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap PatBase Info VName ParamType -> [VName]
forall t. Pat t -> [VName]
patNames [PatBase Info VName ParamType]
params
Html
rettype' <- ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall {a}. DocM a -> DocM a
noLink' (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> (TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Maybe (TypeExp Info VName)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (ResRetType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
retTypeHtml ResRetType
rettype) TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml Maybe (TypeExp Info VName)
retdecl
[Html]
params' <- ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall {a}. DocM a -> DocM a
noLink' (ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html])
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall a b. (a -> b) -> a -> b
$ (PatBase Info VName ParamType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [PatBase Info VName ParamType]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM PatBase Info VName ParamType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
paramHtml [PatBase Info VName ParamType]
params
(Html, Html, Html) -> DocM (Html, Html, Html)
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
( [Char] -> Html
keyword [Char]
"val " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> (Html -> Html
H.span (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"decl_name") Html
name,
Html
tparams',
[Html] -> Html
forall a. Monoid a => [a] -> a
mconcat (Html -> [Html] -> [Html]
forall a. a -> [a] -> [a]
intersperse Html
" -> " ([Html] -> [Html]) -> [Html] -> [Html]
forall a b. (a -> b) -> a -> b
$ [Html]
params' [Html] -> [Html] -> [Html]
forall a. [a] -> [a] -> [a]
++ [Html
rettype'])
)
synopsisModType :: Html -> ModTypeBind -> Maybe (DocM Html)
synopsisModType :: Html
-> ModTypeBindBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisModType Html
prefix ModTypeBindBase Info VName
sb = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$ do
let name' :: Html
name' = VName -> Html
vnameSynopsisDef (VName -> Html) -> VName -> Html
forall a b. (a -> b) -> a -> b
$ ModTypeBindBase Info VName -> VName
forall (f :: * -> *) vn. ModTypeBindBase f vn -> vn
modTypeName ModTypeBindBase Info VName
sb
Html -> Html
fullRow (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> do
Html
se' <- ModTypeExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisModTypeExp (ModTypeExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ModTypeExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ ModTypeBindBase Info VName -> ModTypeExpBase Info VName
forall (f :: * -> *) vn.
ModTypeBindBase f vn -> ModTypeExpBase f vn
modTypeExp ModTypeBindBase Info VName
sb
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
prefix Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Char] -> Html
keyword [Char]
"module type " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" = " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
se'
synopsisMod :: FileModule -> ModBind -> Maybe (DocM Html)
synopsisMod :: FileModule
-> ModBindBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisMod FileModule
fm (ModBind VName
name [ModParamBase Info VName]
ps Maybe (ModTypeExpBase Info VName, Info (Map VName VName))
sig ModExpBase Info VName
_ Maybe DocComment
_ SrcLoc
_) =
case Maybe (ModTypeExpBase Info VName, Info (Map VName VName))
sig of
Maybe (ModTypeExpBase Info VName, Info (Map VName VName))
Nothing -> (Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
proceed (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Mod
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Mod
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< Mod -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
envModType) (Mod
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Maybe Mod
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> VName -> Map VName Mod -> Maybe Mod
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup VName
name Map VName Mod
modtable
Just (ModTypeExpBase Info VName
s, Info (Map VName VName)
_) -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$ Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
proceed (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< ModTypeExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisModTypeExp ModTypeExpBase Info VName
s
where
proceed :: Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
proceed Html
sig' = do
let name' :: Html
name' = VName -> Html
vnameSynopsisDef VName
name
Html
ps' <- [ModParamBase Info VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
modParamHtml [ModParamBase Info VName]
ps
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html -> Html -> Html -> Html
specRow ([Char] -> Html
keyword [Char]
"module " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name') Html
": " (Html
ps' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
sig')
FileModule TySet
_abs Env {envModTable :: Env -> Map VName Mod
envModTable = Map VName Mod
modtable} Prog
_ Env
_ = FileModule
fm
envModType :: Mod -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
envModType (ModEnv Env
e) = Env -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderEnv Env
e
envModType (ModFun (FunModType TySet
_ Mod
_ (MTy TySet
_ Mod
m))) = Mod -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
envModType Mod
m
synopsisType :: TypeBind -> Maybe (DocM Html)
synopsisType :: TypeBindBase Info VName
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
synopsisType TypeBindBase Info VName
tb = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$ do
let name' :: Html
name' = VName -> Html
vnameSynopsisDef (VName -> Html) -> VName -> Html
forall a b. (a -> b) -> a -> b
$ TypeBindBase Info VName -> VName
forall (f :: * -> *) vn. TypeBindBase f vn -> vn
typeAlias TypeBindBase Info VName
tb
Html -> Html
fullRow (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Html
-> TypeBindBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeBindHtml Html
name' TypeBindBase Info VName
tb
typeBindHtml :: Html -> TypeBind -> DocM Html
typeBindHtml :: Html
-> TypeBindBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeBindHtml Html
name' (TypeBind VName
_ Liftedness
l [TypeParamBase VName]
tparams TypeExp Info VName
t Info StructRetType
_ Maybe DocComment
_ SrcLoc
_) = do
Html
t' <- [VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a. [VName] -> DocM a -> DocM a
noLink ((TypeParamBase VName -> VName) -> [TypeParamBase VName] -> [VName]
forall a b. (a -> b) -> [a] -> [b]
map TypeParamBase VName -> VName
forall vn. TypeParamBase vn -> vn
typeParamName [TypeParamBase VName]
tparams) (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp Info VName
t
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Liftedness -> Html -> [TypeParamBase VName] -> Html
typeAbbrevHtml Liftedness
l Html
name' [TypeParamBase VName]
tparams Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" = " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t'
renderEnv :: Env -> DocM Html
renderEnv :: Env -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderEnv (Env Map VName BoundV
vtable Map VName TypeBinding
ttable Map VName MTy
sigtable Map VName Mod
modtable Map (Namespace, Name) (QualName VName)
_) = do
[Html]
typeBinds <- ((VName, TypeBinding)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [(VName, TypeBinding)]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (VName, TypeBinding)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderTypeBind (Map VName TypeBinding -> [(VName, TypeBinding)]
forall k a. Map k a -> [(k, a)]
M.toList Map VName TypeBinding
ttable)
[Html]
valBinds <- ((VName, BoundV)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [(VName, BoundV)]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (VName, BoundV)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderValBind (Map VName BoundV -> [(VName, BoundV)]
forall k a. Map k a -> [(k, a)]
M.toList Map VName BoundV
vtable)
[Html]
sigBinds <- ((VName, MTy)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [(VName, MTy)]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (VName, MTy)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderModType (Map VName MTy -> [(VName, MTy)]
forall k a. Map k a -> [(k, a)]
M.toList Map VName MTy
sigtable)
[Html]
modBinds <- ((VName, Mod)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [(VName, Mod)]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (VName, Mod)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderMod (Map VName Mod -> [(VName, Mod)]
forall k a. Map k a -> [(k, a)]
M.toList Map VName Mod
modtable)
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
braces (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html) -> [Html] -> Html
forall a b. (a -> b) -> a -> b
$ [Html]
typeBinds [Html] -> [Html] -> [Html]
forall a. [a] -> [a] -> [a]
++ [Html]
valBinds [Html] -> [Html] -> [Html]
forall a. [a] -> [a] -> [a]
++ [Html]
sigBinds [Html] -> [Html] -> [Html]
forall a. [a] -> [a] -> [a]
++ [Html]
modBinds
renderModType :: (VName, MTy) -> DocM Html
renderModType :: (VName, MTy)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderModType (VName
name, MTy
_sig) =
([Char] -> Html
keyword [Char]
"module type " <>) (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> QualName VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
qualNameHtml (VName -> QualName VName
forall v. v -> QualName v
qualName VName
name)
renderMod :: (VName, Mod) -> DocM Html
renderMod :: (VName, Mod)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderMod (VName
name, Mod
_mod) =
([Char] -> Html
keyword [Char]
"module " <>) (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> QualName VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
qualNameHtml (VName -> QualName VName
forall v. v -> QualName v
qualName VName
name)
renderValBind :: (VName, BoundV) -> DocM Html
renderValBind :: (VName, BoundV)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderValBind = (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b.
(a -> b)
-> ReaderT Context (WriterT Documented (Writer Warnings)) a
-> ReaderT Context (WriterT Documented (Writer Warnings)) b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Html -> Html
H.div (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ((VName, BoundV)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (VName, BoundV)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (VName, BoundV)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisValBindBind
renderTypeBind :: (VName, TypeBinding) -> DocM Html
renderTypeBind :: (VName, TypeBinding)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
renderTypeBind (VName
name, TypeAbbr Liftedness
l [TypeParamBase VName]
tps StructRetType
tp) = do
Html
tp' <- ResRetType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
retTypeHtml (ResRetType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ResRetType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Uniqueness -> StructRetType -> ResRetType
forall u. Uniqueness -> RetTypeBase Size u -> ResRetType
toResRet Uniqueness
Nonunique StructRetType
tp
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
H.div (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Liftedness -> Html -> [TypeParamBase VName] -> Html
typeAbbrevHtml Liftedness
l (VName -> Html
vnameHtml VName
name) [TypeParamBase VName]
tps Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" = " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
tp'
synopsisValBindBind :: (VName, BoundV) -> DocM Html
synopsisValBindBind :: (VName, BoundV)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisValBindBind (VName
name, BoundV [TypeParamBase VName]
tps StructType
t) = do
let tps' :: [Html]
tps' = (TypeParamBase VName -> Html) -> [TypeParamBase VName] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map TypeParamBase VName -> Html
typeParamHtml [TypeParamBase VName]
tps
Html
t' <- TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml (TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ (NoUniqueness -> Uniqueness)
-> StructType -> TypeBase Size Uniqueness
forall b c a. (b -> c) -> TypeBase a b -> TypeBase a c
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second (Uniqueness -> NoUniqueness -> Uniqueness
forall a b. a -> b -> a
const Uniqueness
Nonunique) StructType
t
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$
[Char] -> Html
keyword [Char]
"val "
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> VName -> Html
vnameHtml VName
name
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ((Html -> Html) -> [Html] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map (Html
" " <>) [Html]
tps')
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": "
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t'
dietHtml :: Diet -> Html
dietHtml :: Diet -> Html
dietHtml Diet
Consume = Html
"*"
dietHtml Diet
Observe = Html
""
typeHtml :: TypeBase Size Uniqueness -> DocM Html
typeHtml :: TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml TypeBase Size Uniqueness
t = case TypeBase Size Uniqueness
t of
Array Uniqueness
u Shape Size
shape ScalarTypeBase Size NoUniqueness
et -> do
Html
shape' <- Shape Size
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
prettyShape Shape Size
shape
Html
et' <- TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml (TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ ScalarTypeBase Size Uniqueness -> TypeBase Size Uniqueness
forall dim u. ScalarTypeBase dim u -> TypeBase dim u
Scalar (ScalarTypeBase Size Uniqueness -> TypeBase Size Uniqueness)
-> ScalarTypeBase Size Uniqueness -> TypeBase Size Uniqueness
forall a b. (a -> b) -> a -> b
$ (NoUniqueness -> Uniqueness)
-> ScalarTypeBase Size NoUniqueness
-> ScalarTypeBase Size Uniqueness
forall b c a. (b -> c) -> ScalarTypeBase a b -> ScalarTypeBase a c
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second (Uniqueness -> NoUniqueness -> Uniqueness
forall a b. a -> b -> a
const Uniqueness
Nonunique) ScalarTypeBase Size NoUniqueness
et
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Uniqueness -> Html
prettyU Uniqueness
u Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
shape' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
et'
Scalar (Prim PrimType
et) -> Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ PrimType -> Html
primTypeHtml PrimType
et
Scalar (Record Map Name (TypeBase Size Uniqueness)
fs)
| Just [TypeBase Size Uniqueness]
ts <- Map Name (TypeBase Size Uniqueness)
-> Maybe [TypeBase Size Uniqueness]
forall a. Map Name a -> Maybe [a]
areTupleFields Map Name (TypeBase Size Uniqueness)
fs ->
Html -> Html
parens (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Html] -> Html
commas ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [TypeBase Size Uniqueness]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml [TypeBase Size Uniqueness]
ts
| Bool
otherwise ->
Html -> Html
braces (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Html] -> Html
commas ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((Name, TypeBase Size Uniqueness)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [(Name, TypeBase Size Uniqueness)]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (Name, TypeBase Size Uniqueness)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
ppField (Map Name (TypeBase Size Uniqueness)
-> [(Name, TypeBase Size Uniqueness)]
forall k a. Map k a -> [(k, a)]
M.toList Map Name (TypeBase Size Uniqueness)
fs)
where
ppField :: (Name, TypeBase Size Uniqueness)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
ppField (Name
name, TypeBase Size Uniqueness
tp) = do
Html
tp' <- TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml TypeBase Size Uniqueness
tp
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ [Char] -> Html
forall a. ToMarkup a => a -> Html
toHtml (Name -> [Char]
nameToString Name
name) Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
tp'
Scalar (TypeVar Uniqueness
u QualName VName
et [TypeArg Size]
targs) -> do
[Html]
targs' <- (TypeArg Size
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [TypeArg Size]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM TypeArg Size
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeArgHtml [TypeArg Size]
targs
Html
et' <- QualName VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
qualNameHtml QualName VName
et
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Uniqueness -> Html
prettyU Uniqueness
u Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
et' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ((Html -> Html) -> [Html] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map (Html
" " <>) [Html]
targs')
Scalar (Arrow Uniqueness
_ PName
pname Diet
d StructType
t1 ResRetType
t2) -> do
Html
t1' <- TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml (TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ (NoUniqueness -> Uniqueness)
-> StructType -> TypeBase Size Uniqueness
forall b c a. (b -> c) -> TypeBase a b -> TypeBase a c
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second (Uniqueness -> NoUniqueness -> Uniqueness
forall a b. a -> b -> a
const Uniqueness
Nonunique) StructType
t1
Html
t2' <- ResRetType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
retTypeHtml ResRetType
t2
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ case PName
pname of
Named VName
v ->
Html -> Html
parens (VName -> Html
vnameHtml VName
v Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Diet -> Html
dietHtml Diet
d Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t1') Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" -> " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t2'
PName
Unnamed ->
Diet -> Html
dietHtml Diet
d Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t1' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" -> " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t2'
Scalar (Sum Map Name [TypeBase Size Uniqueness]
cs) -> [Html] -> Html
pipes ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((Name, [TypeBase Size Uniqueness])
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [(Name, [TypeBase Size Uniqueness])]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (Name, [TypeBase Size Uniqueness])
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
ppClause (Map Name [TypeBase Size Uniqueness]
-> [(Name, [TypeBase Size Uniqueness])]
forall a. Map Name a -> [(Name, a)]
sortConstrs Map Name [TypeBase Size Uniqueness]
cs)
where
ppClause :: (Name, [TypeBase Size Uniqueness])
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
ppClause (Name
n, [TypeBase Size Uniqueness]
ts) = Html -> [Html] -> Html
joinBy Html
" " ([Html] -> Html) -> ([Html] -> [Html]) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Name -> Html
ppConstr Name
n :) ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [TypeBase Size Uniqueness]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml [TypeBase Size Uniqueness]
ts
ppConstr :: Name -> Html
ppConstr Name
name = Html
"#" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Char] -> Html
forall a. ToMarkup a => a -> Html
toHtml (Name -> [Char]
nameToString Name
name)
retTypeHtml :: ResRetType -> DocM Html
retTypeHtml :: ResRetType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
retTypeHtml (RetType [] TypeBase Size Uniqueness
t) = TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml TypeBase Size Uniqueness
t
retTypeHtml (RetType [VName]
dims TypeBase Size Uniqueness
t) = do
Html
t' <- TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml TypeBase Size Uniqueness
t
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
"?" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ((VName -> Html) -> [VName] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map (Html -> Html
brackets (Html -> Html) -> (VName -> Html) -> VName -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VName -> Html
vnameHtml) [VName]
dims) Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
"." Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t'
prettyShape :: Shape Size -> DocM Html
prettyShape :: Shape Size
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
prettyShape (Shape [Size]
ds) =
[Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Size
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [Size]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM Size -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
dimDeclHtml [Size]
ds
typeArgHtml :: TypeArg Size -> DocM Html
typeArgHtml :: TypeArg Size
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeArgHtml (TypeArgDim Size
d) = Size -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
dimDeclHtml Size
d
typeArgHtml (TypeArgType StructType
t) = TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml (TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ (NoUniqueness -> Uniqueness)
-> StructType -> TypeBase Size Uniqueness
forall b c a. (b -> c) -> TypeBase a b -> TypeBase a c
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second (Uniqueness -> NoUniqueness -> Uniqueness
forall a b. a -> b -> a
const Uniqueness
Nonunique) StructType
t
modParamHtml :: [ModParamBase Info VName] -> DocM Html
modParamHtml :: [ModParamBase Info VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
modParamHtml [] = Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Html
forall a. Monoid a => a
mempty
modParamHtml (ModParam VName
pname ModTypeExpBase Info VName
psig Info [VName]
_ SrcLoc
_ : [ModParamBase Info VName]
mps) =
(Html -> Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 Html -> Html -> Html
f (ModTypeExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisModTypeExp ModTypeExpBase Info VName
psig) ([ModParamBase Info VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
modParamHtml [ModParamBase Info VName]
mps)
where
f :: Html -> Html -> Html
f Html
se Html
params =
Html
"("
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> VName -> Html
vnameHtml VName
pname
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": "
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
se
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
") -> "
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
params
synopsisModTypeExp :: ModTypeExpBase Info VName -> DocM Html
synopsisModTypeExp :: ModTypeExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisModTypeExp ModTypeExpBase Info VName
e = case ModTypeExpBase Info VName
e of
ModTypeVar QualName VName
v Info (Map VName VName)
_ SrcLoc
_ -> QualName VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
qualNameHtml QualName VName
v
ModTypeParens ModTypeExpBase Info VName
e' SrcLoc
_ -> Html -> Html
parens (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ModTypeExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisModTypeExp ModTypeExpBase Info VName
e'
ModTypeSpecs [SpecBase Info VName]
ss SrcLoc
_ -> Html -> Html
braces (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Html -> Html
H.table (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"specs") (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (SpecBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [SpecBase Info VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM SpecBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisSpec [SpecBase Info VName]
ss
ModTypeWith ModTypeExpBase Info VName
s (TypeRef QualName VName
v [TypeParamBase VName]
ps TypeExp Info VName
t SrcLoc
_) SrcLoc
_ -> do
Html
s' <- ModTypeExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisModTypeExp ModTypeExpBase Info VName
s
Html
t' <- TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp Info VName
t
Html
v' <- QualName VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
qualNameHtml QualName VName
v
let ps' :: Html
ps' = [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html) -> [Html] -> Html
forall a b. (a -> b) -> a -> b
$ (TypeParamBase VName -> Html) -> [TypeParamBase VName] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map ((Html
" " <>) (Html -> Html)
-> (TypeParamBase VName -> Html) -> TypeParamBase VName -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeParamBase VName -> Html
typeParamHtml) [TypeParamBase VName]
ps
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
s' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Char] -> Html
keyword [Char]
" with " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
v' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
ps' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" = " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t'
ModTypeArrow Maybe VName
Nothing ModTypeExpBase Info VName
e1 ModTypeExpBase Info VName
e2 SrcLoc
_ ->
(Html -> Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 Html -> Html -> Html
forall {a}. (Semigroup a, IsString a) => a -> a -> a
f (ModTypeExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisModTypeExp ModTypeExpBase Info VName
e1) (ModTypeExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisModTypeExp ModTypeExpBase Info VName
e2)
where
f :: a -> a -> a
f a
e1' a
e2' = a
e1' a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
" -> " a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
e2'
ModTypeArrow (Just VName
v) ModTypeExpBase Info VName
e1 ModTypeExpBase Info VName
e2 SrcLoc
_ ->
do
let name :: Html
name = VName -> Html
vnameHtml VName
v
Html
e1' <- ModTypeExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisModTypeExp ModTypeExpBase Info VName
e1
Html
e2' <- [VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a. [VName] -> DocM a -> DocM a
noLink [VName
v] (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ ModTypeExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisModTypeExp ModTypeExpBase Info VName
e2
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
"(" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
e1' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
") -> " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
e2'
keyword :: String -> Html
keyword :: [Char] -> Html
keyword = (Html -> Html
H.span (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"keyword") (Html -> Html) -> ([Char] -> Html) -> [Char] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Html
forall a. IsString a => [Char] -> a
fromString
vnameHtml :: VName -> Html
vnameHtml :: VName -> Html
vnameHtml (VName Name
name Int
tag) =
Html -> Html
H.span (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id ([Char] -> AttributeValue
forall a. IsString a => [Char] -> a
fromString (Int -> [Char]
forall a. Show a => a -> [Char]
show Int
tag)) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Name -> Html
renderName Name
name
vnameDescDef :: VName -> IndexWhat -> DocM Html
vnameDescDef :: VName
-> IndexWhat
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
vnameDescDef VName
v IndexWhat
what = do
VName -> IndexWhat -> DocM ()
document VName
v IndexWhat
what
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id ([Char] -> AttributeValue
forall a. IsString a => [Char] -> a
fromString (Int -> [Char]
forall a. Show a => a -> [Char]
show (VName -> Int
baseTag VName
v))) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Name -> Html
renderName (VName -> Name
baseName VName
v)
vnameSynopsisDef :: VName -> Html
vnameSynopsisDef :: VName -> Html
vnameSynopsisDef (VName Name
name Int
tag) =
Html -> Html
H.span (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.id ([Char] -> AttributeValue
forall a. IsString a => [Char] -> a
fromString (Int -> [Char]
forall a. Show a => a -> [Char]
show Int
tag [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
"s")) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href ([Char] -> AttributeValue
forall a. IsString a => [Char] -> a
fromString ([Char]
"#" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ Int -> [Char]
forall a. Show a => a -> [Char]
show Int
tag)) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
Name -> Html
renderName Name
name
vnameSynopsisRef :: VName -> Html
vnameSynopsisRef :: VName -> Html
vnameSynopsisRef VName
v =
Html -> Html
H.a
(Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"synopsis_link"
(Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href ([Char] -> AttributeValue
forall a. IsString a => [Char] -> a
fromString ([Char]
"#" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ Int -> [Char]
forall a. Show a => a -> [Char]
show (VName -> Int
baseTag VName
v) [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
"s"))
(Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
"↑"
synopsisSpec :: SpecBase Info VName -> DocM Html
synopsisSpec :: SpecBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisSpec SpecBase Info VName
spec = case SpecBase Info VName
spec of
TypeAbbrSpec TypeBindBase Info VName
tpsig ->
Html -> Html
fullRow (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Html
-> TypeBindBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeBindHtml (VName -> Html
vnameSynopsisDef (VName -> Html) -> VName -> Html
forall a b. (a -> b) -> a -> b
$ TypeBindBase Info VName -> VName
forall (f :: * -> *) vn. TypeBindBase f vn -> vn
typeAlias TypeBindBase Info VName
tpsig) TypeBindBase Info VName
tpsig
TypeSpec Liftedness
l VName
name [TypeParamBase VName]
ps Maybe DocComment
_ SrcLoc
_ ->
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
fullRow (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ [Char] -> Html
keyword [Char]
l' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> VName -> Html
vnameSynopsisDef VName
name Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ((TypeParamBase VName -> Html) -> [TypeParamBase VName] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map ((Html
" " <>) (Html -> Html)
-> (TypeParamBase VName -> Html) -> TypeParamBase VName -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeParamBase VName -> Html
typeParamHtml) [TypeParamBase VName]
ps)
where
l' :: [Char]
l' = case Liftedness
l of
Liftedness
Unlifted -> [Char]
"type "
Liftedness
SizeLifted -> [Char]
"type~ "
Liftedness
Lifted -> [Char]
"type^ "
ValSpec VName
name [TypeParamBase VName]
tparams TypeExp Info VName
rettype Info StructType
_ Maybe DocComment
_ SrcLoc
_ -> do
let tparams' :: [Html]
tparams' = (TypeParamBase VName -> Html) -> [TypeParamBase VName] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map TypeParamBase VName -> Html
typeParamHtml [TypeParamBase VName]
tparams
Html
rettype' <- [VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a. [VName] -> DocM a -> DocM a
noLink ((TypeParamBase VName -> VName) -> [TypeParamBase VName] -> [VName]
forall a b. (a -> b) -> [a] -> [b]
map TypeParamBase VName -> VName
forall vn. TypeParamBase vn -> vn
typeParamName [TypeParamBase VName]
tparams) (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp Info VName
rettype
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$
Html -> Html -> Html -> Html
specRow
([Char] -> Html
keyword [Char]
"val " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> VName -> Html
vnameSynopsisDef VName
name)
([Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ((Html -> Html) -> [Html] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map (Html
" " <>) [Html]
tparams') Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": ")
Html
rettype'
ModSpec VName
name ModTypeExpBase Info VName
sig Maybe DocComment
_ SrcLoc
_ ->
Html -> Html -> Html -> Html
specRow ([Char] -> Html
keyword [Char]
"module " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> VName -> Html
vnameSynopsisDef VName
name) Html
": " (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ModTypeExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisModTypeExp ModTypeExpBase Info VName
sig
IncludeSpec ModTypeExpBase Info VName
e SrcLoc
_ -> Html -> Html
fullRow (Html -> Html) -> (Html -> Html) -> Html -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Char] -> Html
keyword [Char]
"include " <>) (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ModTypeExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisModTypeExp ModTypeExpBase Info VName
e
typeExpHtml :: TypeExp Info VName -> DocM Html
typeExpHtml :: TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp Info VName
e = case TypeExp Info VName
e of
TEUnique TypeExp Info VName
t SrcLoc
_ -> (Html
"*" <>) (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp Info VName
t
TEArray SizeExp Info VName
d TypeExp Info VName
at SrcLoc
_ -> do
Html
at' <- TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp Info VName
at
Html
d' <- SizeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
dimExpHtml SizeExp Info VName
d
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
d' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
at'
TETuple [TypeExp Info VName]
ts SrcLoc
_ -> Html -> Html
parens (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Html] -> Html
commas ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [TypeExp Info VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml [TypeExp Info VName]
ts
TERecord [(Name, TypeExp Info VName)]
fs SrcLoc
_ -> Html -> Html
braces (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Html] -> Html
commas ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((Name, TypeExp Info VName)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [(Name, TypeExp Info VName)]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (Name, TypeExp Info VName)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
ppField [(Name, TypeExp Info VName)]
fs
where
ppField :: (Name, TypeExp Info VName)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
ppField (Name
name, TypeExp Info VName
t) = do
Html
t' <- TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp Info VName
t
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ [Char] -> Html
forall a. ToMarkup a => a -> Html
toHtml (Name -> [Char]
nameToString Name
name) Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t'
TEVar QualName VName
name SrcLoc
_ -> QualName VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
qualNameHtml QualName VName
name
TEParens TypeExp Info VName
te SrcLoc
_ -> Html -> Html
parens (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp Info VName
te
TEApply TypeExp Info VName
t TypeArgExp Info VName
arg SrcLoc
_ -> do
Html
t' <- TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp Info VName
t
Html
arg' <- TypeArgExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeArgExpHtml TypeArgExp Info VName
arg
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
t' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
arg'
TEArrow Maybe VName
pname TypeExp Info VName
t1 TypeExp Info VName
t2 SrcLoc
_ -> do
Html
t1' <- case TypeExp Info VName
t1 of
TEArrow {} -> Html -> Html
parens (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp Info VName
t1
TypeExp Info VName
_ -> TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp Info VName
t1
Html
t2' <- TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp Info VName
t2
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ case Maybe VName
pname of
Just VName
v ->
Html -> Html
parens (VName -> Html
vnameHtml VName
v Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t1') Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" -> " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t2'
Maybe VName
Nothing ->
Html
t1' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
" -> " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t2'
TESum [(Name, [TypeExp Info VName])]
cs SrcLoc
_ -> [Html] -> Html
pipes ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((Name, [TypeExp Info VName])
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [(Name, [TypeExp Info VName])]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (Name, [TypeExp Info VName])
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
ppClause [(Name, [TypeExp Info VName])]
cs
where
ppClause :: (Name, [TypeExp Info VName])
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
ppClause (Name
n, [TypeExp Info VName]
ts) = Html -> [Html] -> Html
joinBy Html
" " ([Html] -> Html) -> ([Html] -> [Html]) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Name -> Html
ppConstr Name
n :) ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [TypeExp Info VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml [TypeExp Info VName]
ts
ppConstr :: Name -> Html
ppConstr Name
name = Html
"#" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Char] -> Html
forall a. ToMarkup a => a -> Html
toHtml (Name -> [Char]
nameToString Name
name)
TEDim [VName]
dims TypeExp Info VName
t SrcLoc
_ -> do
Html
t' <- TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp Info VName
t
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
"?" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ((VName -> Html) -> [VName] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map (Html -> Html
brackets (Html -> Html) -> (VName -> Html) -> VName -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Html
renderName (Name -> Html) -> (VName -> Name) -> VName -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VName -> Name
baseName) [VName]
dims) Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
"." Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t'
qualNameHtml :: QualName VName -> DocM Html
qualNameHtml :: QualName VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
qualNameHtml (QualName [VName]
names vname :: VName
vname@(VName Name
name Int
tag)) =
if Int
tag Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
maxIntrinsicTag
then Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Name -> Html
renderName Name
name
else Maybe [Char] -> Html
f (Maybe [Char] -> Html)
-> ReaderT
Context (WriterT Documented (Writer Warnings)) (Maybe [Char])
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ReaderT
Context (WriterT Documented (Writer Warnings)) (Maybe [Char])
ref
where
prefix :: Html
prefix :: Html
prefix = (VName -> Html) -> [VName] -> Html
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
".") (Html -> Html) -> (VName -> Html) -> VName -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Html
renderName (Name -> Html) -> (VName -> Name) -> VName -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VName -> Name
baseName) [VName]
names
f :: Maybe [Char] -> Html
f (Just [Char]
s) = Html -> Html
H.a (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.href ([Char] -> AttributeValue
forall a. IsString a => [Char] -> a
fromString [Char]
s) (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
prefix Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Name -> Html
renderName Name
name
f Maybe [Char]
Nothing = Html
prefix Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Name -> Html
renderName Name
name
ref :: ReaderT
Context (WriterT Documented (Writer Warnings)) (Maybe [Char])
ref = do
Bool
boring <- (Context -> Bool)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Bool
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ((Context -> Bool)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Bool)
-> (Context -> Bool)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Bool
forall a b. (a -> b) -> a -> b
$ VName -> NoLink -> Bool
forall a. Ord a => a -> Set a -> Bool
S.member VName
vname (NoLink -> Bool) -> (Context -> NoLink) -> Context -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Context -> NoLink
ctxNoLink
if Bool
boring
then Maybe [Char]
-> ReaderT
Context (WriterT Documented (Writer Warnings)) (Maybe [Char])
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe [Char]
forall a. Maybe a
Nothing
else [Char] -> Maybe [Char]
forall a. a -> Maybe a
Just ([Char] -> Maybe [Char])
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
-> ReaderT
Context (WriterT Documented (Writer Warnings)) (Maybe [Char])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
vnameLink VName
vname
vnameLink :: VName -> DocM String
vnameLink :: VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
vnameLink VName
vname = do
[Char]
current <- (Context -> [Char])
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks Context -> [Char]
ctxCurrent
[Char]
file <- (Context -> [Char])
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ((Context -> [Char])
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char])
-> (Context -> [Char])
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
forall a b. (a -> b) -> a -> b
$ [Char]
-> (([Char], Namespace) -> [Char])
-> Maybe ([Char], Namespace)
-> [Char]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [Char]
current ([Char], Namespace) -> [Char]
forall a b. (a, b) -> a
fst (Maybe ([Char], Namespace) -> [Char])
-> (Context -> Maybe ([Char], Namespace)) -> Context -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VName -> FileMap -> Maybe ([Char], Namespace)
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup VName
vname (FileMap -> Maybe ([Char], Namespace))
-> (Context -> FileMap) -> Context -> Maybe ([Char], Namespace)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Context -> FileMap
ctxFileMap
[Char]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([Char]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char])
-> [Char]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
forall a b. (a -> b) -> a -> b
$ VName -> [Char] -> [Char] -> [Char]
vnameLink' VName
vname [Char]
current [Char]
file
vnameLink' :: VName -> String -> String -> String
vnameLink' :: VName -> [Char] -> [Char] -> [Char]
vnameLink' (VName Name
_ Int
tag) [Char]
current [Char]
file =
if [Char]
file [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
current
then [Char]
"#" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ Int -> [Char]
forall a. Show a => a -> [Char]
show Int
tag
else [Char] -> [Char] -> [Char]
relativise [Char]
file [Char]
current [Char] -> [Char] -> [Char]
-<.> [Char]
".html#" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ Int -> [Char]
forall a. Show a => a -> [Char]
show Int
tag
paramHtml :: Pat ParamType -> DocM Html
paramHtml :: PatBase Info VName ParamType
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
paramHtml PatBase Info VName ParamType
pat = do
let (PName
pat_param, Diet
d, StructType
t) = PatBase Info VName ParamType -> (PName, Diet, StructType)
patternParam PatBase Info VName ParamType
pat
Html
t' <- TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeHtml (TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> TypeBase Size Uniqueness
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ (NoUniqueness -> Uniqueness)
-> StructType -> TypeBase Size Uniqueness
forall b c a. (b -> c) -> TypeBase a b -> TypeBase a c
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second (Uniqueness -> NoUniqueness -> Uniqueness
forall a b. a -> b -> a
const Uniqueness
Nonunique) StructType
t
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ case PName
pat_param of
Named VName
v -> Html -> Html
parens (VName -> Html
vnameHtml VName
v Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Diet -> Html
dietHtml Diet
d Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t')
PName
Unnamed -> Html
t'
relativise :: FilePath -> FilePath -> FilePath
relativise :: [Char] -> [Char] -> [Char]
relativise [Char]
dest [Char]
src =
[[Char]] -> [Char]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (Int -> [Char] -> [[Char]]
forall a. Int -> a -> [a]
replicate ([[Char]] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length ([Char] -> [[Char]]
splitPath [Char]
src) Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) [Char]
"../") [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char] -> [Char] -> [Char]
makeRelative [Char]
"/" [Char]
dest
dimDeclHtml :: Size -> DocM Html
dimDeclHtml :: Size -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
dimDeclHtml = Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Size -> Html)
-> Size
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Html -> Html
brackets (Html -> Html) -> (Size -> Html) -> Size -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Html
forall a. ToMarkup a => a -> Html
toHtml ([Char] -> Html) -> (Size -> [Char]) -> Size -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Size -> [Char]
forall a. Pretty a => a -> [Char]
prettyString
dimExpHtml :: SizeExp Info VName -> DocM Html
dimExpHtml :: SizeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
dimExpHtml (SizeExpAny SrcLoc
_) = Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
brackets Html
forall a. Monoid a => a
mempty
dimExpHtml (SizeExp Size
e SrcLoc
_) = Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
brackets (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ [Char] -> Html
forall a. ToMarkup a => a -> Html
toHtml ([Char] -> Html) -> [Char] -> Html
forall a b. (a -> b) -> a -> b
$ Size -> [Char]
forall a. Pretty a => a -> [Char]
prettyString Size
e
typeArgExpHtml :: TypeArgExp Info VName -> DocM Html
typeArgExpHtml :: TypeArgExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeArgExpHtml (TypeArgExpSize SizeExp Info VName
d) = SizeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
dimExpHtml SizeExp Info VName
d
typeArgExpHtml (TypeArgExpType TypeExp Info VName
d) = TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp Info VName
d
typeParamHtml :: TypeParam -> Html
typeParamHtml :: TypeParamBase VName -> Html
typeParamHtml (TypeParamDim VName
name SrcLoc
_) =
Html -> Html
brackets (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ VName -> Html
vnameHtml VName
name
typeParamHtml (TypeParamType Liftedness
l VName
name SrcLoc
_) =
Html
"'" Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Char] -> Html
forall a. IsString a => [Char] -> a
fromString (Liftedness -> [Char]
forall a. Pretty a => a -> [Char]
prettyString Liftedness
l) Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> VName -> Html
vnameHtml VName
name
typeAbbrevHtml :: Liftedness -> Html -> [TypeParam] -> Html
typeAbbrevHtml :: Liftedness -> Html -> [TypeParamBase VName] -> Html
typeAbbrevHtml Liftedness
l Html
name [TypeParamBase VName]
params =
Html
what Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ((TypeParamBase VName -> Html) -> [TypeParamBase VName] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map ((Html
" " <>) (Html -> Html)
-> (TypeParamBase VName -> Html) -> TypeParamBase VName -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeParamBase VName -> Html
typeParamHtml) [TypeParamBase VName]
params)
where
what :: Html
what = [Char] -> Html
keyword ([Char] -> Html) -> [Char] -> Html
forall a b. (a -> b) -> a -> b
$ [Char]
"type" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ Liftedness -> [Char]
forall a. Pretty a => a -> [Char]
prettyString Liftedness
l [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
" "
docHtml :: Maybe DocComment -> DocM Html
docHtml :: Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
docHtml (Just (DocComment Text
doc SrcLoc
loc)) =
Text -> Html
H.preEscapedText
(Text -> Html) -> ([Char] -> Text) -> [Char] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [CMarkOption] -> [CMarkExtension] -> Text -> Text
GFM.commonmarkToHtml [] [CMarkExtension
GFM.extAutolink]
(Text -> Text) -> ([Char] -> Text) -> [Char] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Text
T.pack
([Char] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SrcLoc
-> [Char]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
identifierLinks SrcLoc
loc (Text -> [Char]
T.unpack Text
doc)
docHtml Maybe DocComment
Nothing = Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Html
forall a. Monoid a => a
mempty
identifierLinks :: SrcLoc -> String -> DocM String
identifierLinks :: SrcLoc
-> [Char]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
identifierLinks SrcLoc
_ [] = [Char]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
identifierLinks SrcLoc
loc [Char]
s
| Just (([Char]
name, [Char]
namespace, Maybe [Char]
file), [Char]
s') <- [Char] -> Maybe (([Char], [Char], Maybe [Char]), [Char])
identifierReference [Char]
s = do
let proceed :: [Char]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
proceed [Char]
x = ([Char]
x <>) ([Char] -> [Char])
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SrcLoc
-> [Char]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
identifierLinks SrcLoc
loc [Char]
s'
unknown :: ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
unknown = [Char]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
proceed ([Char]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char])
-> [Char]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
forall a b. (a -> b) -> a -> b
$ [Char]
"`" [Char] -> [Char] -> [Char]
forall a. Semigroup a => a -> a -> a
<> [Char]
name [Char] -> [Char] -> [Char]
forall a. Semigroup a => a -> a -> a
<> [Char]
"`"
case [Char] -> Maybe Namespace
forall {a}. (Eq a, IsString a) => a -> Maybe Namespace
knownNamespace [Char]
namespace of
Just Namespace
namespace' -> do
Maybe VName
maybe_v <- (Namespace, [Char], Maybe [Char]) -> DocM (Maybe VName)
lookupName (Namespace
namespace', [Char]
name, Maybe [Char]
file)
case Maybe VName
maybe_v of
Maybe VName
Nothing -> do
SrcLoc -> Doc () -> DocM ()
warn SrcLoc
loc (Doc () -> DocM ()) -> Doc () -> DocM ()
forall a b. (a -> b) -> a -> b
$
Doc ()
"Identifier '"
Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> [Char] -> Doc ()
forall a. IsString a => [Char] -> a
fromString [Char]
name
Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> Doc ()
"' not found in namespace '"
Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> [Char] -> Doc ()
forall a. IsString a => [Char] -> a
fromString [Char]
namespace
Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> Doc ()
"'"
Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> [Char] -> Doc ()
forall a. IsString a => [Char] -> a
fromString ([Char] -> ([Char] -> [Char]) -> Maybe [Char] -> [Char]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [Char]
"" ([Char]
" in file " <>) Maybe [Char]
file)
Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> Doc ()
"."
ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
unknown
Just VName
v' -> do
[Char]
link <- VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
vnameLink VName
v'
[Char]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
proceed ([Char]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char])
-> [Char]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
forall a b. (a -> b) -> a -> b
$ [Char]
"[`" [Char] -> [Char] -> [Char]
forall a. Semigroup a => a -> a -> a
<> [Char]
name [Char] -> [Char] -> [Char]
forall a. Semigroup a => a -> a -> a
<> [Char]
"`](" [Char] -> [Char] -> [Char]
forall a. Semigroup a => a -> a -> a
<> [Char]
link [Char] -> [Char] -> [Char]
forall a. Semigroup a => a -> a -> a
<> [Char]
")"
Maybe Namespace
_ -> do
SrcLoc -> Doc () -> DocM ()
warn SrcLoc
loc (Doc () -> DocM ()) -> Doc () -> DocM ()
forall a b. (a -> b) -> a -> b
$ Doc ()
"Unknown namespace '" Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> [Char] -> Doc ()
forall a. IsString a => [Char] -> a
fromString [Char]
namespace Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> Doc ()
"'."
ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
unknown
where
knownNamespace :: a -> Maybe Namespace
knownNamespace a
"term" = Namespace -> Maybe Namespace
forall a. a -> Maybe a
Just Namespace
Term
knownNamespace a
"mtype" = Namespace -> Maybe Namespace
forall a. a -> Maybe a
Just Namespace
Signature
knownNamespace a
"type" = Namespace -> Maybe Namespace
forall a. a -> Maybe a
Just Namespace
Type
knownNamespace a
_ = Maybe Namespace
forall a. Maybe a
Nothing
identifierLinks SrcLoc
loc (Char
c : [Char]
s') = (Char
c :) ([Char] -> [Char])
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SrcLoc
-> [Char]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
identifierLinks SrcLoc
loc [Char]
s'
lookupName :: (Namespace, String, Maybe FilePath) -> DocM (Maybe VName)
lookupName :: (Namespace, [Char], Maybe [Char]) -> DocM (Maybe VName)
lookupName (Namespace
namespace, [Char]
name, Maybe [Char]
file) = do
[Char]
current <- (Context -> [Char])
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Char]
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks Context -> [Char]
ctxCurrent
let file' :: Maybe ImportName
file' = ImportName -> [Char] -> ImportName
mkImportFrom ([Char] -> ImportName
mkInitialImport [Char]
current) ([Char] -> ImportName) -> Maybe [Char] -> Maybe ImportName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe [Char]
file
Maybe Env
env <- Maybe ImportName -> DocM (Maybe Env)
lookupEnvForFile Maybe ImportName
file'
case (Namespace, Name)
-> Map (Namespace, Name) (QualName VName) -> Maybe (QualName VName)
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup (Namespace
namespace, [Char] -> Name
nameFromString [Char]
name) (Map (Namespace, Name) (QualName VName) -> Maybe (QualName VName))
-> (Env -> Map (Namespace, Name) (QualName VName))
-> Env
-> Maybe (QualName VName)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Env -> Map (Namespace, Name) (QualName VName)
envNameMap (Env -> Maybe (QualName VName))
-> Maybe Env -> Maybe (QualName VName)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Maybe Env
env of
Maybe (QualName VName)
Nothing -> Maybe VName -> DocM (Maybe VName)
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe VName
forall a. Maybe a
Nothing
Just QualName VName
qn -> Maybe VName -> DocM (Maybe VName)
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe VName -> DocM (Maybe VName))
-> Maybe VName -> DocM (Maybe VName)
forall a b. (a -> b) -> a -> b
$ VName -> Maybe VName
forall a. a -> Maybe a
Just (VName -> Maybe VName) -> VName -> Maybe VName
forall a b. (a -> b) -> a -> b
$ QualName VName -> VName
forall vn. QualName vn -> vn
qualLeaf QualName VName
qn
lookupEnvForFile :: Maybe ImportName -> DocM (Maybe Env)
lookupEnvForFile :: Maybe ImportName -> DocM (Maybe Env)
lookupEnvForFile Maybe ImportName
Nothing = (Context -> Maybe Env) -> DocM (Maybe Env)
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ((Context -> Maybe Env) -> DocM (Maybe Env))
-> (Context -> Maybe Env) -> DocM (Maybe Env)
forall a b. (a -> b) -> a -> b
$ Env -> Maybe Env
forall a. a -> Maybe a
Just (Env -> Maybe Env) -> (Context -> Env) -> Context -> Maybe Env
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FileModule -> Env
fileEnv (FileModule -> Env) -> (Context -> FileModule) -> Context -> Env
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Context -> FileModule
ctxFileMod
lookupEnvForFile (Just ImportName
file) = (Context -> Maybe Env) -> DocM (Maybe Env)
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ((Context -> Maybe Env) -> DocM (Maybe Env))
-> (Context -> Maybe Env) -> DocM (Maybe Env)
forall a b. (a -> b) -> a -> b
$ (FileModule -> Env) -> Maybe FileModule -> Maybe Env
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap FileModule -> Env
fileEnv (Maybe FileModule -> Maybe Env)
-> (Context -> Maybe FileModule) -> Context -> Maybe Env
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ImportName -> Imports -> Maybe FileModule
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup ImportName
file (Imports -> Maybe FileModule)
-> (Context -> Imports) -> Context -> Maybe FileModule
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Context -> Imports
ctxImports
describeGeneric ::
VName ->
IndexWhat ->
Maybe DocComment ->
(Html -> DocM Html) ->
DocM Html
describeGeneric :: VName
-> IndexWhat
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGeneric VName
name IndexWhat
what Maybe DocComment
doc Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
f = do
Html
name' <- Html -> Html
H.span (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"decl_name" (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> VName
-> IndexWhat
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
vnameDescDef VName
name IndexWhat
what
Html
decl_type <- Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
f Html
name'
Html
doc' <- Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
docHtml Maybe DocComment
doc
let decl_doc :: Html
decl_doc = Html -> Html
H.dd (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"desc_doc" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
doc'
decl_header :: Html
decl_header =
(Html -> Html
H.dt (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"desc_header") (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
VName -> Html
vnameSynopsisRef VName
name Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
decl_type
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
decl_header Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
decl_doc
describeGenericMod ::
VName ->
IndexWhat ->
ModTypeExp ->
Maybe DocComment ->
(Html -> DocM Html) ->
DocM Html
describeGenericMod :: VName
-> IndexWhat
-> ModTypeExpBase Info VName
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGenericMod VName
name IndexWhat
what ModTypeExpBase Info VName
se Maybe DocComment
doc Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
f = do
Html
name' <- Html -> Html
H.span (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"decl_name" (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> VName
-> IndexWhat
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
vnameDescDef VName
name IndexWhat
what
Html
decl_type <- Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
f Html
name'
Html
doc' <- case ModTypeExpBase Info VName
se of
ModTypeSpecs [SpecBase Info VName]
specs SrcLoc
_ -> Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
(<>) (Html -> Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT
Context (WriterT Documented (Writer Warnings)) (Html -> Html)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
docHtml Maybe DocComment
doc ReaderT
Context (WriterT Documented (Writer Warnings)) (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b.
ReaderT Context (WriterT Documented (Writer Warnings)) (a -> b)
-> ReaderT Context (WriterT Documented (Writer Warnings)) a
-> ReaderT Context (WriterT Documented (Writer Warnings)) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [SpecBase Info VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeSpecs [SpecBase Info VName]
specs
ModTypeExpBase Info VName
_ -> Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
docHtml Maybe DocComment
doc
let decl_doc :: Html
decl_doc = Html -> Html
H.dd (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"desc_doc" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
doc'
decl_header :: Html
decl_header =
(Html -> Html
H.dt (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"desc_header") (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
VName -> Html
vnameSynopsisRef VName
name Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
decl_type
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
decl_header Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
decl_doc
describeDecs :: [Dec] -> DocM Html
describeDecs :: [Dec]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeDecs [Dec]
decs = do
NoLink
visible <- (Context -> NoLink)
-> ReaderT Context (WriterT Documented (Writer Warnings)) NoLink
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks Context -> NoLink
ctxVisibleMTys
Html -> Html
H.dl (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat
([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [ReaderT Context (WriterT Documented (Writer Warnings)) Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM
((Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b.
(a -> b)
-> ReaderT Context (WriterT Documented (Writer Warnings)) a
-> ReaderT Context (WriterT Documented (Writer Warnings)) b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Html -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html -> Html
H.div (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"decl_description")
((Dec
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> [Dec]
-> [ReaderT Context (WriterT Documented (Writer Warnings)) Html]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (NoLink
-> Dec
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
describeDec NoLink
visible) [Dec]
decs)
describeDec :: S.Set VName -> Dec -> Maybe (DocM Html)
describeDec :: NoLink
-> Dec
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
describeDec NoLink
_ (ValDec ValBindBase Info VName
vb) = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$
VName
-> IndexWhat
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGeneric (ValBindBase Info VName -> VName
forall (f :: * -> *) vn. ValBindBase f vn -> vn
valBindName ValBindBase Info VName
vb) (ValBindBase Info VName -> IndexWhat
valBindWhat ValBindBase Info VName
vb) (ValBindBase Info VName -> Maybe DocComment
forall (f :: * -> *) vn. ValBindBase f vn -> Maybe DocComment
valBindDoc ValBindBase Info VName
vb) ((Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ \Html
name -> do
(Html
lhs, Html
mhs, Html
rhs) <- Html -> ValBindBase Info VName -> DocM (Html, Html, Html)
valBindHtml Html
name ValBindBase Info VName
vb
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
lhs Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
mhs Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
rhs
describeDec NoLink
_ (TypeDec TypeBindBase Info VName
vb) =
ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$
VName
-> IndexWhat
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGeneric (TypeBindBase Info VName -> VName
forall (f :: * -> *) vn. TypeBindBase f vn -> vn
typeAlias TypeBindBase Info VName
vb) IndexWhat
IndexType (TypeBindBase Info VName -> Maybe DocComment
forall (f :: * -> *) vn. TypeBindBase f vn -> Maybe DocComment
typeDoc TypeBindBase Info VName
vb) (Html
-> TypeBindBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
`typeBindHtml` TypeBindBase Info VName
vb)
describeDec NoLink
_ (ModTypeDec (ModTypeBind VName
name ModTypeExpBase Info VName
se Maybe DocComment
doc SrcLoc
_)) = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$
VName
-> IndexWhat
-> ModTypeExpBase Info VName
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGenericMod VName
name IndexWhat
IndexModuleType ModTypeExpBase Info VName
se Maybe DocComment
doc ((Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ \Html
name' ->
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ [Char] -> Html
keyword [Char]
"module type " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name'
describeDec NoLink
_ (ModDec ModBindBase Info VName
mb) = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$
VName
-> IndexWhat
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGeneric (ModBindBase Info VName -> VName
forall (f :: * -> *) vn. ModBindBase f vn -> vn
modName ModBindBase Info VName
mb) IndexWhat
IndexModule (ModBindBase Info VName -> Maybe DocComment
forall (f :: * -> *) vn. ModBindBase f vn -> Maybe DocComment
modDoc ModBindBase Info VName
mb) ((Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ \Html
name' ->
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ [Char] -> Html
keyword [Char]
"module " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name'
describeDec NoLink
_ OpenDec {} = Maybe (ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. Maybe a
Nothing
describeDec NoLink
visible (LocalDec (ModTypeDec (ModTypeBind VName
name ModTypeExpBase Info VName
se Maybe DocComment
doc SrcLoc
_)) SrcLoc
_)
| VName
name VName -> NoLink -> Bool
forall a. Ord a => a -> Set a -> Bool
`S.member` NoLink
visible = ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. a -> Maybe a
Just (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html))
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> Maybe
(ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a b. (a -> b) -> a -> b
$
VName
-> IndexWhat
-> ModTypeExpBase Info VName
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGenericMod VName
name IndexWhat
IndexModuleType ModTypeExpBase Info VName
se Maybe DocComment
doc ((Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ \Html
name' ->
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ [Char] -> Html
keyword [Char]
"local module type " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name'
describeDec NoLink
_ LocalDec {} = Maybe (ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. Maybe a
Nothing
describeDec NoLink
_ ImportDec {} = Maybe (ReaderT Context (WriterT Documented (Writer Warnings)) Html)
forall a. Maybe a
Nothing
valBindWhat :: ValBind -> IndexWhat
valBindWhat :: ValBindBase Info VName -> IndexWhat
valBindWhat ValBindBase Info VName
vb
| [PatBase Info VName ParamType] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (ValBindBase Info VName -> [PatBase Info VName ParamType]
forall (f :: * -> *) vn.
ValBindBase f vn -> [PatBase f vn ParamType]
valBindParams ValBindBase Info VName
vb),
RetType [VName]
_ TypeBase Size Uniqueness
t <- Info ResRetType -> ResRetType
forall a. Info a -> a
unInfo (Info ResRetType -> ResRetType) -> Info ResRetType -> ResRetType
forall a b. (a -> b) -> a -> b
$ ValBindBase Info VName -> Info ResRetType
forall (f :: * -> *) vn. ValBindBase f vn -> f ResRetType
valBindRetType ValBindBase Info VName
vb,
TypeBase Size Uniqueness -> Bool
forall dim as. TypeBase dim as -> Bool
orderZero TypeBase Size Uniqueness
t =
IndexWhat
IndexValue
| Bool
otherwise =
IndexWhat
IndexFunction
describeSpecs :: [Spec] -> DocM Html
describeSpecs :: [SpecBase Info VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeSpecs [SpecBase Info VName]
specs =
Html -> Html
H.dl (Html -> Html) -> ([Html] -> Html) -> [Html] -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (SpecBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> [SpecBase Info VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) [Html]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM SpecBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeSpec [SpecBase Info VName]
specs
describeSpec :: Spec -> DocM Html
describeSpec :: SpecBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeSpec (ValSpec VName
name [TypeParamBase VName]
tparams TypeExp Info VName
t Info StructType
_ Maybe DocComment
doc SrcLoc
_) =
VName
-> IndexWhat
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGeneric VName
name IndexWhat
what Maybe DocComment
doc ((Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ \Html
name' -> do
let tparams' :: Html
tparams' = [Html] -> Html
forall a. Monoid a => [a] -> a
mconcat ([Html] -> Html) -> [Html] -> Html
forall a b. (a -> b) -> a -> b
$ (TypeParamBase VName -> Html) -> [TypeParamBase VName] -> [Html]
forall a b. (a -> b) -> [a] -> [b]
map ((Html
" " <>) (Html -> Html)
-> (TypeParamBase VName -> Html) -> TypeParamBase VName -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeParamBase VName -> Html
typeParamHtml) [TypeParamBase VName]
tparams
Html
t' <- [VName]
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a. [VName] -> DocM a -> DocM a
noLink ((TypeParamBase VName -> VName) -> [TypeParamBase VName] -> [VName]
forall a b. (a -> b) -> [a] -> [b]
map TypeParamBase VName -> VName
forall vn. TypeParamBase vn -> vn
typeParamName [TypeParamBase VName]
tparams) (ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ TypeExp Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
typeExpHtml TypeExp Info VName
t
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ [Char] -> Html
keyword [Char]
"val " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
tparams' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
t'
where
what :: IndexWhat
what =
case TypeExp Info VName
t of
TEArrow {} -> IndexWhat
IndexFunction
TypeExp Info VName
_ -> IndexWhat
IndexValue
describeSpec (TypeAbbrSpec TypeBindBase Info VName
vb) =
VName
-> IndexWhat
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGeneric (TypeBindBase Info VName -> VName
forall (f :: * -> *) vn. TypeBindBase f vn -> vn
typeAlias TypeBindBase Info VName
vb) IndexWhat
IndexType (TypeBindBase Info VName -> Maybe DocComment
forall (f :: * -> *) vn. TypeBindBase f vn -> Maybe DocComment
typeDoc TypeBindBase Info VName
vb) (Html
-> TypeBindBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
`typeBindHtml` TypeBindBase Info VName
vb)
describeSpec (TypeSpec Liftedness
l VName
name [TypeParamBase VName]
tparams Maybe DocComment
doc SrcLoc
_) =
VName
-> IndexWhat
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGeneric VName
name IndexWhat
IndexType Maybe DocComment
doc ((Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Html -> Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\Html
name' -> Liftedness -> Html -> [TypeParamBase VName] -> Html
typeAbbrevHtml Liftedness
l Html
name' [TypeParamBase VName]
tparams)
describeSpec (ModSpec VName
name ModTypeExpBase Info VName
se Maybe DocComment
doc SrcLoc
_) =
VName
-> IndexWhat
-> ModTypeExpBase Info VName
-> Maybe DocComment
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
describeGenericMod VName
name IndexWhat
IndexModule ModTypeExpBase Info VName
se Maybe DocComment
doc ((Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ \Html
name' ->
case ModTypeExpBase Info VName
se of
ModTypeSpecs {} -> Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ [Char] -> Html
keyword [Char]
"module " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name'
ModTypeExpBase Info VName
_ -> do
Html
se' <- ModTypeExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisModTypeExp ModTypeExpBase Info VName
se
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ [Char] -> Html
keyword [Char]
"module " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
name' Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
": " Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
se'
describeSpec (IncludeSpec ModTypeExpBase Info VName
sig SrcLoc
_) = do
Html
sig' <- ModTypeExpBase Info VName
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
synopsisModTypeExp ModTypeExpBase Info VName
sig
Html
doc' <- Maybe DocComment
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
docHtml Maybe DocComment
forall a. Maybe a
Nothing
let decl_header :: Html
decl_header =
(Html -> Html
H.dt (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"desc_header") (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$
(Html -> Html
H.span (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"synopsis_link") Html
forall a. Monoid a => a
mempty
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> [Char] -> Html
keyword [Char]
"include "
Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
sig'
decl_doc :: Html
decl_doc = Html -> Html
H.dd (Html -> Html) -> Attribute -> Html -> Html
forall h. Attributable h => h -> Attribute -> h
! AttributeValue -> Attribute
A.class_ AttributeValue
"desc_doc" (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Html
doc'
Html -> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a.
a -> ReaderT Context (WriterT Documented (Writer Warnings)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html)
-> Html
-> ReaderT Context (WriterT Documented (Writer Warnings)) Html
forall a b. (a -> b) -> a -> b
$ Html
decl_header Html -> Html -> Html
forall a. Semigroup a => a -> a -> a
<> Html
decl_doc