/usr/share/doc/libghc-generics-sop-doc/html/Generics-SOP-NS.html is in libghc-generics-sop-doc 0.2.0.0-1.
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 | <!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>Generics.SOP.NS</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Generics-SOP-NS.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Generics-SOP-NS.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">generics-sop-0.2.0.0: Generic Programming using True Sums of Products</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">Generics.SOP.NS</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Datatypes</a></li><li><a href="#g:2">Constructing sums</a></li><li><a href="#g:3">Application</a></li><li><a href="#g:4">Lifting / mapping</a></li><li><a href="#g:5">Dealing with <code><code>All</code> c</code></a></li><li><a href="#g:6">Collapsing</a></li><li><a href="#g:7">Sequencing</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>n-ary sums (and sums of products)</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"><span class="keyword">data</span> <a href="#t:NS">NS</a> :: (k -> *) -> [k] -> * <span class="keyword">where</span><ul class="subs"><li><a href="#v:Z">Z</a> :: f x -> <a href="Generics-SOP-NS.html#t:NS">NS</a> f (x : xs)</li><li><a href="#v:S">S</a> :: <a href="Generics-SOP-NS.html#t:NS">NS</a> f xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> f (x : xs)</li></ul></li><li class="src short"><span class="keyword">newtype</span> <a href="#t:SOP">SOP</a> f xss = <a href="#v:SOP">SOP</a> (<a href="Generics-SOP-NS.html#t:NS">NS</a> (<a href="Generics-SOP-NP.html#t:NP">NP</a> f) xss)</li><li class="src short"><a href="#v:unSOP">unSOP</a> :: <a href="Generics-SOP-NS.html#t:SOP">SOP</a> f xss -> <a href="Generics-SOP-NS.html#t:NS">NS</a> (<a href="Generics-SOP-NP.html#t:NP">NP</a> f) xss</li><li class="src short"><span class="keyword">type</span> <a href="#t:Injection">Injection</a> f xs = f <a href="Generics-SOP-Classes.html#t:-45-.-45--62-">-.-></a> <a href="Generics-SOP-BasicFunctors.html#t:K">K</a> (<a href="Generics-SOP-NS.html#t:NS">NS</a> f xs)</li><li class="src short"><a href="#v:injections">injections</a> :: <span class="keyword">forall</span> xs f. <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xs => <a href="Generics-SOP-NP.html#t:NP">NP</a> (<a href="Generics-SOP-NS.html#t:Injection">Injection</a> f xs) xs</li><li class="src short"><a href="#v:shift">shift</a> :: <a href="Generics-SOP-NS.html#t:Injection">Injection</a> f xs a -> <a href="Generics-SOP-NS.html#t:Injection">Injection</a> f (x : xs) a</li><li class="src short"><a href="#v:apInjs_NP">apInjs_NP</a> :: <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xs => <a href="Generics-SOP-NP.html#t:NP">NP</a> f xs -> [<a href="Generics-SOP-NS.html#t:NS">NS</a> f xs]</li><li class="src short"><a href="#v:apInjs_POP">apInjs_POP</a> :: <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xss => <a href="Generics-SOP-NP.html#t:POP">POP</a> f xss -> [<a href="Generics-SOP-NS.html#t:SOP">SOP</a> f xss]</li><li class="src short"><a href="#v:ap_NS">ap_NS</a> :: <a href="Generics-SOP-NP.html#t:NP">NP</a> (f <a href="Generics-SOP-Classes.html#t:-45-.-45--62-">-.-></a> g) xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> f xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> g xs</li><li class="src short"><a href="#v:ap_SOP">ap_SOP</a> :: <a href="Generics-SOP-NP.html#t:POP">POP</a> (f <a href="Generics-SOP-Classes.html#t:-45-.-45--62-">-.-></a> g) xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> f xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> g xss</li><li class="src short"><a href="#v:liftA_NS">liftA_NS</a> :: <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xs => (<span class="keyword">forall</span> a. f a -> g a) -> <a href="Generics-SOP-NS.html#t:NS">NS</a> f xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> g xs</li><li class="src short"><a href="#v:liftA_SOP">liftA_SOP</a> :: <a href="Generics-SOP-Constraint.html#t:All">All</a> <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xss => (<span class="keyword">forall</span> a. f a -> g a) -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> f xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> g xss</li><li class="src short"><a href="#v:liftA2_NS">liftA2_NS</a> :: <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xs => (<span class="keyword">forall</span> a. f a -> g a -> h a) -> <a href="Generics-SOP-NP.html#t:NP">NP</a> f xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> g xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> h xs</li><li class="src short"><a href="#v:liftA2_SOP">liftA2_SOP</a> :: <a href="Generics-SOP-Constraint.html#t:All">All</a> <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xss => (<span class="keyword">forall</span> a. f a -> g a -> h a) -> <a href="Generics-SOP-NP.html#t:POP">POP</a> f xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> g xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> h xss</li><li class="src short"><a href="#v:cliftA_NS">cliftA_NS</a> :: <a href="Generics-SOP-Constraint.html#t:All">All</a> c xs => proxy c -> (<span class="keyword">forall</span> a. c a => f a -> g a) -> <a href="Generics-SOP-NS.html#t:NS">NS</a> f xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> g xs</li><li class="src short"><a href="#v:cliftA_SOP">cliftA_SOP</a> :: <a href="Generics-SOP-Constraint.html#t:All2">All2</a> c xss => proxy c -> (<span class="keyword">forall</span> a. c a => f a -> g a) -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> f xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> g xss</li><li class="src short"><a href="#v:cliftA2_NS">cliftA2_NS</a> :: <a href="Generics-SOP-Constraint.html#t:All">All</a> c xs => proxy c -> (<span class="keyword">forall</span> a. c a => f a -> g a -> h a) -> <a href="Generics-SOP-NP.html#t:NP">NP</a> f xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> g xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> h xs</li><li class="src short"><a href="#v:cliftA2_SOP">cliftA2_SOP</a> :: <a href="Generics-SOP-Constraint.html#t:All2">All2</a> c xss => proxy c -> (<span class="keyword">forall</span> a. c a => f a -> g a -> h a) -> <a href="Generics-SOP-NP.html#t:POP">POP</a> f xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> g xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> h xss</li><li class="src short"><a href="#v:map_NS">map_NS</a> :: <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xs => (<span class="keyword">forall</span> a. f a -> g a) -> <a href="Generics-SOP-NS.html#t:NS">NS</a> f xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> g xs</li><li class="src short"><a href="#v:map_SOP">map_SOP</a> :: <a href="Generics-SOP-Constraint.html#t:All">All</a> <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xss => (<span class="keyword">forall</span> a. f a -> g a) -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> f xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> g xss</li><li class="src short"><a href="#v:cmap_NS">cmap_NS</a> :: <a href="Generics-SOP-Constraint.html#t:All">All</a> c xs => proxy c -> (<span class="keyword">forall</span> a. c a => f a -> g a) -> <a href="Generics-SOP-NS.html#t:NS">NS</a> f xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> g xs</li><li class="src short"><a href="#v:cmap_SOP">cmap_SOP</a> :: <a href="Generics-SOP-Constraint.html#t:All2">All2</a> c xss => proxy c -> (<span class="keyword">forall</span> a. c a => f a -> g a) -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> f xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> g xss</li><li class="src short"><a href="#v:cliftA2-39-_NS">cliftA2'_NS</a> :: <a href="Generics-SOP-Constraint.html#t:All2">All2</a> c xss => proxy c -> (<span class="keyword">forall</span> xs. <a href="Generics-SOP-Constraint.html#t:All">All</a> c xs => f xs -> g xs -> h xs) -> <a href="Generics-SOP-NP.html#t:NP">NP</a> f xss -> <a href="Generics-SOP-NS.html#t:NS">NS</a> g xss -> <a href="Generics-SOP-NS.html#t:NS">NS</a> h xss</li><li class="src short"><a href="#v:collapse_NS">collapse_NS</a> :: <a href="Generics-SOP-NS.html#t:NS">NS</a> (<a href="Generics-SOP-BasicFunctors.html#t:K">K</a> a) xs -> a</li><li class="src short"><a href="#v:collapse_SOP">collapse_SOP</a> :: <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xss => <a href="Generics-SOP-NS.html#t:SOP">SOP</a> (<a href="Generics-SOP-BasicFunctors.html#t:K">K</a> a) xss -> [a]</li><li class="src short"><a href="#v:sequence-39-_NS">sequence'_NS</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Applicative.html#t:Applicative">Applicative</a> f => <a href="Generics-SOP-NS.html#t:NS">NS</a> (f <a href="Generics-SOP-BasicFunctors.html#t::.:">:.:</a> g) xs -> f (<a href="Generics-SOP-NS.html#t:NS">NS</a> g xs)</li><li class="src short"><a href="#v:sequence-39-_SOP">sequence'_SOP</a> :: (<a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xss, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Applicative.html#t:Applicative">Applicative</a> f) => <a href="Generics-SOP-NS.html#t:SOP">SOP</a> (f <a href="Generics-SOP-BasicFunctors.html#t::.:">:.:</a> g) xss -> f (<a href="Generics-SOP-NS.html#t:SOP">SOP</a> g xss)</li><li class="src short"><a href="#v:sequence_NS">sequence_NS</a> :: (<a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xs, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Applicative.html#t:Applicative">Applicative</a> f) => <a href="Generics-SOP-NS.html#t:NS">NS</a> f xs -> f (<a href="Generics-SOP-NS.html#t:NS">NS</a> <a href="Generics-SOP-BasicFunctors.html#t:I">I</a> xs)</li><li class="src short"><a href="#v:sequence_SOP">sequence_SOP</a> :: (<a href="Generics-SOP-Constraint.html#t:All">All</a> <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xss, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Applicative.html#t:Applicative">Applicative</a> f) => <a href="Generics-SOP-NS.html#t:SOP">SOP</a> f xss -> f (<a href="Generics-SOP-NS.html#t:SOP">SOP</a> <a href="Generics-SOP-BasicFunctors.html#t:I">I</a> xss)</li></ul></div><div id="interface"><h1 id="g:1">Datatypes</h1><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:NS" class="def">NS</a> :: (k -> *) -> [k] -> * <span class="keyword">where</span> <a href="src/Generics-SOP-NS.html#NS" class="link">Source</a></p><div class="doc"><p>An n-ary sum.</p><p>The sum is parameterized by a type constructor <code>f</code> and
indexed by a type-level list <code>xs</code>. The length of the list
determines the number of choices in the sum and if the
<code>i</code>-th element of the list is of type <code>x</code>, then the <code>i</code>-th
choice of the sum is of type <code>f x</code>.</p><p>The constructor names are chosen to resemble Peano-style
natural numbers, i.e., <code><a href="Generics-SOP-NS.html#v:Z">Z</a></code> is for "zero", and <code><a href="Generics-SOP-NS.html#v:S">S</a></code> is for
"successor". Chaining <code><a href="Generics-SOP-NS.html#v:S">S</a></code> and <code><a href="Generics-SOP-NS.html#v:Z">Z</a></code> chooses the corresponding
component of the sum.</p><p><em>Examples:</em></p><pre>Z :: f x -> NS f (x ': xs)
S . Z :: f y -> NS f (x ': y ': xs)
S . S . Z :: f z -> NS f (x ': y ': z ': xs)
...</pre><p>Note that empty sums (indexed by an empty list) have no
non-bottom elements.</p><p>Two common instantiations of <code>f</code> are the identity functor <code><a href="Generics-SOP-BasicFunctors.html#t:I">I</a></code>
and the constant functor <code><a href="Generics-SOP-BasicFunctors.html#t:K">K</a></code>. For <code><a href="Generics-SOP-BasicFunctors.html#t:I">I</a></code>, the sum becomes a
direct generalization of the <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Either.html#t:Either">Either</a></code> type to arbitrarily many
choices. For <code><code><a href="Generics-SOP-BasicFunctors.html#t:K">K</a></code> a</code>, the result is a homogeneous choice type,
where the contents of the type-level list are ignored, but its
length specifies the number of options.</p><p>In the context of the SOP approach to generic programming, an
n-ary sum describes the top-level structure of a datatype,
which is a choice between all of its constructors.</p><p><em>Examples:</em></p><pre>Z (I 'x') :: NS I '[ Char, Bool ]
S (Z (I True)) :: NS I '[ Char, Bool ]
S (Z (I 1)) :: NS (K Int) '[ Char, Bool ]</pre></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:Z" class="def">Z</a> :: f x -> <a href="Generics-SOP-NS.html#t:NS">NS</a> f (x : xs)</td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:S" class="def">S</a> :: <a href="Generics-SOP-NS.html#t:NS">NS</a> f xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> f (x : xs)</td><td class="doc empty"> </td></tr></table></div><div class="subs instances"><p id="control.i:NS" class="caption collapser" onclick="toggleSection('i:NS')">Instances</p><div id="section.i:NS" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><a href="Generics-SOP-Classes.html#t:HSequence">HSequence</a> k [k] (<a href="Generics-SOP-NS.html#t:NS">NS</a> k)</span> <a href="src/Generics-SOP-NS.html#line-305" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="Generics-SOP-Classes.html#t:HCollapse">HCollapse</a> k [k] (<a href="Generics-SOP-NS.html#t:NS">NS</a> k)</span> <a href="src/Generics-SOP-NS.html#line-289" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="Generics-SOP-Classes.html#t:HAp">HAp</a> k [k] (<a href="Generics-SOP-NS.html#t:NS">NS</a> k)</span> <a href="src/Generics-SOP-NS.html#line-213" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="Generics-SOP-Constraint.html#t:All">All</a> k (<a href="Generics-SOP-Constraint.html#t:Compose">Compose</a> * k <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> f) xs => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> (<a href="Generics-SOP-NS.html#t:NS">NS</a> k f xs)</span> <a href="src/Generics-SOP-NS.html#line-100" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left">(<a href="Generics-SOP-Constraint.html#t:All">All</a> k (<a href="Generics-SOP-Constraint.html#t:Compose">Compose</a> * k <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> f) xs, <a href="Generics-SOP-Constraint.html#t:All">All</a> k (<a href="Generics-SOP-Constraint.html#t:Compose">Compose</a> * k <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Ord.html#t:Ord">Ord</a> f) xs) => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Ord.html#t:Ord">Ord</a> (<a href="Generics-SOP-NS.html#t:NS">NS</a> k f xs)</span> <a href="src/Generics-SOP-NS.html#line-101" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="Generics-SOP-Constraint.html#t:All">All</a> k (<a href="Generics-SOP-Constraint.html#t:Compose">Compose</a> * k <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Show.html#t:Show">Show</a> f) xs => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Show.html#t:Show">Show</a> (<a href="Generics-SOP-NS.html#t:NS">NS</a> k f xs)</span> <a href="src/Generics-SOP-NS.html#line-99" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><span class="keyword">type</span> <a href="Generics-SOP-Classes.html#t:Prod">Prod</a> k [k] (<a href="Generics-SOP-NS.html#t:NS">NS</a> k) = <a href="Generics-SOP-NP.html#t:NP">NP</a> k</span> <a href="src/Generics-SOP-NS.html#line-207" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><span class="keyword">type</span> <a href="Generics-SOP-Classes.html#t:CollapseTo">CollapseTo</a> k [k] (<a href="Generics-SOP-NS.html#t:NS">NS</a> k) a = a</span> <a href="src/Generics-SOP-NS.html#line-286" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><span class="keyword">type</span> <a href="Generics-SOP-Constraint.html#t:SListIN">SListIN</a> [k] k (<a href="Generics-SOP-NS.html#t:NS">NS</a> k) = <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> k</span> <a href="src/Generics-SOP-NS.html#line-210" class="link">Source</a></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">newtype</span> <a name="t:SOP" class="def">SOP</a> f xss <a href="src/Generics-SOP-NS.html#SOP" class="link">Source</a></p><div class="doc"><p>A sum of products.</p><p>This is a 'newtype' for an <code><a href="Generics-SOP-NS.html#t:NS">NS</a></code> of an <code><a href="Generics-SOP-NP.html#t:NP">NP</a></code>. The elements of the
(inner) products are applications of the parameter <code>f</code>. The type
<code><a href="Generics-SOP-NS.html#t:SOP">SOP</a></code> is indexed by the list of lists that determines the sizes
of both the (outer) sum and all the (inner) products, as well as
the types of all the elements of the inner products.</p><p>An <code><code><a href="Generics-SOP-NS.html#t:SOP">SOP</a></code> <code><a href="Generics-SOP-BasicFunctors.html#t:I">I</a></code></code> reflects the structure of a normal Haskell datatype.
The sum structure represents the choice between the different
constructors, the product structure represents the arguments of
each constructor.</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:SOP" class="def">SOP</a> (<a href="Generics-SOP-NS.html#t:NS">NS</a> (<a href="Generics-SOP-NP.html#t:NP">NP</a> f) xss)</td><td class="doc empty"> </td></tr></table></div><div class="subs instances"><p id="control.i:SOP" class="caption collapser" onclick="toggleSection('i:SOP')">Instances</p><div id="section.i:SOP" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><a href="Generics-SOP-Classes.html#t:HSequence">HSequence</a> k [[k]] (<a href="Generics-SOP-NS.html#t:SOP">SOP</a> k)</span> <a href="src/Generics-SOP-NS.html#line-306" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="Generics-SOP-Classes.html#t:HCollapse">HCollapse</a> k [[k]] (<a href="Generics-SOP-NS.html#t:SOP">SOP</a> k)</span> <a href="src/Generics-SOP-NS.html#line-290" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="Generics-SOP-Classes.html#t:HAp">HAp</a> k [[k]] (<a href="Generics-SOP-NS.html#t:SOP">SOP</a> k)</span> <a href="src/Generics-SOP-NS.html#line-214" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> (<a href="Generics-SOP-NS.html#t:NS">NS</a> [k] (<a href="Generics-SOP-NP.html#t:NP">NP</a> k f) xss) => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> (<a href="Generics-SOP-NS.html#t:SOP">SOP</a> k f xss)</span> <a href="src/Generics-SOP-NS.html#line-119" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Ord.html#t:Ord">Ord</a> (<a href="Generics-SOP-NS.html#t:NS">NS</a> [k] (<a href="Generics-SOP-NP.html#t:NP">NP</a> k f) xss) => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Ord.html#t:Ord">Ord</a> (<a href="Generics-SOP-NS.html#t:SOP">SOP</a> k f xss)</span> <a href="src/Generics-SOP-NS.html#line-120" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Show.html#t:Show">Show</a> (<a href="Generics-SOP-NS.html#t:NS">NS</a> [k] (<a href="Generics-SOP-NP.html#t:NP">NP</a> k f) xss) => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Show.html#t:Show">Show</a> (<a href="Generics-SOP-NS.html#t:SOP">SOP</a> k f xss)</span> <a href="src/Generics-SOP-NS.html#line-118" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><span class="keyword">type</span> <a href="Generics-SOP-Classes.html#t:Prod">Prod</a> k [[k]] (<a href="Generics-SOP-NS.html#t:SOP">SOP</a> k) = <a href="Generics-SOP-NP.html#t:POP">POP</a> k</span> <a href="src/Generics-SOP-NS.html#line-208" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><span class="keyword">type</span> <a href="Generics-SOP-Classes.html#t:CollapseTo">CollapseTo</a> k [[k]] (<a href="Generics-SOP-NS.html#t:SOP">SOP</a> k) a = [a]</span> <a href="src/Generics-SOP-NS.html#line-287" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><span class="keyword">type</span> <a href="Generics-SOP-Constraint.html#t:SListIN">SListIN</a> [[k]] k (<a href="Generics-SOP-NS.html#t:SOP">SOP</a> k) = <a href="Generics-SOP-Constraint.html#t:SListI2">SListI2</a> k</span> <a href="src/Generics-SOP-NS.html#line-211" class="link">Source</a></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:unSOP" class="def">unSOP</a> :: <a href="Generics-SOP-NS.html#t:SOP">SOP</a> f xss -> <a href="Generics-SOP-NS.html#t:NS">NS</a> (<a href="Generics-SOP-NP.html#t:NP">NP</a> f) xss <a href="src/Generics-SOP-NS.html#unSOP" class="link">Source</a></p><div class="doc"><p>Unwrap a sum of products.</p></div></div><h1 id="g:2">Constructing sums</h1><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:Injection" class="def">Injection</a> f xs = f <a href="Generics-SOP-Classes.html#t:-45-.-45--62-">-.-></a> <a href="Generics-SOP-BasicFunctors.html#t:K">K</a> (<a href="Generics-SOP-NS.html#t:NS">NS</a> f xs) <a href="src/Generics-SOP-NS.html#Injection" class="link">Source</a></p><div class="doc"><p>The type of injections into an n-ary sum.</p><p>If you expand the type synonyms and newtypes involved, you get</p><pre>Injection f xs a = (f -.-> K (NS f xs)) a ~= f a -> K (NS f xs) a ~= f a -> NS f xs</pre><p>If we pick <code>a</code> to be an element of <code>xs</code>, this indeed corresponds to an
injection into the sum.</p></div></div><div class="top"><p class="src"><a name="v:injections" class="def">injections</a> :: <span class="keyword">forall</span> xs f. <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xs => <a href="Generics-SOP-NP.html#t:NP">NP</a> (<a href="Generics-SOP-NS.html#t:Injection">Injection</a> f xs) xs <a href="src/Generics-SOP-NS.html#injections" class="link">Source</a></p><div class="doc"><p>Compute all injections into an n-ary sum.</p><p>Each element of the resulting product contains one of the injections.</p></div></div><div class="top"><p class="src"><a name="v:shift" class="def">shift</a> :: <a href="Generics-SOP-NS.html#t:Injection">Injection</a> f xs a -> <a href="Generics-SOP-NS.html#t:Injection">Injection</a> f (x : xs) a <a href="src/Generics-SOP-NS.html#shift" class="link">Source</a></p><div class="doc"><p>Shift an injection.</p><p>Given an injection, return an injection into a sum that is one component larger.</p></div></div><div class="top"><p class="src"><a name="v:apInjs_NP" class="def">apInjs_NP</a> :: <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xs => <a href="Generics-SOP-NP.html#t:NP">NP</a> f xs -> [<a href="Generics-SOP-NS.html#t:NS">NS</a> f xs] <a href="src/Generics-SOP-NS.html#apInjs_NP" class="link">Source</a></p><div class="doc"><p>Apply injections to a product.</p><p>Given a product containing all possible choices, produce a
list of sums by applying each injection to the appropriate
element.</p><p><em>Example:</em></p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>apInjs_NP (I 'x' :* I True :* I 2 :* Nil)
</code></strong>[Z (I 'x'), S (Z (I True)), S (S (Z (I 2)))]
</pre></div></div><div class="top"><p class="src"><a name="v:apInjs_POP" class="def">apInjs_POP</a> :: <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xss => <a href="Generics-SOP-NP.html#t:POP">POP</a> f xss -> [<a href="Generics-SOP-NS.html#t:SOP">SOP</a> f xss] <a href="src/Generics-SOP-NS.html#apInjs_POP" class="link">Source</a></p><div class="doc"><p>Apply injections to a product of product.</p><p>This operates on the outer product only. Given a product
containing all possible choices (that are products),
produce a list of sums (of products) by applying each
injection to the appropriate element.</p><p><em>Example:</em></p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>apInjs_POP (POP ((I 'x' :* Nil) :* (I True :* I 2 :* Nil) :* Nil))
</code></strong>[SOP (Z (I 'x' :* Nil)),SOP (S (Z (I True :* (I 2 :* Nil))))]
</pre></div></div><h1 id="g:3">Application</h1><div class="top"><p class="src"><a name="v:ap_NS" class="def">ap_NS</a> :: <a href="Generics-SOP-NP.html#t:NP">NP</a> (f <a href="Generics-SOP-Classes.html#t:-45-.-45--62-">-.-></a> g) xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> f xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> g xs <a href="src/Generics-SOP-NS.html#ap_NS" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hap">hap</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:ap_SOP" class="def">ap_SOP</a> :: <a href="Generics-SOP-NP.html#t:POP">POP</a> (f <a href="Generics-SOP-Classes.html#t:-45-.-45--62-">-.-></a> g) xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> f xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> g xss <a href="src/Generics-SOP-NS.html#ap_SOP" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hap">hap</a></code>.</p></div></div><h1 id="g:4">Lifting / mapping</h1><div class="top"><p class="src"><a name="v:liftA_NS" class="def">liftA_NS</a> :: <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xs => (<span class="keyword">forall</span> a. f a -> g a) -> <a href="Generics-SOP-NS.html#t:NS">NS</a> f xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> g xs <a href="src/Generics-SOP-NS.html#liftA_NS" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hliftA">hliftA</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:liftA_SOP" class="def">liftA_SOP</a> :: <a href="Generics-SOP-Constraint.html#t:All">All</a> <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xss => (<span class="keyword">forall</span> a. f a -> g a) -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> f xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> g xss <a href="src/Generics-SOP-NS.html#liftA_SOP" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hliftA">hliftA</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:liftA2_NS" class="def">liftA2_NS</a> :: <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xs => (<span class="keyword">forall</span> a. f a -> g a -> h a) -> <a href="Generics-SOP-NP.html#t:NP">NP</a> f xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> g xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> h xs <a href="src/Generics-SOP-NS.html#liftA2_NS" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hliftA2">hliftA2</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:liftA2_SOP" class="def">liftA2_SOP</a> :: <a href="Generics-SOP-Constraint.html#t:All">All</a> <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xss => (<span class="keyword">forall</span> a. f a -> g a -> h a) -> <a href="Generics-SOP-NP.html#t:POP">POP</a> f xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> g xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> h xss <a href="src/Generics-SOP-NS.html#liftA2_SOP" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hliftA2">hliftA2</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:cliftA_NS" class="def">cliftA_NS</a> :: <a href="Generics-SOP-Constraint.html#t:All">All</a> c xs => proxy c -> (<span class="keyword">forall</span> a. c a => f a -> g a) -> <a href="Generics-SOP-NS.html#t:NS">NS</a> f xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> g xs <a href="src/Generics-SOP-NS.html#cliftA_NS" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hcliftA">hcliftA</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:cliftA_SOP" class="def">cliftA_SOP</a> :: <a href="Generics-SOP-Constraint.html#t:All2">All2</a> c xss => proxy c -> (<span class="keyword">forall</span> a. c a => f a -> g a) -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> f xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> g xss <a href="src/Generics-SOP-NS.html#cliftA_SOP" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hcliftA">hcliftA</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:cliftA2_NS" class="def">cliftA2_NS</a> :: <a href="Generics-SOP-Constraint.html#t:All">All</a> c xs => proxy c -> (<span class="keyword">forall</span> a. c a => f a -> g a -> h a) -> <a href="Generics-SOP-NP.html#t:NP">NP</a> f xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> g xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> h xs <a href="src/Generics-SOP-NS.html#cliftA2_NS" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hcliftA2">hcliftA2</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:cliftA2_SOP" class="def">cliftA2_SOP</a> :: <a href="Generics-SOP-Constraint.html#t:All2">All2</a> c xss => proxy c -> (<span class="keyword">forall</span> a. c a => f a -> g a -> h a) -> <a href="Generics-SOP-NP.html#t:POP">POP</a> f xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> g xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> h xss <a href="src/Generics-SOP-NS.html#cliftA2_SOP" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hcliftA2">hcliftA2</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:map_NS" class="def">map_NS</a> :: <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xs => (<span class="keyword">forall</span> a. f a -> g a) -> <a href="Generics-SOP-NS.html#t:NS">NS</a> f xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> g xs <a href="src/Generics-SOP-NS.html#map_NS" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hmap">hmap</a></code>, which is equivalent to <code><a href="Generics-SOP-Classes.html#v:hliftA">hliftA</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:map_SOP" class="def">map_SOP</a> :: <a href="Generics-SOP-Constraint.html#t:All">All</a> <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xss => (<span class="keyword">forall</span> a. f a -> g a) -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> f xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> g xss <a href="src/Generics-SOP-NS.html#map_SOP" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hmap">hmap</a></code>, which is equivalent to <code><a href="Generics-SOP-Classes.html#v:hliftA">hliftA</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:cmap_NS" class="def">cmap_NS</a> :: <a href="Generics-SOP-Constraint.html#t:All">All</a> c xs => proxy c -> (<span class="keyword">forall</span> a. c a => f a -> g a) -> <a href="Generics-SOP-NS.html#t:NS">NS</a> f xs -> <a href="Generics-SOP-NS.html#t:NS">NS</a> g xs <a href="src/Generics-SOP-NS.html#cmap_NS" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hcmap">hcmap</a></code>, which is equivalent to <code><a href="Generics-SOP-Classes.html#v:hcliftA">hcliftA</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:cmap_SOP" class="def">cmap_SOP</a> :: <a href="Generics-SOP-Constraint.html#t:All2">All2</a> c xss => proxy c -> (<span class="keyword">forall</span> a. c a => f a -> g a) -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> f xss -> <a href="Generics-SOP-NS.html#t:SOP">SOP</a> g xss <a href="src/Generics-SOP-NS.html#cmap_SOP" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hcmap">hcmap</a></code>, which is equivalent to <code><a href="Generics-SOP-Classes.html#v:hcliftA">hcliftA</a></code>.</p></div></div><h1 id="g:5">Dealing with <code><code><a href="Generics-SOP-Constraint.html#t:All">All</a></code> c</code></h1><div class="top"><p class="src"><a name="v:cliftA2-39-_NS" class="def">cliftA2'_NS</a> :: <a href="Generics-SOP-Constraint.html#t:All2">All2</a> c xss => proxy c -> (<span class="keyword">forall</span> xs. <a href="Generics-SOP-Constraint.html#t:All">All</a> c xs => f xs -> g xs -> h xs) -> <a href="Generics-SOP-NP.html#t:NP">NP</a> f xss -> <a href="Generics-SOP-NS.html#t:NS">NS</a> g xss -> <a href="Generics-SOP-NS.html#t:NS">NS</a> h xss <a href="src/Generics-SOP-NS.html#cliftA2%27_NS" class="link">Source</a></p><div class="doc"><div class="warning"><p>Deprecated: Use <code><a href="Generics-SOP-NS.html#v:cliftA2_NS">cliftA2_NS</a></code> instead.</p></div><p>Specialization of <code><a href="Generics-SOP-NP.html#v:hcliftA2-39-">hcliftA2'</a></code>.</p></div></div><h1 id="g:6">Collapsing</h1><div class="top"><p class="src"><a name="v:collapse_NS" class="def">collapse_NS</a> :: <a href="Generics-SOP-NS.html#t:NS">NS</a> (<a href="Generics-SOP-BasicFunctors.html#t:K">K</a> a) xs -> a <a href="src/Generics-SOP-NS.html#collapse_NS" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hcollapse">hcollapse</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:collapse_SOP" class="def">collapse_SOP</a> :: <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xss => <a href="Generics-SOP-NS.html#t:SOP">SOP</a> (<a href="Generics-SOP-BasicFunctors.html#t:K">K</a> a) xss -> [a] <a href="src/Generics-SOP-NS.html#collapse_SOP" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hcollapse">hcollapse</a></code>.</p></div></div><h1 id="g:7">Sequencing</h1><div class="top"><p class="src"><a name="v:sequence-39-_NS" class="def">sequence'_NS</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Applicative.html#t:Applicative">Applicative</a> f => <a href="Generics-SOP-NS.html#t:NS">NS</a> (f <a href="Generics-SOP-BasicFunctors.html#t::.:">:.:</a> g) xs -> f (<a href="Generics-SOP-NS.html#t:NS">NS</a> g xs) <a href="src/Generics-SOP-NS.html#sequence%27_NS" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hsequence-39-">hsequence'</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:sequence-39-_SOP" class="def">sequence'_SOP</a> :: (<a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xss, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Applicative.html#t:Applicative">Applicative</a> f) => <a href="Generics-SOP-NS.html#t:SOP">SOP</a> (f <a href="Generics-SOP-BasicFunctors.html#t::.:">:.:</a> g) xss -> f (<a href="Generics-SOP-NS.html#t:SOP">SOP</a> g xss) <a href="src/Generics-SOP-NS.html#sequence%27_SOP" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hsequence-39-">hsequence'</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:sequence_NS" class="def">sequence_NS</a> :: (<a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xs, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Applicative.html#t:Applicative">Applicative</a> f) => <a href="Generics-SOP-NS.html#t:NS">NS</a> f xs -> f (<a href="Generics-SOP-NS.html#t:NS">NS</a> <a href="Generics-SOP-BasicFunctors.html#t:I">I</a> xs) <a href="src/Generics-SOP-NS.html#sequence_NS" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hsequence">hsequence</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:sequence_SOP" class="def">sequence_SOP</a> :: (<a href="Generics-SOP-Constraint.html#t:All">All</a> <a href="Generics-SOP-Sing.html#t:SListI">SListI</a> xss, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Applicative.html#t:Applicative">Applicative</a> f) => <a href="Generics-SOP-NS.html#t:SOP">SOP</a> f xss -> f (<a href="Generics-SOP-NS.html#t:SOP">SOP</a> <a href="Generics-SOP-BasicFunctors.html#t:I">I</a> xss) <a href="src/Generics-SOP-NS.html#sequence_SOP" class="link">Source</a></p><div class="doc"><p>Specialization of <code><a href="Generics-SOP-Classes.html#v:hsequence">hsequence</a></code>.</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.16.1</p></div></body></html>
|