Firstly, since you opened GHCi directly, the terminal window in which it works closes as soon as GHCi stops working. If you open cmd (or a similar terminal) and then use GHCi, you will see the error that GHCi throws when it stops working. In this case we get:
<interactive>: out of memory
This suggests a problem with infinite recursion, as you already suspected.
Since factorial is a simpler function, it is easier to check if its recursive call is the culprit. This means that factorial n - 1 means (factorial n) - 1 , not factorial (n - 1) . And calling factorial n in the definition of factorial n is pretty much the case of an infinite recursion tutorial. In double_factorial we see the same problem.
source share