How does IncoherentInstances work?

Well this is quite complicated. Lets start with the ambiguous error: <interactive>:1:1: Ambiguous type variable `b0′ in the constraint: (Arity b0) arising from a use of `arity’ Probable fix: add a type signature that fixes these type variable(s) In the expression: arity foldr In an equation for `it’: it = arity foldr Normally, without overlapping … Read more

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

Simon Marlow mentions another approach in GHC bug 2209 (also linked to from Bryan O’Sullivan’s answer) You can achieve the desired effect using castSTUArray, incidentally (this is the way we do it in GHC). I’ve used this option in some of my libraries in order to avoid the unsafePerformIO required for the FFI marshalling method. … Read more

How are Haskell programs compiled and executed internally?

To compile and execute a programming language on stock hardware you need a number of things: a compiler to translate your source language into assembly code executable by the native host a support library (aka runtime) for primitive language services, such as memory management, IO and thread management. Things that must be leveraged from lower-level … Read more

Where can I learn about #ifdef?

The GHC documentation has a section relating to the C pre-processor that documents some of the predefined pre-processor macros. The Cabal documentation has a section relating to conditional compilation that gives an example relating to base. If you are writing a portable package, you should be using Cabal, anyway.

GHC’s RTS options for garbage collection

Generally speaking, garbage collection is a space/time tradeoff. Give the GC more space, and it will take less time. There are (many) other factors in play, cache in particular, but the space/time tradeoff is the most important one. The tradeoff works like this: the program allocates memory until it reaches some limit (decided by the … Read more

Excessive amount of system calls when using `threadDelay`

The way GHC’s memory management is structured, in order to keep memory usage under control, a ‘major GC’ is periodically needed, during the running of the program. This is a relatively expensive operation, and it ‘stops the world’ – the program makes no progress whilst this is occurring. Obviously, it is undesirable for this to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)