ndmitchell / uniplate

Haskell library for simple, concise and fast generic operations.
Other
76 stars 8 forks source link

Use GHC.Types.SPEC to fix compilation with shared:False #15

Closed thomie closed 4 years ago

thomie commented 8 years ago

This fixes https://ghc.haskell.org/trac/ghc/ticket/8618, and allows uniplate to be installed when shared:False is set in ~/.cabal.

Edit: some more background information.

From compiler/specialise/SpecConstr.hs in the ghc repository:

Note [Forcing specialisation]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

With stream fusion and in other similar cases, we want to fully
specialise some (but not necessarily all!) loops regardless of their
size and the number of specialisations.

We allow a library to do this, in one of two ways (one which is
deprecated):

  1) Add a parameter of type GHC.Types.SPEC (from ghc-prim) to the loop body.

  2) (Deprecated) Annotate a type with ForceSpecConstr from GHC.Exts,
     and then add *that* type as a parameter to the loop body

The reason #2 is deprecated is because it requires GHCi, which isn't
available for things like a cross compiler using stage1.

So the issue here goes something like this:

This commit changes uniplate to use GHC.Types.SPEC instead of ForceSpecConstr, as suggested by that Note.

GHC.Types.SPEC was added to ghc-prim 0.3.1.0 / GHC 7.8.1 [1]. It's magic is partially explained in [2]. I made a similar pull request for vector in [3].

[1] https://downloads.haskell.org/~ghc/7.8.1/docs/html/users_guide/release-7-8-1.html [2] http://git.haskell.org/ghc.git/commitdiff/cee3adbcc180bdf1be8b24aeaafa2ca4a737cbbf [3] https://github.com/haskell/vector/pull/83

ndmitchell commented 8 years ago

Thanks for the patch! I have managed to get myself wedged with a load of local changes in Uniplate that are in a state I don't want to merge or lose, which is both annoying, and means that the time to merge in this patch will probably be a month or so. But the patch looks good and I will merge.

langston-barrett commented 5 years ago

Ping @ndmitchell

ndmitchell commented 4 years ago

Many apologies this patch took 4 years to get in. I took the code and reapplied it to master, as part of #31. Thanks very much, and sorry life got away from me.