Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>No, there isn't, since if the compiler could make this determination, that would be equivalent to solving the Halting Problem. In general, the fact that two functions call each other in a "loop" pattern is not enough to conclude that actually calling one of the functions will result in a loop.</p> <p>To use a (contrived) example,</p> <pre><code>collatzOdd :: Int -&gt; Int collatzOdd 1 = 1 collatzOdd n = let n' = 3*n+1 in if n' `mod` 2 == 0 then collatzEven n' else collatzOdd n' collatzEven :: Int -&gt; Int collatzEven n = let n' = n `div` 2 in if n' `mod` 2 == 0 then collatzEven n' else collatzOdd n' collatz :: Int -&gt; Int collatz n = if n `mod` 2 == 0 then collatzEven n else collatzOdd n </code></pre> <p>(This is of course not the most natural way to implement the <a href="http://en.wikipedia.org/wiki/Collatz_conjecture" rel="noreferrer">Collatz conjecture</a>, but it illustrates mutually recursive functions.)</p> <p>Now <code>collatzEven</code> and <code>collatzOdd</code> depend on each other, but the Collatz conjecture states that calling <code>collatz</code> terminates for all positive <code>n</code>. If GHC could determine whether a class that had <code>collatzOdd</code> and <code>collatzEven</code> as default definitions had a complete definition or not, then GHC would be able to solve the Collatz conjecture! (This is of course not a proof of the undecideability of the Halting Problem, but it should illustrate why determining whether a mutually recursive set of functions is well-defined is not at all as trivial as it may seem.)</p> <p>In general, since GHC cannot determine this automatically, documentation for Haskell classes will give the "minimal complete definition" necessary for creating an instance of a class.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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