ghc

Is it possible to skip the nursery?

跟風遠走 提交于 2019-12-20 09:34:39
问题 If I know a certain value is likely to survive its first encounter with the garbage collector, is there some way to let GHC know, so it can just allocate it directly somewhere outside the nursery? For instance, if I'm building up a large structure out of a bunch of smaller pieces, I know each piece will last at least until the whole structure is complete. 回答1: In the GHC garbage collector there are no hooks for hinting at the generation an object should be allocated to. However, you might be

Haskell tuple constructor (GHC) and the separation between a language and its implementation

无人久伴 提交于 2019-12-20 09:32:35
问题 Haskell blew my mind yet again when I realised that (x,y) Is just syntactic sugar for (,) x y Naturally I wanted to extend this to larger tuples. But (,) x ((,) y z) Gave me (x,(y,z)) Which was not what I was looking for. On a whim, I tried (,,) x y z And it worked, giving exactly what I wanted: (x,y,z) This raised the question: How far can you take it? Much to my astonishment, there seemed to be no limit. All of the below are valid operators: (,) (,,) (,,,) (,,,,) --etc (,,,,,,,,,,,,,,) (,,,

Error in Compiling haskell .ll file with llvm backend

让人想犯罪 __ 提交于 2019-12-20 03:14:34
问题 I want to compile haskell using ghc front-end and llvm back-end. I have following code in my haskell hello.hs file: main = putStrLn "Hello World!" I compile hello.hs with ghc using following command ghc -fllvm -keep-llvm-files -force-recomp -hello.hs which generate a hello.ll file along with other files. I then try to compile this .ll file into a .bc file. llvm-as hello.ll -o hello.bc and then this .bc file to executable file llc hello.bc -o hello which generate an executable file. The

New GHC feature - did I imagine it?

一曲冷凌霜 提交于 2019-12-20 02:09:08
问题 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? 回答1:

New GHC feature - did I imagine it?

霸气de小男生 提交于 2019-12-20 02:09:03
问题 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? 回答1:

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

时光毁灭记忆、已成空白 提交于 2019-12-19 19:51:29
问题 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. 回答1: You can't. ThreadId is abstract. The Int you

Haskell compiling with -O2 drastically increases memory usage

牧云@^-^@ 提交于 2019-12-19 18:22:29
问题 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

GHC complains about non-exhaustive patterns that are enforced by the type checker

可紊 提交于 2019-12-19 16:36:16
问题 I have the following code {-# LANGUAGE DataKinds, GADTs, TypeOperators #-} data Vect v a where Nil :: Vect '[] a Vec :: a -> Vect v a -> Vect (() ': v) a instance Eq a => Eq (Vect v a) where (==) Nil Nil = True (Vec e0 v0) == (Vec e1 v1) = e0 == e1 && v0 == v1 When compiling or interpreting with -Wall the following warning is given: Pattern match(es) are non-exhaustive In an equation for `==': Patterns not matched: Nil (Vec _ _) (Vec _ _) Nil Normally this is to be expected. Normally, even if

GHC complains about non-exhaustive patterns that are enforced by the type checker

时间秒杀一切 提交于 2019-12-19 16:36:10
问题 I have the following code {-# LANGUAGE DataKinds, GADTs, TypeOperators #-} data Vect v a where Nil :: Vect '[] a Vec :: a -> Vect v a -> Vect (() ': v) a instance Eq a => Eq (Vect v a) where (==) Nil Nil = True (Vec e0 v0) == (Vec e1 v1) = e0 == e1 && v0 == v1 When compiling or interpreting with -Wall the following warning is given: Pattern match(es) are non-exhaustive In an equation for `==': Patterns not matched: Nil (Vec _ _) (Vec _ _) Nil Normally this is to be expected. Normally, even if

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

折月煮酒 提交于 2019-12-19 12:52:33
问题 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