haskell-numerics / random-fu

A suite of Haskell libraries for representing, manipulating, and sampling random variables
42 stars 21 forks source link

Fix build of random-source for GHC 8.4 and below #61

Closed int-e closed 3 years ago

int-e commented 3 years ago

Two specializations in Data.Random.Source.StdGen cause a scary panic in ghc < 8.6:

[11 of 11] Compiling Data.Random.Source.StdGen ( src/Data/Random/Source/StdGen.hs, dist/dist-sandbox-9d371a75/build/Data/Random/Source/StdGen.o )

src/Data/Random/Source/StdGen.hs:62:1: warning:
    You cannot SPECIALISE ‘RandomGen.getRandomPrimFromRandomGenState’
      because its definition has no INLINE/INLINABLE pragma
      (or its defining module ‘Data.Random.Source.RandomGen’
       was compiled without -O)
   |
62 | {-# SPECIALIZE RandomGen.getRandomPrimFromRandomGenState :: Prim a -> State StdGen a #-}
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ghc: panic! (the 'impossible' happened)
  (GHC version 8.4.4 for x86_64-unknown-linux):
        dsImpSpecs
  getRandomPrimFromRandomGenState
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
        pprPanic, called at compiler/deSugar/DsBinds.hs:720:28 in ghc:DsBinds

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

This patch disables them for old versions of ghc.

This patch adds an INLINABLE pragma to the specialized function (as suggested by the warning).

int-e commented 3 years ago

NB, why does circleci want me to log in (requesting all sorts of permissions including write access to repos with very flimsy excuses: "We ask for read/write access to make your experience seamless on CircleCI.") in order to simply view a build log? That seems very invasive, and is not going to happen.

(Sorry, I'm mostly venting. But perhaps it's worth checking whether there's a CircleCI setting to make the logs publicly viewable?)

int-e commented 3 years ago

(3rd push. Sorry if you've looked at this in the meantime, I suck at amending commits.)