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

Manual derivation of the type of q (specified in the body)

I don't realize why q's type is Ord t => [t] -> [a] and not Ord a => [a] -> [a] q [] = [] q (x:xs) = q us ++ q ws where us = filter (<=x) xs ws = filter (>=x) xs Under which circumstances the input type could differ from the…
Fof
  • 407
  • 2
  • 8
0
votes
1 answer

Deriving the type of (foldr (.))

I'm trying to manually derive the type of (foldr (.)) foldr :: (a1 -> b1 -> b1) -> b1 -> [a1] -> b1 (.) ::(b2 -> c2) -> (a2 -> b2) -> a2 -> c2 Then: a1 ~ (b2 -> c2) b1 ~ (a2 -> b2) b1 ~ a2 So I get that (foldr (.)) :: (a2 -> b2) -> [(b2 -> c2)] ->…
Fof
  • 407
  • 2
  • 8
0
votes
2 answers

Manual derivation of the type for `f1 x xs = (filter . (<)) x xs`

I want to manually derive the type of: f1 x xs = (filter . (<)) x xs First time we see x, so: x :: t1 Then (<) has this type: (<) :: Ord a1 => a1 -> a1 -> Bool We can only say (< x) if the following types can be unified: t1 ~ a1 Then x ::…
Fof
  • 407
  • 2
  • 8
0
votes
1 answer

Which is the type of (flip .)?

I'm trying to understand why the type of: (flip .) is: (a -> a1 -> b -> c) -> a -> b -> a1 -> c First of all, the type of: flip: is (a -> b -> c) -> b -> a -> c (.): is (b -> c) -> (a -> b) -> a -> c I will rename the variables to be more clear in…
Fof
  • 407
  • 2
  • 8
0
votes
2 answers

Stoppage ghci with list comprehension

I'm new to Haskell. Following list comprehension dose not work good. ghci stop it's output. (after type '7', ghci stop long long time.) Prelude Data.Numbers.Primes> [x | x <- primes, x <= 10] Loading package array-0.4.0.1 ... linking ...…
shaegis
  • 9
  • 3
0
votes
1 answer

GHCI to external file

I have a Haskell function which returns quite a large output. (In fact, beyond the console's buffer size.) Is there any way GHCI output can be automatically saved to an external txt file rather than simply displayed?
MrD
  • 4,986
  • 11
  • 48
  • 90
0
votes
1 answer

Various Questions about Trees in Haskell

I'm just picking up Haskell and have a few questions about tree notation First, I'm dealing with the following definition of a tree: data Tree a = Leaf a | Branch [Tree a] 1) I understand that this definition allows for an infinite number of…
p0ny
  • 329
  • 1
  • 3
  • 11
0
votes
1 answer

Haskell: GHCI error when using lambda abstraction

I tried to run the following code which is taken from 'Programming in Haskell' by Graham Hutton type Parser a = [(a, String)] return :: a -> Parser a return v = \inp -> [(v,inp)] when loading the module in GHCI 7.6.3 the following error…
David
  • 75
  • 3
0
votes
1 answer

ghci: Custom Prompt in Emacs haskell-mode

How do you set up a custom prompt in ghci so that it works properly with inferior haskell process ? I know that I can modify ~/.ghci, but that leads to another problem. Any solution to this ?
Sibi
  • 47,472
  • 16
  • 95
  • 163
0
votes
1 answer

Run main as sudo in ghci

I have a snap application. I'd like to run it on port 80 within ghci for local debugging purposes. Normally I'd run sudo ./main -p 80 on the compiled binary to achieve this, but within ghci I get a permission denied. *Main> :main -p 80 Initializing…
The Internet
  • 7,959
  • 10
  • 54
  • 89
0
votes
0 answers

haskell GHC. exe crashes on executing sqlite3 trigger

I have written the following trigger. When I execute it, ghc. exe crashes. It says "ghc.exe has stopped working. windows is currently looking for a solution to this problem. This is something I've never experienced". calculateNoOfStocksTraded…
Prasadika
  • 897
  • 2
  • 20
  • 36
0
votes
0 answers

"Duplicate symbol" error when using ghc-mod as a library

I'm trying to use the ghc-mod library to typecheck a haskell program from within another program. When I do so, I get the following error: GHCi runtime linker: fatal error: I found a duplicate definition for symbol …
jmite
  • 8,171
  • 6
  • 40
  • 81
0
votes
1 answer

EclipseFG does not search for "user" installed modules

I've just installed EclipseFP and now I am trying to load a module in GHCi. The problem is that GHCi doesn't load libraries installed by cabal, referenced by my module. After I set -v in GHCi and ran :r, it looks like GHCi is only looking for…
Salman
  • 1
  • 2
0
votes
2 answers

Haskell multiline interactive mode

In python, there exists many IDEs which let you do this. >>> if (a==5): print "Yes" else: print "No" But in haskell's GHCi: Prelude> do :2:1: Empty 'do' block It does not work. Is there any IDE which lets you do multiline…
PyRulez
  • 10,513
  • 10
  • 42
  • 87
0
votes
2 answers

using takeWhile AND filters with list comprehension issue

I am confused why GHCI is calculating this list infinitely: takeWhile (>0) [x^2 | x <- [100, 99..], odd x] This list, however, stops and is calculated as expected: takeWhile (>0) [x | x <- [100, 99..], odd x] What am I missing here? Why is it that…
sugarmuff
  • 435
  • 5
  • 17