Shen Chen Xu | 24 Apr 23:37 2014

Fwd: Type/type class information in GHC plugin

Hello everyone,

I would like to write a GHC plugin which adds wrapper to functions. Say I have
a function

addWrapper :: Ord a => (a -> b) -> a -> b

which is supposed to transform (assuming the argument is in the Ord class)

foo = \ x -> ...


foo = addWrapper (\ x -> ...)

This works fine if I'm only interested in wrapping functions of type Int ->
Int, in which case I make addWrapper to also have type

addWrapper :: (Int -> Int) -> Int -> Int

and use mkCoreApp to apply addWrapper to the right hand side.

However, if I want it to be polymorphic as described above, the transformed GHC
Core for an Int -> Int function should look like

foo = addHook  <at>  GHC.Types.Int  <at>  GHC.Types.Int GHC.Classes.$fOrdInt (\ x -> ...)

My question is, given the right hand side of foo, how do I construct the
type/type class information inside Core shown above?

(Continue reading)

Sergei Meshveliani | 23 Apr 10:59 2014

testing 7.8.2

Dear GHC developers,

I have tested  ghc-7.8.2-src  by making it by  ghc-7.6.3  

under  Debian Linux.
Then I have `made' my DoCon-2.12 application by  ghc-7.8.2. 

It looks all right.
For any occasion, here are some test results.

Comparing it to  ghc-7.4.1  shows the following.

1) The default context reduction stack (21) is not sufficient,        
   so, I add  -fcontext-stack=30  to the options.

2) The resulting  libHSdocon-2.12.a  is  1/10 larger
   (but the DoCon source is not the same, and it is, may be 1/100  

3) The  Main  executable test size is almost the same. 

4) The test running speed is the same. 

5) The minimal -M memory setting for running the test is  4300 Kb
   against  2400 Kb  of  ghc-6.4.1.


(Continue reading)

Christian Maeder | 23 Apr 10:23 2014

ghc -M


using "ghc -M" with ghc-7.8.2 under linux. I got a message:

   You must specify at least one -dep-suffix

(and a failure).

I've stopped using "ghc -M" now, but I think it should be documented better.

Maybe dynamic linking complicated matters.

Cheers Christian
Sergei Meshveliani | 22 Apr 20:53 2014

installing random-


can you, please, explain me how to make the `random' package visible for

I have 
* installed  haskell-platform-2013.2.0.0, 
* `made'  ghc-7.8.2  from source by  ghc-7.6.3,

and run  make configure

under  ghc-7.8.2

for my  DoCon  program.  docon.cabal  has

tested-with:     GHC
build-type:      Simple
build-depends:   base >= 4 && < 5, containers >= 0.3 && <=, 
                 random >= 1.0 && < 1.2
  TypeSynonymInstances UndecidableInstances FlexibleContexts
  FlexibleInstances MultiParamTypeClasses OverlappingInstances
  RecordWildCards NamedFieldPuns DoAndIfThenElse
(Continue reading)

Simon Peyton Jones | 21 Apr 10:30 2014

Tightening up on inferred type signatures


GHC generally obeys this rule

·         If GHC infers a type f::type, then it’s OK for you to add a type signature saying exactly that.

For example, it rejects inferred types that are ambiguous.  I think this is a good property; it was certainly the source of many bug reports before inferred ambiguous types were rejected.

However, up to now (including in 7.8) GHC hasn’t followed this rule consistently. In particular, it will infer types like

   fold :: (Functor (PF a), Regular a) => (PF a b -> b) -> a -> b

(where PF is a type family). If you write this as a type signature, GHC will insist on FlexibleContexts and TypeFamilies.

So in, Jan has made GHC check inferred types in the same way that it checks declared types, thus rejecting the above inferred type unless you give the language extensions.

This makes the compiler more consistent.

But it does mean that some code may be rejected that 7.8 accepts.  This email is just a heads-up that you might want to compile your library with 7.10 (i.e. a snapshot of HEAD) well in advance.  There will be other breaking changes of course; e.g Applicative will finally be a superclass of Monad, for example.



Glasgow-haskell-users mailing list
Glasgow-haskell-users <at>
Roman Cheplyaka | 19 Apr 19:59 2014

Re: HSghc-prim- unknown symbol 'memcpy'

* M Farkas-Dyck <strake888 <at>> [2014-04-19 12:55:23-0500]
> On 19/04/2014, Roman Cheplyaka <roma <at>> wrote:
> > Don't know if it helps, but I think ghci loads the dynamic library, not the static one.
> I straced both the broken ghci on aforesaid system and a working ghci
> on a glibc system and it loads bare .o files.

Interesting. I thought that has changed in 7.8. I'd love to see an explanation
from someone knowledgeable.

Glasgow-haskell-users mailing list
Glasgow-haskell-users <at>
M Farkas-Dyck | 19 Apr 19:18 2014

HSghc-prim- unknown symbol 'memcpy'

I just built stock ghc 7.8.1 against musl on Linux x86_64. I get this:

$ ghci
GHCi, version 7.8.1:  :? for help
Loading package ghc-prim ... linking ... ghc:
/lib/ghc-7.8.1/ghc-prim- unknown symbol
ghc: unable to load package `ghc-prim'

