ekmett/reflection

Reflection does not install anymore under GHC 7.6.3

Closed this issue · 18 comments

Hello Ed,

sorry if mine is an idiotic issue. I saw you updated reflection tonight, and this is now generating a failure when installing on my Mac Os X 10.8 with GHC 7.6.3:

cabal install reflection                                                                                                                               
Resolving dependencies...
Configuring reflection-1.3...
Building reflection-1.3...
Preprocessing library reflection-1.3...
[1 of 1] Compiling Data.Reflection  ( fast/Data/Reflection.hs, dist/build/Data/Reflection.o )

fast/Data/Reflection.hs:92:21:
    A newtype constructor cannot have an existential context,
      but `Magic' does
    In the definition of data constructor `Magic'
    In the newtype declaration for `Magic'
Failed to install reflection-1.3
cabal: Error: some packages failed to install:
reflection-1.3 failed during the building phase. The exception was:
ExitFailure 1

Interesting. Do any previous versions of it install for you?

Interestingly enough, yesterday night (10:00 pm UK time) I've installed aeson-lens, which depends on reflection. Then night-time your changes kicked in, and this morning I couldn't install reflection anymore :)

That is very strange. That is clearly not an existential context.

newtype Magic a r = Magic (forall s. Reifies s a => Proxy s -> r)

Also it is interesting that I haven't changed that part of the code in quite a while.

Uhm.. strange indeed. Just out of curiosity, which GHC version are you using atm? I'll give it a shot this evening on my personal macbook, even though I'm using hsenv and ghc 7.6.3 on both machines.

Obviously if you change the newtype to be a data it does install, but my gut feeling would say is not want we want, and there was a rational behind the newtype. Furthermore, it doesn't explain, the error, is a fix, not a solution :(

Changing the type to data destroys the whole hack that makes reflection work.

I'm on 7.4.1 as I'm currently operating on a shipped platform for support reasons.

I just tried to build it with 7.6.2, i get the same problem

arter ~ » cabal install reflection
Resolving dependencies...
Downloading reflection-1.3...
Configuring reflection-1.3...
Building reflection-1.3...
Failed to install reflection-1.3
Last 10 lines of the build log ( /Users/carter/.cabal/logs/reflection-1.3.log ):Building reflection-1.3...Preprocessing library reflection-1.3...[1 of 1] Compiling Data.Reflection ( fast/Data/Reflection.hs, dist/build/Data/Reflection.o )fast/Data/Reflection.hs:92:21: A newtype constructor cannot have an existential context, but Magic' does In the definition of data constructorMagic' In the newtype declaration for `Magic'cabal: Error: some packages failed to install:
reflection-1.3 failed during the building phase. The exception was:
ExitFailure 1

the version tagged 1.2.0.1
commit hash 96b5a41
builds fine on my machine.

I've created an issue to track this on the ghc side: http://hackage.haskell.org/trac/ghc/ticket/7873#comment:1

It may be the fact that i turned on PolyKinds in the module defining Magic, whereas previously it was previously only in the module with Proxy.

Ed, I've tried to use the "hacked" version of reflection (the one with data instead of newtype) and at least aeson-lens seems to work just fine. Can you come up with a use case scenario where using data would really destroy the entire library?

The version I just shipped to hackage a couple of hours ago should work. Using data there is actually completely nonsensical.

It is relying on the equivalence of the representation of (Reifies s a => Proxy s -> r) and (Proxy s -> a) -> Proxy s -> r. When you put data there, you've added a box, and there isn't an expected equivalence in the representation. You are unsafeCoercing a box around such a function to a function.

Your runtime probably just didn't run long enough to crash or do something terrible to you. ;) Any semblance of working with data is completely coincidental or is based on the fact that evaluated data returns itself. This isn't nearly as safe to rely on though.

aeson-lens doesn't actually use reify. ;)

Closing this out as it worksforme, now.

It's working for me too, thanks :)
Didn't mean to argue with you Ed :D I was just curious to learn something about the internals :P

A.

Sorry if that reply came off as a bit prickly. I was just trying to convey why data doesn't make sense there. =)