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
3
votes
2 answers

LLVM Opt missing in OS X 10.9.2

I am using Haskell's GHC to create LLVM code but it cannot find opt from LLVM. I googled the problem and it was recommended to install LLVM from homebrew, which I did, but there's no opt binary on my path. I am wondering where I can get it from so I…
jap
  • 617
  • 3
  • 13
3
votes
2 answers

Implementing Maybe version of GHC.Exts 'the' function

GHC.Exts exports the function the: the ensures that all the elements of the list are identical and then returns that unique element This function is partial as it throws an error in case not all elements of the list are equal. How can I implement…
Uli Köhler
  • 13,012
  • 16
  • 70
  • 120
3
votes
1 answer

Moving .ghc and .cabal to a different user

How can I move the GHC and cabal installed packages to a different user? I've copied the directories but I'm getting error messages like: ConfigParser.hs:15:8: Could not find module `Data.ByteString.Char8' There are files missing in the…
Uli Köhler
  • 13,012
  • 16
  • 70
  • 120
3
votes
5 answers

Iteratively printing every integer in a List

Say I have a List of integers l = [1,2] Which I want to print to stdout. Doing print l produces [1,2] Say I want to print the list without the braces map print l produces No instance for (Show (IO ())) arising from a use of `print' Possible fix: add…
Abraham P
  • 15,029
  • 13
  • 58
  • 126
3
votes
1 answer

Haskell Plugins gives old values when re-compiling file

I've been using the Haskell plugins package to compile strings into functions/values which can be used in Haskell at runtime. However, I've got a problem: when I try to load different values with the same name, it only gives the first value. Here's…
jmite
  • 8,171
  • 6
  • 40
  • 81
3
votes
1 answer

Interaction of forkIO/killThread with forkProcess

I've written the code below, and noticed that killThread blocks and the thread still continues. That only happens if I do it in the forkProcess, if I remove the forkProcess, everything works as expected. Code {-# LANGUAGE TupleSections #-} module…
bennofs
  • 11,873
  • 1
  • 38
  • 62
3
votes
0 answers

Preventing GHC from optimizing conversion between values sharing runtime representation (f.i. Int -> Integer)

I'm currently playing around a bit with the possibility of removing a level of indirection from all lifted but newtype-like types (single constructor with a single argument) in Haste; for instance, Int would get a plain number as its runtime…
valderman
  • 8,365
  • 4
  • 22
  • 29
3
votes
2 answers

Making unneeded conversions a no-op

I'm writing a program which reads and writes images that supports multiple pixel types (i.e. RGB, CMYK, greyscale etc.). These pixel types can use different types of components, sort of like this: class (Storable c) => PixelComponent c where …
Emil Eriksson
  • 2,110
  • 1
  • 21
  • 31
3
votes
3 answers

theoretical deadlock in Control.Concurrent.Chan readChan

Browsing the source of readChan one finds the following implementation and comment, starting with version 4.6 of base: -- |Read the next value from the 'Chan'. readChan :: Chan a -> IO a readChan (Chan readVar _) = do modifyMVarMasked readVar $…
wrl
  • 131
  • 4
3
votes
1 answer

How do I try out GHC 7.8-RC1 with projects requiring libraries?

I've downloaded the binary distribution for GHC 7.8-RC1. It did a nice job installing separate ghc/ghci/ghc-pkg binaries for 7.6 and 7.8. I can launch ghci and do wonderful things, and I can compile simple hello world files, but if I try to do…
Jake Brownson
  • 469
  • 2
  • 9
3
votes
1 answer

import "base" System.IO

In packages-haskell2010/System/IO.hs we have the following line : import "base" System.IO hiding (openFile, hWaitForInput) This form of import (where it is followed by a String and then by a module name) is not documented at Import. Am I correct…
artella
  • 5,068
  • 4
  • 27
  • 35
3
votes
1 answer

typeOf with type constructors of kind *->* / printing type of value from within program

Consider the following : module Main where data Tree a = EmptyTree | Node a (Tree a) (Tree a) deriving (Show, Read, Eq) data Container a b = Container{contField :: b a} deriving (Show) result = Container {contField = Node 'a' EmptyTree…
artella
  • 5,068
  • 4
  • 27
  • 35
3
votes
1 answer

Why reading of file takes memory for the whole file?

I'm doing this: import qualified Data.ByteString.Lazy.Char8 as BS main :: IO () main = do let filename = "sample.txt" text <- BS.readFile filename let res = BS.take 1000 $ text print res When I run this with profiling it gave…
The_Ghost
  • 2,070
  • 15
  • 26
3
votes
0 answers

Linking fails with filenames using Unicode characters

I'm going to create an .exe file from the (existing) file MonodyFrèreJacques.hs. However, when i give the command: ghc --make MonodyFrèreJacques.hs I get this error message: Linking MonodyFrèreJacques.exe ... C:\Program Files (x86)\Haskell…
Alberto Capitani
  • 1,039
  • 13
  • 30
3
votes
2 answers

less strict type language option

I have a function in Haskell: import qualified Codec.Picture as Juicy --juicyLoad :: FilePath -> IO (Vector Word8) juicyLoad file = do image <- Juicy.readPng file case image of Left err -> undefined Right (Juicy.ImageRGB8…
functorial
  • 687
  • 5
  • 13