memcpy is defined in /lib/libc.a; how can I link it in? I tried -lc
and -opt-lc options to ghci, in vain.
Jan Stolarek | 16 Apr 17:19 2014

Autocomplete command line options with GHC 7.8

Hi all,

GHC 7.8 adds --show-options flag that prints all supported command line flags on standard output. 
This can be used to enable autocompletion of command line options for ghc in shells that support 
autocompletion. If you're using bash add this snippet to your ~/.bashrc file:

<<<<<<<<<<<<< START

# Autocomplete GHC commands
    local envs=`ghc --show-options`
    # get the word currently being completed
    local cur=${COMP_WORDS[$COMP_CWORD]}

    # the resulting completions should be put into this array
    COMPREPLY=( $( compgen -W "$envs" -- $cur ) )
complete -F _ghc -o default ghc

<<<<<<<<<<<< END



PS. I also added a wiki page:
Feel free to add instructions for other shells.
Conal Elliott | 16 Apr 01:39 2014

Concrete syntax for open type kind?

I see ‘#’ for unlifted and ‘?’ for open kinds in compiler/parser/Parser.y: akind :: { IfaceKind } : '*' { ifaceLiftedTypeKind } | '#' { ifaceUnliftedTypeKind } | '?' { ifaceOpenTypeKind } | '(' kind ')' { $2 } kind :: { IfaceKind } : akind { $1 } | akind '->' kind { ifaceArrow $1 $3 }

However, I don’t know how to get GHC to accept ‘#’ or ‘?’ in a kind annotation. Are these kinds really available to source programs.

I see that undefined has an open-kinded type:

*Main> :i undefined undefined :: forall (a :: OpenKind). a -- Defined in ‘GHC.Err’

Looking in the GHC.Err source, I just see the following:

undefined :: a undefined = error "Prelude.undefined"

However, if I try similarly,

q :: a q = error "q"

I don’t see a similar type:

*X> :i q q :: forall a. a -- Defined at ../test/X.hs:12:1
I don't know what kind 'a' has here, nor how to find out.

-- Conal
Glasgow-haskell-users mailing list
Glasgow-haskell-users <at>
Ramin Honary | 14 Apr 19:35 2014

Fwd: Using Cabal to install terminfo- breaks GHC on Debian x86_64

Hi, thanks for your reply.

Yes, I know for a fact I was installing to the global registry. All of my Haskell projects depend on a few important packages, and I always install these globally. For stuff I just want to play around with, I just install into the user registry. Actually terminfo- is not something any of my projects depend on, but I had installed it globally anyway and then this problem occurred.

Also, the behavior Cabal installing Crypto- was odd. As I explained in my first e-mail, some of the shared modules were being built with file extensions of ".hi" instead of ".dyn_hi", but the "copy" phase of the Cabal installation was searching for files with ".dyn_hi" extensions and was failing. And not all modules were being built incorrectly, some modules had the correct ".dyn_hi", others had just ".hi". This may be a problem with the Crypto.cabal file, however.

But anyway, the transition to using shared libraries by default has (in my experience) caused just these two hiccups. I'm glad I was able to expose this problem.

-- Ramin Honary

On Mon, Apr 14, 2014 at 10:07 PM, Austin Seipp <austin <at>> wrote:
Hi Ramin,

Can I ask if you're installing packages into the global user database?
If so, that's definitely the way for this to happen - otherwise, Cabal
should never overwrite *anything* in the 'global' package directory
(in your case, under /usr/local/lib/ghc-7.8.2...) This is the only way
I can see this happening. In particular, installing 'terminfo' into my
local package database ('cabal install terminfo') works fine...

Carefully review your cabal configuration if you don't mind. You can
also always force the installation using '--user' when running cabal.

