ghc

cabal sandbox v. global package db

蓝咒 提交于 2019-12-01 22:00:35
问题 When installing inside a cabal sandbox, cabal will still use packages from the global package db (in particular, packages which came from the Haskell Platform). This can lead to install conflicts. Is it possible to configure cabal to ignore the global package db? I see the corresponding feature has been implemented in ghc itself, via a -no-global-package-db option (see https://ghc.haskell.org/trac/ghc/ticket/5977), and ghc-pkg will ignore the global package db if you do not pass it the -

New GHC feature - did I imagine it?

流过昼夜 提交于 2019-12-01 21:54:26
I swear I saw a new feature in a recent set of GHC release notes - but now I can find no reference to it. Am I delusional, or does this feature actually exist? It was to do with loading incomplete modules. As best as I can remember, it allows you to turn off compilation errors due to undefined variables. (Naturally, at run-time this causes an exception to be thrown if you try to actually use the undefined variables for anything.) Does that sound familiar? Or is my mind making this up? You are looking for a compile time option, vs a language extension, of " defer errors to runtime ". That is,

How can I build a ThreadId given that I know the actual number?

僤鯓⒐⒋嵵緔 提交于 2019-12-01 17:44:07
It often happens to me when debugging or playing around in GHCi that I happen to know the actual ThreadId number (for example from using Debug.Trace ), but that's all I have. The problem is that all thread APIs, such as killThread require a ThreadId and not an Int . I've tried Hoogle but came out empty. Is there a way to do this? I'm concerned mostly with debugging, so I don't mind if it's a nasty hack or if it's through a GHC-only library. You can't. ThreadId is abstract. The Int you have is actually nothing more than a counter ( source ): 32 static StgThreadID next_thread_id = 1; ... 59

Haskell compiling with -O2 drastically increases memory usage

你。 提交于 2019-12-01 17:28:44
This simple program runs in constant memory space when compiled with no flags with ghc: import Data.List f x = x*x g a = foldl' (+) (f a) [1..(1073741824-1)] main = do putStrLn $ show $ foldl' (+) 0 $ map g [0,1] When compiled with ghc -O2 the memory usage exceeds the system resources (8GB). Changing main to: main = do putStrLn $ show $ foldl' (+) 0 [g 0, g 1] alleviates the problem so it appears to be something to do with the map. Can anyone explain the behaviour and perhaps how to work around it? GHC version is: Glasgow Haskell Compiler, Version 7.4.1, stage 2 booted by GHC version 7.4.1

GHCi hangs when Ctrl+Cing from infinite loop with -fbreak-on-exception set

ε祈祈猫儿з 提交于 2019-12-01 16:08:46
As the title says, I create an infinite loop in GHCi: f x = x - 2 g x = if f x < x then g (f x + 2) else x g 2 Normally pressing Ctrl+C yields "Interrupted." and a return to the GHCi prompt. If I :set -fbreak-on-exception beforehand though, Ctrl+C does not break the loop and my only recourse is to kill the program externally. Is there a way to break into infinite loops using GHCi? Is this a bug? 来源: https://stackoverflow.com/questions/47188857/ghci-hangs-when-ctrlcing-from-infinite-loop-with-fbreak-on-exception-set

Liberal coverage condition introduced in GHC 7.7 breaks code valid in GHC 7.6

不羁岁月 提交于 2019-12-01 15:52:36
The idea I'm writing a DSL , which compiles to Haskell. Users of this language can define own immutable data structures and associated functions. By associated function I mean a function, which belongs to a data structure. For example, user can write (in "pythonic" pseudocode): data Vector a: x,y,z :: a def method1(self, x): return x (which is equivalent to the following code, but shows also, that associated functions beheva like type classes with open world assumption): data Vector a: x,y,z :: a def Vector.method1(self, x): return x In this example, method1 is a function associated with

How to get cabal to ignore the global package DB when using a sandbox

我是研究僧i 提交于 2019-12-01 15:28:40
I'm trying to install two libraries, Elm and yesod-platform , using a cabal sandbox on Ubuntu. The problem is, I'm using xmonad as my window manager. Thus, a bunch of Haskell libraries have been installed by my package manager. When trying to resolve dependencies, it's using the versions of the libraries installed by apt, and thus is giving a "maximum backjumps exceeded" error. How can I instruct Cabal to ignore any packages not in the Cabal sandbox, so that it will install fresh versinos of these packages in the sandbox and be able to resolve the dependcies? Too late probably, but still… I

Haskell: TVar: orElse

落爺英雄遲暮 提交于 2019-12-01 15:22:24
Is the "else" part of orElse called when a transaction is retried due to another transaction writing to a TVar it had read, or only when retry is explicitly called? If you have orElse a b then b is only run if retry is called explicitly in a . Otherwise orElse would essentially become nondeterministic. (The rerunning of transactions that is done by the STM runtime is transparent and should not effect the outcome of any computation.) 来源: https://stackoverflow.com/questions/10101044/haskell-tvar-orelse

Python-“is”-like equality operator for Haskell/GHC

旧巷老猫 提交于 2019-12-01 15:17:42
Is there a GHC-specific "unsafe" extension to ask whether two Haskell references point to the same location? I'm aware this can break referential transparency if not used properly. But there should be little harm (unless I'm missing something), if it is used very careful, as a means for optimizations by short-cutting recursive (or expensive) data traversal, e.g. for implementing an optimized Eq instance, e.g.: instance Eq ComplexTree where a == b = (a `unsafeSameRef` b) || (a `deepCompare` b) providing deepCompare is guaranteed to be true if unsafeSameRef decides true (but not necessarily the

GHCi hangs when Ctrl+Cing from infinite loop with -fbreak-on-exception set

烈酒焚心 提交于 2019-12-01 15:06:17
问题 As the title says, I create an infinite loop in GHCi: f x = x - 2 g x = if f x < x then g (f x + 2) else x g 2 Normally pressing Ctrl+C yields "Interrupted." and a return to the GHCi prompt. If I :set -fbreak-on-exception beforehand though, Ctrl+C does not break the loop and my only recourse is to kill the program externally. Is there a way to break into infinite loops using GHCi? Is this a bug? 来源: https://stackoverflow.com/questions/47188857/ghci-hangs-when-ctrlcing-from-infinite-loop-with