ghc

GHC + wxHaskell on Windows

Have GHC 6.8.3 and wxHaskell-0.10.3 on a Windows XP computer. Installed both as binary distributions, not by building from sources. Built a sample with the following command: ghc --make Paint.hs It works on that same computer it was built on (with GHC and wxHaskell installed), but fails if transferred to another one (with neither of th...

How to catch arbitrary exception in Haskell?

In ghc 6.10.1. ...

What is a good way to debug haskell code?

I have used the ghci debugger but would really prefer if it was somewhat integrated with a text editor to simplify the process of setting breakpoints. It should probably not strictly evaluate every visible variable but at least simplify the process of looking at the local state. I recently found the trace function which has been helpful...

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). ...

Should I use GHC Haskell extensions or not?

As I am learning Haskell, I see that there is a lot of language extensions used in real life code. As a beginner, should I learn to use them, or should I avoid them at all cost? I see that it breaks compatibility with Haskell 98 and limits code to pretty much GHC only. However, if I browse packages on Hackage, I see that most of them are...

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 "genOut/String" out = outString #-} infixl 9 <<, ≪ (≪), (<<) :: Out a ⇒ IO Handle → a → IO Handl...

Pass Pointer to an Array in Haskell to a C Function

I have the following C code: #include <sys/times.h> #include <time.h> float etime_( float *tarray ) { struct tms buf; times( &buf ); tarray[0] = 1.0 * buf.tms_utime / CLOCKS_PER_SEC; tarray[1] = 1.0 * buf.tms_stime / CLOCKS_PER_SEC; return tarray[0] + tarray[1]; } Trying to port this Fortran code to Haskell: ...

On Cygwin, how do I install curl from hackage?

From a Windows command prompt, c:\>cabal install curl Resolving dependencies... Configuring curl-1.3.5... cabal: Error: some packages failed to install: curl-1.3.5 failed during the configure step. The exception was: sh: runGenProcess: does not exist (No such file or directory) I have installed Cygwin's curl-devel package, but from a C...

Haddock: Failed to create dependency graph (when adding sections with * or a module heading)

I compiled and installed haddock-2.4.2 from the tarball source. Adding a few simple comments to the code here: https://dl.getdropbox.com/u/143480/doc/DualMap.hs and running haddock $ haddock -h -o doc Data/DualMap.hs Warning: Data.DualMap: could not find link destinations for: Data.Typeable.Typeable2 GHC.Base.Eq GHC.Show.Show G...

GHC parse error which I do not understand

I am teaching myself Haskell I want to write a function that recursively finds the first number that has an integer square root and is smaller than a starting number. It looks like this: findFirstSquare :: Int -> Int findFirstSquare x | x <= 0 = error "This function only works for 1 or above" | fr...

Mixing Erlang and Haskell

If you've bought into the functional programming paradigm, the chances are that you like both Erlang and Haskell. Both have purely functional cores and other goodness such as lightweight threads that make them a good fit for a multicore world. But there are some differences too. Erlang is a commercially proven fault-tolerant language ...

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 folders. Is there a command line option for GHC not to leave behind its intermediate files? (...

Problem using Network package in GHC

I have this simple code: import Network main = return () executing it with runhaskell fails: >runhaskell test.hs test.hs: C:\ghc\ghc-6.10.4\network-2.2.1.2\HSnetwork-2.2.1.2.o: unknown symbol `_getnameinfo' test.hs: test.hs: unable to load package `network-2.2.1.2' GHCi also gives simillar error message. What can I do about it? I ...

How to programmatically retrieve GHC package information?

More specifically, given an arbritary package name I need to retrieve the same library-dirs field that can be obtained with the ghc-pkg describe command from inside a running Haskell program. ...

How to use fromInteger in Haskell?

One way to calculate 2^8 in haskell is by writing product(replicate 8 2) When trying to create a function for this, defined as follows... power1 :: Integer → Integer → Integer power1 n k | k < 0 = error errorText power1 n 0 = 1 power1 n k = product(replicate k n) i get the following error: Couldn't match expected type 'Int' again...

How to get 64-bit binaries from GHC for Snow Leopard?

Hey guys, I've recently upgraded my OS to Snow Leopard, which broke my GHC. I was able to fix it on one machine by adding flags for 32-bit compiles in /usr/bin/ghc (something like -optl -m32 -opta -m32 -optc -m32, gathered from here). Now I can't get it to produce 64-bit binaries for my other machine, which supports 64-bits. The 32-b...

"cannot do signed 4 byte relocation" on compile

I'm going through Real world Haskell, and got to the example: -- file: ch04/InteractWith.hs -- Save this in a source file, e.g. Interact.hs import System.Environment (getArgs) interactWith function inputFile outputFile = do input <- readFile inputFile writeFile outputFile (function input) main = mainWith myFunction where mainWi...

How to customize the readline keybindings of ghci

I know ghci supports readline , and keybindings such as ^W and ^U work as expected. But I do wonder whether ghci support the customization of keybindings , just like the way bash deal with inputrc ? Thanks for any feedback. ...

Getting Cabal to work with GHC 6.12.1

I've installed the latest GHC package (6.12.1) on OS X, but I can't get Cabal to work. I've removed the version I had previously that worked with GHC 6.10 and tried to re-install from scratch. The latest Cabal version available for download is 1.6.0.2. However, when I try to build this I get the following error: Configuring Cabal-1.6...

Using stdout/stderr/stdin streams behind haskell's FFI

I'm developing a small haskell program that uses an external static library I've developed in C++. It accesses the lib through ghc's FFI (foreign function interface). Inside this library I would like to do some output to the console. However, it looks to me like the c++ side of things does not have a correct handle to stdout because outp...