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

Function type specialisation in Haskell

I have a function that has type Read a => String -> a, is it possible to have another function with the same name that does things differently when a is for example String? Are there any GHC extensions that allow this? Something like: f :: Read a…
Marek Sapota
  • 20,103
  • 3
  • 34
  • 47
2
votes
1 answer

GHC Compile Errors

I created a very simple program: module CompileTest(main) where main = putStrLn "Hello, World!" When I try to compile it using ghc CompileTest.hs I get: /usr/lib/ghc-6.12.1/libHSrtsmain.a(Main.o): In function `main': (.text+0x10): undefined…
Xodarap
  • 11,581
  • 11
  • 56
  • 94
2
votes
1 answer

specialization in type classes using ghc

How can I make the genOut/String fire? module IOStream where import System.IO import System.IO.Unsafe class Out a where out :: a → String instance Show a ⇒ Out a where out = show outString :: String → String outString = id {-# RULES…
Cetin Sert
  • 4,497
  • 5
  • 38
  • 76
2
votes
1 answer

ghc - square brackets on command line?

On this page: http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours/Parsing it shows ghc being called thusly: ghc -package parsec -o simple_parser [../code/listing3.4.hs listing3.4.hs] What are the square brackets for? I get an error…
ErikR
  • 51,541
  • 9
  • 73
  • 124
2
votes
2 answers

Simple Haskell compile error not understood

I am currently learning Haskell. I am trying to write a function which given two list of n distinct elements returns true if one is a permutation of the other. I am doing this as an exercise. I first wrote it as : isPermut :: (Eq…
user1188374
  • 829
  • 2
  • 7
  • 9
2
votes
2 answers

Why Haskell ghc does not work, but runghc works well?

One code work from runghc, but I can not compile same one with ghc command. Why? Below is my minimal code and environment: https://gist.github.com/1588756 Works well: $ runghc cat.hs Can not compile: $ ghc cat.hs -o cat Macbook air, max os x snow…
Matt - sanemat
  • 5,418
  • 8
  • 37
  • 41
2
votes
1 answer

No available version of ghc-prim -any with GHC 7.2.2

I've got ghc-7.2.2 unknown linux tar.bz2 installed in $HOME on archlinux. After installing a number of packages successfully with cabal-dev trying to install eg. parsec-numbers, text, ad etc I get: cabal: cannot configure base-4.4.1.0 It requires…
2
votes
1 answer

Using a haskell function from C++: Undefined reference error

I want to call haskell functions out of C++ and did use the tutorial at http://www.haskell.org/ghc/docs/7.0.2/html/users_guide/ffi-ghc.html So I have a haskell file Foo.hs: module Foo where foreign export ccall foo :: Int -> IO Int foo :: Int ->…
Heinzi
  • 5,793
  • 4
  • 40
  • 69
2
votes
1 answer

Trying to write a function point free, GHCI does not approve

As an exercise I'm trying to implement interesting parts of the prelude manually. Whenever I spot an opportunity to go point free I take it. However this has led me to a brick wall in the most unlikely place. Using this code: myelem _ [] = False…
TheIronKnuckle
  • 7,224
  • 4
  • 33
  • 56
2
votes
1 answer

GHC - getting weird dynamic linker errors (libffi.so.4)

Whenever I try to compile an executable with ghc --make, I am getting the following error when trying to execute the program afterwards, despite there being no errors upon compilation: ./main: error while loading shared libraries: libffi.so.4:…
Cubic
  • 14,902
  • 5
  • 47
  • 92
2
votes
3 answers

Getting a string from a IO ExitCode monad

I'm trying to concatenate a string given as an argument (using getArgs) to the haskell program, e.g.: "rm " ++ filename ++ " filename2.txt" which is inside a main = do block. The problem is with the type of filename, and ghc won't compile it,…
meltuhamy
  • 3,293
  • 4
  • 23
  • 22
2
votes
1 answer

Could not load any module in Haskell

I made 3 Haskell scripts in a folder, and they import Text.Printf, Data.Char, Data.List, and System.Random: HaskellList.hs import Data.List import System.Random main :: IO () main = do let vb = [50, 40, 30, 20, 10, 0] let vbEli = head vb …
Prido1024
  • 51
  • 3
2
votes
1 answer

Haskell implementation of Determinant, Rank and Inverse Matrix calculation- input matrix size limitation

I'm new to Haskell. As a part of an academic course, I was requested to implement a function in Haskell that calculates the determinant, rank and inverse matrix of a given matrix. I use gaussian elimination (performing same row operations on both…
Menish
  • 21
  • 3
2
votes
2 answers

Strictness and how to tell GHC/GHCi to just store a value in a variable once and for all

Apologies if this is a common question, I couldn't find anything similar, but I may just be too inexperienced to know the proper vocabulary. Here's an example of the fundamental problem in GHCi: -- foo is something relatively expensive to compute,…
Syncrossus
  • 570
  • 3
  • 17
2
votes
0 answers

How to suppress warnings from external packages?

My stack build shows warning from external packages, like: happy > /tmp/stack-d6caed253e9f21bf/happy-1.20.0/src/ProduceGLRCode.lhs:224:12: warning: [-Wincomplete-uni-patterns] 176happy > Pattern match(es) are…
Abhijit Sarkar
  • 21,927
  • 20
  • 110
  • 219
1 2 3
99
100