ghc

How to find out GHC's memory representations of data types?

喜夏-厌秋 提交于 2019-11-27 16:13:03
问题 Recently, blog entries such as Computing the Size of a Hashmap explained how to reason about space complexities of commonly used container types. Now I'm facing the question of how to actually "see" which memory layout my GHC version chooses (depending on compile flags and target architecture) for weird data types (constructors) such as data BitVec257 = BitVec257 {-# UNPACK #-} !Word64 {-# UNPACK #-} !Word64 {-# UNPACK #-} !Bool {-# UNPACK #-} !Word64 {-# UNPACK #-} !Word64 data BitVec514 =

What advantages do StableNames have over reallyUnsafePtrEquality#, and vice versa?

旧巷老猫 提交于 2019-11-27 14:51:02
问题 data StableName a Stable names have the following property: If sn1 :: StableName and sn2 :: StableName and sn1 == sn2 then sn1 and sn2 were created by calls to makeStableName on the same object. The reverse is not necessarily true: if two stable names are not equal, then the objects they name may still be equal. reallyUnsafePtrEquality# :: a -> a -> Int# reallyUnsafePtrEquality# returns whether two objects on the GHC heap are the same object. It's really unsafe because the garbage collector

GHC 7.10 generates slower code than older versions

偶尔善良 提交于 2019-11-27 14:46:19
问题 I realized that the latest version of GHC (7.10.3) produces significantly slower code than an older version. My current version as of now: $ ghc --version The Glorious Glasgow Haskell Compilation System, version 7.10.3 I have also two other old versions installed on my local machine. My test code is taken from here (the collatz1.hs code): import Data.Word import Data.List import System.Environment collatzNext :: Word32 -> Word32 collatzNext a = (if even a then a else 3*a+1) `div` 2 -- new

How can I set my GHCi prompt to a lambda character on Windows?

落花浮王杯 提交于 2019-11-27 13:44:39
问题 I want to have a lambda (λ) symbol as my prompt in GHCi (7.8) on Windows 7, so I set up my .ghci file as :set +m :set prompt "λ: " :set prompt2 " | " And I set my console font to Lucida Console since it's supposed to support Unicode, but when I load up GHCi, it looks like this instead How can I get Windows to recognize the λ symbol properly? 回答1: Using > chcp.com 65001 worked with ghci but opening other text files with vim after setting that code page returned garbled text. Add the following

What is fusion in Haskell?

会有一股神秘感。 提交于 2019-11-27 12:42:16
Every now and again I have been noticing the following in Haskell documentation: (for example in Data.Text ): Subject to fusion What is fusion and how do I use it? Alec 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, it comes for free through the GHC compiler. Haskell is pure Because Haskell is pure, we get

Data families vs Injective type families

为君一笑 提交于 2019-11-27 12:23:20
问题 Now that we have injective type families, is there any remaining use case for using data families over type families? Looking at past StackOverflow questions about data families, there is this question from a couple years ago discussing the difference between type families and data families, and this answer about use cases of data families. Both say that the injectivity of data families is their greatest strength. Looking at the docs on data families, I see reason not to rewrite all uses of

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

血红的双手。 提交于 2019-11-27 12:20:25
Occasionally, a piece of code I want to write isn't legal without at least one language extension. This is particularly true when trying to implement ideas in research papers, which tend to use whichever spiffy, super-extended version of GHC was available at the time the paper was written, without making it clear which extensions are actually required. The result is that I often end up with something like this at the top of my .hs files: {-# LANGUAGE TypeFamilies , MultiParamTypeClasses , FunctionalDependencies , FlexibleContexts , FlexibleInstances , UndecidableInstances ,

Fixing issues noted by ghc-pkg check

醉酒当歌 提交于 2019-11-27 10:16:18
问题 It's rather nice that ghc-pkg check will list broken packages, and why they are broken. But as far as I know, there is no automated way to take care of those broken packages. What is the recommended way to deal with broken packages? (Preferably not reinstall GHC) 回答1: Hopefully, you have been wise enough to not break any in your global package database. Breakage there can easily mean a reinstallation of GHC is necessary. So, let us assume that the breakage is restricted to the user package db

Specialization with Constraints

蓝咒 提交于 2019-11-27 09:54:08
问题 I'm having problems getting GHC to specialize a function with a class constraint. I have a minimal example of my problem here: Foo.hs and Main.hs. The two files compile (GHC 7.6.2, ghc -O3 Main ) and run. NOTE: Foo.hs is really stripped down. If you want to see why the constraint is needed, you can see a little more code here. If I put the code in a single file or make many other minor changes, GHC simply inlines the call to plusFastCyc . This will not happen in the real code because

Everywhere that GHC/Haskell Platform installs

无人久伴 提交于 2019-11-27 09:52:33
问题 Assume I want to completely reinstall GHC/HP. I want to (as much for superstition as anything) delete anything and everything from previous installs. What do I actually need to delete (and where)? Edit: I'm on OSX, but I'm more curious if this information is available in general, for all systems. Edit2: So far we have: OSX: /Library/Frameworks/GHC.framework/ ~/.cabal/ /usr/bin/ -- symlinks I'll add to that (based on "prefix" defined here: http://www.vex.net/~trebla/haskell/sicp.xhtml#storage)