Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There is no way to construct a "real" value of a no-constructor type (where by "real" I mean a terminating computation; Haskell has <code>undefined :: a</code>, <code>error :: String -&gt; a</code> and the possibility of writing nonterminating programs like <code>mwahaha = mwahaha</code>, which to be simplistic I'll call "fake" values).</p> <p>One example of how this can be useful is versions 0.5 and later of the <a href="http://hackage.haskell.org/package/conduit/" rel="nofollow">conduit</a> library. The basic type in the library is <code>Pipe l i o u m r</code>; with different parameters for these types, a <code>Pipe</code> can serve either as a <strong>source</strong> (which produces output without consuming any input), a <strong>sink</strong> (consumes input without producing any output), or a <strong>conduit</strong> (consumes input and produces output). The <code>i</code> and <code>o</code> type parameters to <code>Pipe</code> are the types of its input and output, respectively.</p> <p>So one of the ways the conduit library enforces the notion that sources consume no input and sinks produce no output by using the <code>Void</code> type from <a href="http://hackage.haskell.org/package/void-0.5.7" rel="nofollow"><code>Data.Void</code></a> as the input type for sources and output type for sinks. Again, there is no terminating way to construct a value of such a type, so a program that attempts to consume output from a sink will not terminate (which as a reminder, in Haskell this can mean "raise an error" and not necessarily "loop forever").</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload