Extracting the exponent and mantissa of a Javascript Number

Using the new ArrayBuffer access arrays, it is actually possible to retrieve the exact mantissa and exponent, by extracting them from the Uint8Array. If you need more speed, consider reusing the Float64Array. function getNumberParts(x) { var float = new Float64Array(1), bytes = new Uint8Array(float.buffer); float[0] = x; var sign = bytes[7] >> 7, exponent = … Read more

Is there a list of GHC extensions that are considered ‘safe’?

It’s probably best to look at what SafeHaskell allows: Safe Language The Safe Language (enabled through -XSafe) restricts things in two different ways: Certain GHC LANGUAGE extensions are disallowed completely. Certain GHC LANGUAGE extensions are restricted in functionality. Below is precisely what flags and extensions fall into each category: Disallowed completely: GeneralizedNewtypeDeriving, TemplateHaskell Restricted functionality: … Read more

What is fusion in Haskell?

In general, fusion refers to transformations whose purpose is to get rid of intermediate data structures. You fuse function calls that result in wasteful memory allocations into something more efficient. This is actually IMO one of the biggest applications of Haskell being pure. And you pretty much don’t need to do anything to get it, … Read more

Small Haskell program compiled with GHC into huge binary

Let’s see what’s going on, try $ du -hs A 13M A $ file A A: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.27, not stripped $ ldd A linux-vdso.so.1 => (0x00007fff1b9ff000) libXrandr.so.2 => /usr/lib/libXrandr.so.2 (0x00007fb21f418000) libX11.so.6 => /usr/lib/libX11.so.6 (0x00007fb21f0d9000) libGLU.so.1 => /usr/lib/libGLU.so.1 (0x00007fb21ee6d000) libGL.so.1 => /usr/lib/libGL.so.1 … Read more