A more generic helper function for renderTicketDetail splices (with RankNTypes?)
This one is just to satisfy my curiosity. Consider the function used with mapV
in renderTicketDetail
which uses callTemplate "_null"
for missing values.
Would it be possible to write it to be more generic? Currently its first parameter is (TicketComicDetail -> Maybe Text, Text -> Text)
. I would like it to be (TicketComicDetail -> Maybe a, a -> Text)
so that I could use both (bookmarkRegexp, HTML.text)
and (crawlParams, T.pack . show . parserType)
as values for my splices instead of having to write (fmap (T.pack . show . parserType) . crawlParams, id)
.
If I try to use this function in the place it'll coerce my a
to be of some specific type for all mapped values:
foo :: forall a n. Monad n
=> (TicketComicDetail -> Maybe a, a -> Text)
-> RuntimeSplice n ((Bool, Int), TicketComicDetail)
-> Splice n
foo (f, s) n = do
nul <- callTemplate "_null"
return $ yieldRuntime $
f . snd <$> n >>=
maybe (codeGen nul) (return . textSplice s)