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
18
votes
1 answer

Haskell type operator precedence

When the language extension TypeOperators is enabled, it's possible to define own type operators. Also, it's possible to set their relative precedence with infix*. But what's the precedence of (->), for example? > :i (->) data (->) a b -- Defined…
polkovnikov.ph
  • 6,256
  • 6
  • 44
  • 79
18
votes
1 answer

Difference in getLine functionality with GHCi vs. runhaskell

I've just stumbled upon a thing I don't understand. If I am using GHCi and use getLine I get the following Prelude> a <- getLine Testoo -- the Backspace action results in a '^?' Prelude> a "Test\DELoo" If I write the same in a…
epsilonhalbe
  • 15,637
  • 5
  • 46
  • 74
18
votes
1 answer

Module loading options in GHCi

Why does GHCi have so many different commands for loading modules into a session? Here are ones I'm aware of, together with their rather confusing explanations from :help in ghci: add [*] -- add module(s) to the current target set :module…
hdgarrood
  • 2,141
  • 16
  • 23
18
votes
1 answer

Dynamic loading under GHCi

I need to be able to load Haskell modules dynamicaally, and evaluate expressions in the context of dynamically-loaded modules. Hint does it; the problem is, it doesn't work under GHCi, on Windows at least. cygwin-bash> ghci HintTest.hs GHCi, version…
n. m. could be an AI
  • 112,515
  • 14
  • 128
  • 243
18
votes
2 answers

How to configure amount of command history saved by GHCi?

By default, GHCi saves 100 lines of command history in ~/.ghc/ghci_history. Can I increase this number? I'm using GHC 7.6.3 on GNU/Linux.
ntc2
  • 11,203
  • 7
  • 53
  • 70
18
votes
1 answer

How do I make lenses from a record in GHCi

I want to play around with the Lens library a bit. I've loaded it into GHCi and created a record data type with the appropriate underscores: > data Foo a = Foo {_arg1 :: Int, _arg2 :: [a]} I would like to make the lenses for Foo using the…
John F. Miller
  • 26,961
  • 10
  • 71
  • 121
18
votes
5 answers

Differences Between Hugs, Yhc and GHCi

There are differences between Hugs, Yhc and GHCi? If there are differences, What are they?
Nathan Campos
  • 28,769
  • 59
  • 194
  • 300
18
votes
1 answer

find all types that are instances of a typeclass

learnyouahaskell mentions the following: Types in Enum class are (), Bool, Char, Ordering, Int, Integer, Float and Double Is there any way to find which types are instances of which typeclass and vice versa in GHCi? I want something like the :t…
user1308560
  • 409
  • 2
  • 9
17
votes
1 answer

ghci tab-completion in haskell-mode

It's quite nice to have ghci integrated with Emacs through inferior-haskell-mode: this adds a wonderful possibility to quickly navigate to compile error locations, interactively inspect types, definitions, etc. Nevertheless, the major feature I'm…
dying_sphynx
  • 1,136
  • 8
  • 17
17
votes
1 answer

How can I stop infinite evaluation in GHCi?

When I run something like: Prelude> cycle "ab" I can see an infinite printing of "ab". To stop it I just use Ctrl+c. And it works. When I run: Prelude Data.List> nub $ cycle "ab" I am not able to stop it. Question: Why it so? How can I stop this…
mkUltra
  • 2,828
  • 1
  • 22
  • 47
17
votes
1 answer

Ghc: partially compile Haskell code?

When I compile a Haskell file with ghci, typically with :load, and if there is no type error, all the expressions are loaded in the ghc interpreter. It's very nice: I can play around with :t to figure out the type of various expressions. My problem…
Olivier Verdier
  • 46,998
  • 29
  • 98
  • 90
17
votes
1 answer

IO/Monadic assign operator causing ghci to explode for infinite list

Consider the following program. It runs forever and does nothing useful, but the memory consumption in ghci is constant : --NoExplode.hs module Main (main) where test :: [Int] -> IO() test lst = do print "test" rList lst rList :: [Int] -> IO…
artella
  • 5,068
  • 4
  • 27
  • 35
17
votes
2 answers

Setting GHCi prompt inside multiline blocks

GHCi's prompt can be set as follows, which is in my .ghci: :set prompt "λ> " However, a different prompt appears in multiline blocks, and I can't figure out how to change it. It is completely unreadable if too many modules are imported: λ>…
betaveros
  • 1,360
  • 12
  • 23
17
votes
2 answers

haskell parse error in pattern for n+k pattern

I have started working my way through Erik Meijer's 13-part lectures (and Graham Hutton's slides) to learn Haskell. On the slides for Chapter 4, on page 13, it introduces the pattern-matching syntax for n+k patterns. In particular, it says: As…
pohl
  • 3,158
  • 1
  • 30
  • 48
16
votes
1 answer

Increase the "width" of ghci

When an output line is too long in GHCI, it is broken: > :i bar bar :: Lens' (Foo a0) Int -- Defined at NewType_makeLenses.hs:7:1 > :i baz baz :: Lens (Foo a0) (Foo a1) a0 a1 -- Defined at NewType_makeLenses.hs:7:1 Is there a way to set the…
Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225