Problems using ghci

Hello,

I’m trying to do some Haskell on a recent NixOS installation and encounter the following problem in GHCi.

When running any recursive code, for example :

f 0 = 0
f n = f 0

(you can reproduce this by running nix shell nixpkgs#ihaskell and then pasting those lines in GHCi

The computation stalls until it stack overflows

I do not encounter the same problem when compiling with ghc or loading a file in GHCi

At one point the problem vanished, and then it came back, thus I assumed it was some kind of kernel bug (there have been kernel bugs breaking GHCi in the past Memory allocation errors on 6.1.1 / Kernel & Hardware / Arch Linux Forums)

(Haskell is not installed system wide, I use it in development flakes)

I’m running NixOS unstable

Take a look at the GHCi documentation page.
3. Using GHCi — Glasgow Haskell Compiler 9.8.1 User's Guide.

Essentially you can’t write recursive definitions like that without special syntax or options.

I personally write such functions in Emacs and then load the file with GHCi.

If the problem persists then it may be an underlying bug.

Well, I think you are right, although I was sure it worked at some point, I must assume my memory failed me

In the meantime, the case of syntax works