Questions tagged [ghci]

GHCi is the interactive environment (REPL) for the Glasgow Haskell Compiler.

GHCi is the interactive environment (REPL) for the Glasgow Haskell Compiler and GHCi is one of the main tools used to develope, test and debug Haskell.

Typically, ghci-tag is associated with questions

  • different use cases of ghci, how it works
  • ghci environment settings, tuning
  • customization of ghci environment, scripting
  • how ghci can be used with other tools
  • development of the ghci

There is Haskell-wiki that describes the basic use and customization of GHCi.

1069 questions
29
votes
3 answers

Haskell line of code not compiling: "Illegal datatype context"

I am not able to get this line of code compiled in Haskell but it works on my professor's system. I use ghci version 7.6.2. data Eq a => Shape a = Shape a More precisely, this is the error I am getting [1 of 1] Compiling Main ( test.hs,…
Goutham
  • 293
  • 3
  • 7
29
votes
7 answers

Installing Haskell packages on Mac

I can't seem to get a few Haskell packages to install on my Mac (10.6.8). I first tried Happstack and it failed and then I tried Snap. Sometimes when I run ghci I get a segmentation fault. Other times it works and goes like this: GHCi, version…
Jonovono
  • 3,437
  • 5
  • 42
  • 64
28
votes
4 answers

Haskell / GHCi - loading modules from different directories

My haskell application has the following directory structure: src/ utils/Utils.hs subsystem/Subsystem.hs The Subsystem module imports Utils module. I would like to hand test this code in GHCi. The problem is GHCi seems to be only looking…
simon
  • 281
  • 3
  • 3
28
votes
7 answers

How to hack GHCi (or Hugs) so that it prints Unicode chars unescaped?

Look at the problem: Normally, in the interactive Haskell environment, non-Latin Unicode characters (that make a part of the results) are printed escaped, even if the locale allows such characters (as opposed to direct output through putStrLn,…
imz -- Ivan Zakharyaschev
  • 4,921
  • 6
  • 53
  • 104
28
votes
1 answer

unknown command ':1' haskell

I just decided to get adventurous and learn some Haskell. I am following along from http://learnyouahaskell.com/. I downloaded the whole Haskell Platform from http://www.haskell.org/platform/mac.html for 64bit Mac Architecture, I already had…
sammalaska
  • 283
  • 2
  • 6
27
votes
1 answer

Template Haskell: reify in GHCi

Is it somehow possible to do reify in GHCi? When I try it using 'runQ' it complains "can not do reify in the IO monad". >>> runQ (reify ''Bool) Template Haskell error: Can't do `reify' in the IO monad *** Exception: user error (Template Haskell…
scravy
  • 11,904
  • 14
  • 72
  • 127
26
votes
1 answer

Binding `len = length xs` and then calculating `len` causes GHC to consume lots of RAM

I found a strange thing about GHCi and lists. This command takes some time to execute and just returns the right answer. ghci> length [1..10^8] 100000000 However, binding this to a variable and executing causes GHC to consume about 5 GiB of RAM…
Alex
  • 1,165
  • 2
  • 9
  • 27
25
votes
1 answer

Expand type synonyms, type families with GHCi

I am wondering if there is functionality that exists within GHCi (or elsewhere) to expand type synonyms and families out of an arbitrary type expression. For example, if I have these types, data A = A data B = B data F a = F a data G a = G a data H…
mgibson
  • 253
  • 2
  • 5
24
votes
5 answers

Debugging infinite loops in Haskell programs with GHCi

For the first time I've encountered an infinite loop in a Haskell program I'm writing. I've narrowed it down to a quite specific section of code, but I cannot seem to pinpoint exactly where I have a non-terminating recursive definition. I'm vaguely…
gspr
  • 11,144
  • 3
  • 41
  • 74
23
votes
2 answers

Error haskell: not in scope. What does that mean?

I started with Haskell today and all the functions I perform on ghci display this message. I just want to know why this is happening. I know there are a lot of questions about this, but this is a simple case and I need to understand this error in…
Marcio
  • 331
  • 1
  • 3
  • 12
23
votes
2 answers

Set vi as editor in GHCi

How can I get vi editing mode to work in GHCi? I'm using version 7.10.3. I tried Prelude> :set editor vi, but to no effect. I also have these lines in my ~/.inputrc. set editing-mode vi set keymap vi .
23
votes
1 answer

How can I make GHCI release memory

The introduction The following code shows that when using runhaskell Haskell Garbage Collector releases the memory, when a is no longer used. It results in core dump while releasing variable a - for a purpose, to inspect the behaviour - a has got…
remdezx
  • 2,939
  • 28
  • 49
23
votes
1 answer

How to check Haskell infix operator precedence

I can see the type of an infix operator in GHCi with :t like so: >:t (.) (.) :: (b -> c) -> (a -> b) -> a -> c How can i see the operator precedence in GHCi? is that possible? Also, bonus question, is there a way to see the source of these…
Adam Gordon Bell
  • 3,083
  • 2
  • 26
  • 53
22
votes
2 answers

Specifying package name for module-related commands in ghci

Is there a way to specify the package name for a module for the :browse, :load or :module commands in ghci (version 6.12.1) ? Some module names are ambiguous: Prelude> :module Control.Monad.Cont : Ambiguous module name…
gawi
  • 13,940
  • 7
  • 42
  • 78
22
votes
1 answer

Infinite loop in haskell?

I thought this would produce a factorial function... (within ghci) Prelude> let ft 0 = 1 Prelude> let ft n = n * ft (n - 1) Prelude> ft 5 (hangs indefinitely, until ^C).
Mike
  • 229
  • 1
  • 3
1 2
3
71 72