Negative doubles or floats in Haskell (macports)

Why does a segmentation error occur when I try to show a negative double or float? There are no problems for negative integers.

Prelude> let a = 4 Prelude> :ta a :: Integer Prelude> let b = -4 Prelude> b -4 Prelude> :tb b :: Integer Prelude> let c = 5.6 Prelude> :tc c :: Double Prelude> let d = -5.6 Prelude> :td d :: Double Prelude> show d "-Segmentation fault 

I tried it in different ways, it seems that the number is correctly understood, but not shown. Version Information:

 ghci --version The Glorious Glasgow Haskell Compilation System, version 6.10.4 
+4
source share
4 answers

GHC on MacPorts seems to be broken. See https://trac.macports.org/ticket/25265

Instead, consider installing the Haskell platform from haskell.org, which includes GHC 6.12.3 and a set of Haskin treats.

+6
source

The most important thing you should understand is that segmentation errors should never occur in Haskell. Its type system ensures that at runtime nothing like this "goes wrong." If you see a segmentation error, that is, either an error in your Haskell compiler, or you are linking to C code with Haskell FFI, and something went wrong with your C code. However, in pure Haskell code you will never see this.

+2
source

March 2011: This is fixed in the release of the GHC 7 Haskell Platform , where both 32-bit and 64-bit native Mac ports are in excellent condition.

+1
source

Works for me 6.12.3. May be a bug in this version.

0
source

All Articles