/usr/share/doc/libghc-th-reify-many-doc/html/Language-Haskell-TH-ReifyMany.html is in libghc-th-reify-many-doc 0.1.6-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Language.Haskell.TH.ReifyMany</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="file:///usr/share/javascript/mathjax/MathJax.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Language-Haskell-TH-ReifyMany.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Language-Haskell-TH-ReifyMany.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">th-reify-many-0.1.6: Recurseively reify template haskell datatype info</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><p class="caption">Language.Haskell.TH.ReifyMany</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p><code>th-reify-many</code> provides functions for recursively reifying top
level declarations. The main intended use case is for enumerating
the names of datatypes reachable from an initial datatype, and
passing these names to some function which generates instances.</p><p>For example, in order to define <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#v:Lift">Lift</a></code>
instances for two mutually recursive datatypes, I could write
something like:</p><pre>{-# LANGUAGE TemplateHaskell #-}
import Language.Haskell.TH.ReifyMany (reifyManyWithoutInstances)
import Language.Haskell.TH.Lift (Lift(..), deriveLiftMany)
data A = A B
data B = B Int
$(reifyManyWithoutInstances ''Lift [''A] (const True) >>= deriveLiftMany)</pre><p>One interesting feature of this is that it attempts to omit the
types which already have an instance defined. For example, if
<code>$(deriveLift ''B)</code> is used before <code>deriveLiftMany</code>, it will omit
the instance for B.</p><p>Of course, the intended usecase for this involves many more
datatypes - for example, syntax trees such as those found in TH.</p><p>Note that <code><a href="Language-Haskell-TH-ReifyMany.html#v:reifyManyWithoutInstances">reifyManyWithoutInstances</a></code> is rather imperfect in its
testing of whether an instance exists, and whether an instance
should exist. See this function's docs for details.</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><a href="#v:reifyManyWithoutInstances">reifyManyWithoutInstances</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>] -> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a>) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>]</li><li class="src short"><a href="#v:reifyManyTyCons">reifyManyTyCons</a> :: ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a>, [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>])) -> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Info">Info</a>)]</li><li class="src short"><a href="#v:reifyMany">reifyMany</a> :: ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Info">Info</a>) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a>, [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>])) -> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Info">Info</a>)]</li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><a id="v:reifyManyWithoutInstances" class="def">reifyManyWithoutInstances</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>] -> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a>) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>] <a href="src/Language-Haskell-TH-ReifyMany.html#reifyManyWithoutInstances" class="link">Source</a> <a href="#v:reifyManyWithoutInstances" class="selflink">#</a></p><div class="doc"><p>Recursively enumerates type constructor declarations, halting
when datatypes appear to already have an instance for the typeclass
specified by the first <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></code> parameter. It guesses that an
instance exists for a given datatype if it's used in the top
constructor of any of its parameters (see <code><a href="Language-Haskell-TH-ReifyMany-Internal.html#v:instanceMatches">instanceMatches</a></code>).</p><p>This function is useful for bulk defining typeclass instances like
<code>Binary</code>, <code>Lift</code>, <code>Data</code>, <code>Typeable</code>, etc. It isn't very clever,
though - in particular it has the following limitations:</p><ul><li>It only works well when type constructors mentioned in
fields should all have instances defined for them.</li><li>It ignores data type / constructor constraints.</li><li>It ignores data / type families.</li></ul><p>It also takes a user-defined predicate, which is useful in
situations where this attempts to descend into datatypes which do
not need instances defined for them.</p><p>Note that this will always initially yield the <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></code>s of the
initial types, regardless of whether they are instances or not.</p></div></div><div class="top"><p class="src"><a id="v:reifyManyTyCons" class="def">reifyManyTyCons</a> :: ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a>, [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>])) -> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Info">Info</a>)] <a href="src/Language-Haskell-TH-ReifyMany.html#reifyManyTyCons" class="link">Source</a> <a href="#v:reifyManyTyCons" class="selflink">#</a></p><div class="doc"><p>Like <code><a href="Language-Haskell-TH-ReifyMany.html#v:reifyMany">reifyMany</a></code>, but specialized for recursively enumerating
type constructor declarations, omitting <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#v:PrimTyConI">PrimTyConI</a></code>.</p><p>In order to have this behave like <code><a href="Language-Haskell-TH-ReifyMany.html#v:reifyManyWithoutInstances">reifyManyWithoutInstances</a></code>, but
not do any instance filtering, use it with the <code><a href="Language-Haskell-TH-ReifyMany-Internal.html#v:isDataDec">isDataDec</a></code> and
<code><a href="Language-Haskell-TH-ReifyMany-Internal.html#v:decConcreteNames">decConcreteNames</a></code> internal utilities. For example:</p><pre>{-# LANGUAGE TemplateHaskell #-}
import Language.Haskell.TH
import Language.Haskell.TH.ReifyMany
import Language.Haskell.TH.ReifyMany.Internal
$(do results <- reifyManyTyCons
(\(_, dec) -> return (isDataDec dec, decConcreteNames dec))
[''Exp]
-- Display the results
reportError (show (map fst results))
-- This TH splice doesn't generate any code.
return []
)</pre></div></div><div class="top"><p class="src"><a id="v:reifyMany" class="def">reifyMany</a> :: ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Info">Info</a>) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a>, [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>])) -> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Info">Info</a>)] <a href="src/Language-Haskell-TH-ReifyMany.html#reifyMany" class="link">Source</a> <a href="#v:reifyMany" class="selflink">#</a></p><div class="doc"><p>Starting from a set of initial top level declarations, specified
by <code>[Name]</code>, recursively enumerate other related declarations. The
provided function determines whether the current info be included
in the list of results, and which <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></code>s to lookup next. This
function handles keeping track of which <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></code>s have already been
visited.</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|