ghc

How to install Haskell Platform on Linux Debian Wheezy?

旧城冷巷雨未停 提交于 2019-12-01 03:14:31
Initially I thought I would get install Haskell with couple of commands using apt-get but its seems somehow complex. As I look at the haskell org download page , I downloaded haskell-platform-2013.2.0.0.tar.gz . Then next step is somehow confusing. It ask to install GHC before installing platform but at the same time if one opens GHC download page , it shows some warning e.g Stop ! ..... we recommend installing the Haskell Platform instead of GHC . Please guide me how to install Haskell on Debian Wheezy. Can we build a .deb installation package from this package ? vivian $ sudo apt-get install

Which dictionary does GHC choose when more than one is in scope?

自作多情 提交于 2019-12-01 03:06:39
Consider the following example: import Data.Constraint class Bar a where bar :: a -> a foo :: (Bar a) => Dict (Bar a) -> a -> a foo Dict = bar GHC has two choices for the dictionary to use when selecting a Bar instance in foo : it could use the dictionary from the Bar a constraint on foo , or it could use the runtime Dict to get a dictionary. See this question for an example where the dictionaries correspond to different instances. Which dictionary does GHC use, and why is it the "correct" choice? GHC just picks one, and this is the correct choice. Any two dictionaries for the same constraint

How to detect if a program has been compiled using -threaded?

荒凉一梦 提交于 2019-12-01 02:45:02
I'm working on a Haskell daemon that uses POSIX fork/exec together with file locking mechanism. My experiments show that file locks aren't inherited during executeFile with -threaded runtime (see also this thread ), no matter if I use +RTS -N or not. So I'd like to add a check to be sure that the daemon ins't compiled with -threaded . Is there a portable way to detect it? There is a value in Control.Concurrent for this, for example: module Main (main) where import Control.Concurrent main :: IO () main = print rtsSupportsBoundThreads And test: $ ghc -fforce-recomp Test.hs; ./Test [1 of 1]

Code becomes slower as more boxed arrays are allocated

拜拜、爱过 提交于 2019-12-01 02:42:44
Edit: It turns out that things generally (not just array/ref operations) slow down the more arrays have been created, so I guess this might just be measuring increased GC times and might not be as strange as I thought. But I'd really like to know (and learn how to find out) what's happening here though, and if there's some way to mitigate this effect in code that creates lots of smallish arrays. Original question follows. In investigating some weird benchmarking results in a library, I stumbled upon some behavior I don't understand, though it might be really obvious. It seems that the time

Why are Haskell/GHC executables so large in filesize? [duplicate]

痴心易碎 提交于 2019-12-01 02:31:55
Possible Duplicate: Small Haskell program compiled with GHC into huge binary Recently I noticed how large Haskell executables are. Everything below was compiled on GHC 7.4.1 with -O2 on Linux. Hello World ( main = putStrLn "Hello World!" ) is over 800 KiB. Running strip over it reduces the filesize to 500 KiB; even adding -dynamic to the compilation doesn't help much, leaving me with a stripped executable around 400 KiB. Compiling a very primitive example involving Parsec yields a 1.7 MiB file. -- File: test.hs import qualified Text.ParserCombinators.Parsec as P import Data.Either (either) --

Writing “fib” to run in parallel: -N2 is slower?

牧云@^-^@ 提交于 2019-12-01 01:15:16
问题 I'm learning Haskell and trying write code to execute in parallel, but Haskell always runs it sequentially. And when I execute with the -N2 runtime flag it take more time to execute than if I omit this flag. Here is code: import Control.Parallel import Control.Parallel.Strategies fib :: Int -> Int fib 1 = 1 fib 0 = 1 fib n = fib (n - 1) + fib (n - 2) fib2 :: Int -> Int fib2 n = a `par` (b `pseq` (a+b)) where a = fib n b = fib n + 1 fib3 :: Int -> Int fib3 n = runEval $ do a <- rpar (fib n) b

Why is GHCi typing this statement oddly?

别说谁变了你拦得住时间么 提交于 2019-12-01 00:17:17
问题 In answering a question on stackoverflow, I noticed that GHCi (interactive) is assigning a too-restrictive type in a let statement. Namely, given the code, import Control.Arrow f = maximum &&& id >>> fst &&& (\(m,l) -> length $ filter (==m) l) (as on my answer to https://stackoverflow.com/questions/6281813/maximum-of-list-and-count-of-repeat-maximum-number/6283594#6283594), if one inserts a "let" before f and enters this in ghci, it gives the following type information Prelude Control.Arrow>

May I limit memory usage per function/monad/thread in Haskell?

心已入冬 提交于 2019-11-30 23:47:41
问题 I'm working on a research compiler project intended to work as a service. One of the requirements is that certain users might have a limited memory usage (e.g., "calls from IP a.b.c.d may use up to 30mb of heap memory") while handling its calls. My prototype implementation, written in C, simply uses a memory pool indead of malloc 'ing directly (which is actually pretty hard to get right due to effective types). Manual memory management, though. Is there any way to achieve this in Haskell, by

Howto kill a thread in Haskell

偶尔善良 提交于 2019-11-30 23:09:00
问题 Using Control.Concurrent and forkIO there are some cases that will leave the thread in a blocked state (this is especially frequent under windows with networking) so even if one try to use killThread the exception is never raised in the thread. Is there any other way to force a thread to die? My attempt to terminate the whole application with exitFailure from a helper thread don't have any effect under these conditions. The Glorious Glasgow Haskell Compilation System, version 6.12.1 HP 2010.1

How can I compile a GUI executable with ghc?

五迷三道 提交于 2019-11-30 22:39:39
I ported a little Haskell program I wrote from Mac to Windows. It's a GUI application (wxHaskell, compiled with ghc 6.12.1), so it does not need the command prompt window to open. It does so, anyway, so my question: What must I do so that the program starts without opening a prompt window first? Is there some ghc switch for this? When using wxWidgets with cygwin, you can avoid having a console window appear by passing the -mwindows flag to the linker . You can tell GHC to pass flags to the linker using the -optl prefix , so you could try building with -optl-mwindows and see if that works. I've