Questions tagged [ghc]

Glasgow Haskell Compiler is a state-of-the-art, open source compiler and interactive environment for the functional language Haskell. Use this tag for questions specifically about GHC and not about Haskell in general as almost everyone will be using it unless specified otherwise.

The Glasgow Haskell Compiler (GHC) is the most commonly used compiler for . Apart from supporting the language standards (Haskell 98 and Haskell 2010), it also supports a wide variety of language extensions like generalized algebraic data types (GADTs) and multi-parameter type classes.

As GHC is by far the most used Haskell compiler, it is safe to assume that anyone is using it unless specified otherwise. This means the GHC tag should be used for questions relating directly to the compiler or to its APIs, and not for questions about Haskell in general.

GHC also exports most of its functionality as a Haskell API - the compiler itself can also act like a library. This tag should also be used for any questions pertaining to the GHC API.

Other resources:

2470 questions
43
votes
1 answer

Wrong IO actions order using putStr and getLine

I have the following code: main = do putStr "Test input : " content <- getLine putStrLn content When I run it (with runhaskell) or compile it (ghc 6.10.4) the result is like this: asd Test input : asd Why is Test input : asd being…
QWRp
  • 528
  • 4
  • 6
43
votes
2 answers

Restricting string literals to Text only

I'm aware that the OverloadedStrings language pragma wraps an implicit fromString around all string literals. What I'd like to do is not actually overload strings, but merely change their meaning so that they are always turned into Text, and…
Dan Burton
  • 53,238
  • 27
  • 117
  • 198
41
votes
1 answer

Why were type classes difficult to implement?

On slide 30/78 of this presentation, Simon suggests that implementation of type classes was a "despair" at the beginning. Is anybody aware why that was?
Łukasz Lew
  • 48,526
  • 41
  • 139
  • 208
41
votes
6 answers

How to stop GHC from generating intermediate files?

When compiling a haskell source file via ghc --make foo.hs GHC always leaves behind a variety of intermediate files other than foo.exe. These are foo.hi and foo.o. I often end up having to delete the .hi and .o files to avoid cluttering up the…
unknown
40
votes
7 answers

Making small haskell executables?

Are there any good ways to make small haskell executables? With ghc6 a simple hello world program seems to come to about 370kB (523kB before strip). Hello world in C is about 4kB (9kB before strip).
Anthony Towns
  • 2,864
  • 1
  • 19
  • 23
40
votes
1 answer

Excessive amount of system calls when using `threadDelay`

I'm having a couple of Haskell processes running in production on a system with 12 cores. All processes are compiled with -threaded and run with 12 capabilities. One library they all use is resource-pool which keeps a pool of database…
raichoo
  • 2,557
  • 21
  • 28
40
votes
3 answers

What exactly is the kind "*" in Haskell?

In Haskell, (value-level) expressions are classified into types, which can be notated with :: like so: 3 :: Int, "Hello" :: String, (+ 1) :: Num a => a -> a. Similarly, types are classified into kinds. In GHCi, you can inspect the kind of a type…
Christian Conkle
  • 5,932
  • 1
  • 28
  • 52
40
votes
1 answer

Haskell program outputs `<>`

I wrote a Haskell program that preforms a binary search on a list. At least that's what I thought it does. When I compiled the program with ghc v7.6.3 and ran the program I got the following output: progname: <> What on earth does this output…
recursion.ninja
  • 5,377
  • 7
  • 46
  • 78
40
votes
3 answers

How are Haskell programs compiled and executed internally?

I'm having trouble understanding how Haskell (GHC) compiles programs, and how those programs are run. GHC is the canonical example of a nontrivial program written in Haskell. However, parts of GHC seem not to be written in Haskell, namely the…
David
  • 8,275
  • 5
  • 26
  • 36
39
votes
2 answers

Fixing issues noted by ghc-pkg check

It's rather nice that ghc-pkg check will list broken packages, and why they are broken. But as far as I know, there is no automated way to take care of those broken packages. What is the recommended way to deal with broken packages? (Preferably not…
Dan Burton
  • 53,238
  • 27
  • 117
  • 198
39
votes
4 answers

Where can I learn about #ifdef?

I see this used often to make modules compatible with GHC and Hugs, but google is not helping me learn more about it. What can I put inside the conditional? Can I make parts of a module conditional on what version of 'base' is in use? EDIT 3/2017:…
jberryman
  • 16,334
  • 5
  • 42
  • 83
39
votes
2 answers

How to execute a command right after a fetch or pull command in git?

I cloned the GHC (Glasgow Haskell Compiler) repository. In order to build the compiler, you need several libraries, all of them are available as git repositories too. In order to ease ones live, the GHC hackers included a script sync-all that, when…
fuz
  • 88,405
  • 25
  • 200
  • 352
39
votes
2 answers

GHC's RTS options for garbage collection

I have a Haskell program which processes a text file and builds a Map (with several million elements). The whole thing can run for 2-3 minutes. I found that tweaking the -H and -A options makes a big difference in running time. There is…
Daniel
  • 26,899
  • 12
  • 60
  • 88
38
votes
4 answers

Converting IEEE 754 floating point in Haskell Word32/64 to and from Haskell Float/Double

Question In Haskell, the base libraries and Hackage packages provide several means of converting binary IEEE-754 floating point data to and from the lifted Float and Double types. However, the accuracy, performance, and portability of these methods…
acfoltzer
  • 5,588
  • 31
  • 48
38
votes
7 answers

Where can I find a list of all GHC extensions

I wanted to use {-# LANGUAGE OverloadedStrings #-} but I forgot how it's called. This kind of thing isn't hoogle-able, and also it takes some time finding using google*. Is there somewhere a list of GHC extensions named as they are in the LANGUAGE…
yairchu
  • 23,680
  • 7
  • 69
  • 109