However, thank you very much for bringing this to my attention. What
you have discovered is a real brainfart I don't think we had
considered! The problem is that now that GHC is dynamically linked, we
*cannot* get away with lying about whether those packages are
installed - because they must install shared objects for GHC itself to
work. That means overwriting them by accident (because we don't think
they're installed) is a real possibility.

Relatedly, the NixOS Haskell users are suffering from the same problem
with 7.8.2 -
- same problem, slightly different symptoms.

See for the ticket.

So this is definitely a real problem. I think scheduling the change
for 7.8.3 is correct.

My intuition tells me the fix might actually be quite simple - don't
lie about xhtml and terminfo being installed, and just be honest. Is
there any particular downside to doing this? I don't think so, *other*
than the fact it does mean terminfo has to come along when it's not
part of the Haskell Platform!

On Mon, Apr 14, 2014 at 7:08 AM, Ramin Honary <ramin.honary <at>> wrote:
> I am using Debian, not Mac. It is possible the problem may be with the
> binary release for Debian x86_64, or it could just be my Cabal config file.
> When I install the binary distribution onto Debian, I simply run "make
> install" in the ghc-7.8.2 directory. I don't know how this install process
> the creates the GHC package registry, but after a fresh install, the output
> of the "ghc-pkg list" command shows that "terminfo-" is NOT installed
> even though there the /usr/local/lib/ghc-7.8.2/terminfo- directory
> clearly exists and is populated with the correct library files. But since it
> is not registered Cabal tries to re-build it and overwrites the existing
> "terminfo-" package.
> After a fresh install on Mac or Fedora, I wonder if "terminfo-" shows
> up in the GHC package registry? It could be the package registry for the
> Debian binary distribution missed that detail.
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users <at>


Austin Seipp, Haskell Consultant
Well-Typed LLP,

Glasgow-haskell-users mailing list
Glasgow-haskell-users <at>
Ramin Honary | 13 Apr 17:08 2014

Using Cabal to install terminfo- breaks GHC on Debian x86_64

I am posting this to the mailing list, but it is a copy of a post I originally made on Haskell Reddit.

My GHC is working fine now. But there seem to be some changes in either GHC 7.8.2 or Cabal- that have broken some of the older packages in Hackage.

TL;DR I discovered the "Crypto- package is broken, and trying to install "terminfo-" breaks GHC by over-writing the terminfo library that came with the GHC tarball because isn't in the GHC package registry.

I downloaded the binary distribution from here:

and then immediately began re-building all of the packages in my .cabal/packages/ direcotry.

I admit, all of my problems may be due to my Cabal config, but I haven't had any problems with it before this, as far as I know it is the default setup the option to build profiling libraries set to True.

The first problem I had was that Crypto- was not building files correctly. Some of shared object files "*.dyn_o" were being built without their accompanying "*.dyn_hi" files, although some of the "*.dyn_hi" files did exist). When cabal tried to copy these "*.dyn_hi" files to the global package registry during installation it would fail with something about (for example) "could not find RSA.dyn_hi". To solve this, I rebuilt every "*.dyn_o" file that did not have an accompanying "*.dyn_hi" by hand using the command

ghc -dynamic --make Codec.Binary.RSA

The resulting "Codec/Binary/RSA.hi" file was actually a dynamic interface file but it's file extension was just ".hi" for some reason, (I double checked by using ghc --show-iface) so I just copied it it the "dist/build/Codec/Binary/" directory. I did this for every "*.hi" file that was supposed to be named "*.dyn_hi". This included about 10 files. Again, some "*.dyn_o" did build correctly with an accompanying "*.dyn_hi", about 10 of the modules were built incorrectly, all the rest were OK.

The second problem I had was with installing "Yi" which relies on the "terminfo-" package. The "terminfo" library that came with the GHC 7.8.2 binary distribution does not show up in the output of "ghc-pkg list", so Cabal tries to build it thinking it doesn't exist, and it overwrites the existing "terminfo-" package with a library that contains missing symbols. This causes GHC to completely stop working. The "ghc" program immediately fails with an error:

symbol lookup error: /usr/local/lib/ghc-7.8.2/bin/../haskeline- \ undefined symbol: terminfozm0zi4zi0zi0_SystemziConsoleziTerminfoziCursor_moveDown5_info

I was able to solve this problem by simply copying the contents of:


from the source distribution tarball to the GHC installation directory:


and that solved the problem. But any program depending on "terminfo" simply will not install properly. The terminfo- package does not show up in the output of ghc-pkg list, even though it comes with the GHC 7.8.2 tarball and GHC relies on it. Attempting to install Terminfo will build a ".so" file that GHC cannot use. So don't install terminfo- from Hackage.

Fortunately, Yi is not something that is absolutely necessary. I was able to install every other package I needed (lens, diagrams, yesod, xmonad, gtk) without incident.

But whatever changes have been made in ghc-7.8.2 and the accompanying Cabal- seem to have broken some of the older Hackage packages.

Glasgow-haskell-users mailing list
Glasgow-haskell-users <at>