haskell-numerics / random-fu

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

Newest version hides the PureMT module? #62

Closed adamConnerSax closed 3 years ago

adamConnerSax commented 3 years ago

I think v0.3.0.10 has hidden the "Data.Random.Source.PureMT" module.

  1. I think that is a breaking change so the version number should change to at least 0.4, I think. Can you fix that on hackage? Otherwise it will break things with correctly specified upper bounds.

  2. Why? Is the stuff in there available someplace else now?

Thanks!

int-e commented 3 years ago

The module has been removed in https://github.com/haskell-numerics/random-fu/commit/5e8469f8381d549b00139efaa44f0dd4f3e80575

I'm not sure why the module was removed along with the import in the test suite, but I agree that should've resulted in a major version bump.

As for 2., the testsuite does the following https://github.com/haskell-numerics/random-fu/blob/3de77f71f4cf507317145db36a0c86aef0371903/tests/speed/TestSupport.hs#L26-L29 which afaics works as a random source thanks to the instance

instance (Monad m1, RandomGen g, ModifyRef (Ref m2 g) m1 g) => RandomSource m1 (Ref m2 g)
adamConnerSax commented 3 years ago

Will the hackage versioning be fixed? Or the module added back and the current version deprecated? Otherwise everyone who relied on that module may have to go in and fix their upper bounds.

idontgetoutmuch commented 3 years ago

I am really sorry about this. I will investigage today.

idontgetoutmuch commented 3 years ago

I mistakenly thought that a recent PR had introduced this module as I get this

[2 of 2] Compiling Main             ( Bench.hs, dist/build/random-fu-bench/random-fu-bench-tmp/Main.o )

Bench.hs:44:38: error:
    • Overlapping instances for RandomSource
                                  IO (GHC.IORef.IORef System.Random.Mersenne.Pure64.Internal.PureMT)
        arising from a use of ‘dists’
      Matching instances:
        two instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the second argument of ‘bgroup’, namely ‘(dists mtSrc count)’
      In the expression: bgroup "PureMT" (dists mtSrc count)
      In the second argument of ‘bgroup’, namely
        ‘[bgroup "MWC" (dists mwcSrc count),
          bgroup "PureMT" (dists mtSrc count),
          bgroup "StdGen" (dists stdSrc count),
          bgroup "DevRandom" (dists DevRandom count), ....]’
   |
44 |             , bgroup "PureMT"       (dists mtSrc        count)
   |                                      ^^^^^^^^^^^^^^^^^^^^^^^^

builder for '/nix/store/majvhzyl7qdhzp24h8b5i05nlabvaqdr-speed-tests-0.0.0.1.drv' failed with exit code 1
error: build of '/nix/store/majvhzyl7qdhzp24h8b5i05nlabvaqdr-speed-tests-0.0.0.1.drv' failed

I see now that I was mistaken and that this module has existed for some time. At the moment I don't understand why I am getting overlapping instances.

idontgetoutmuch commented 3 years ago

I have created a PR to fix this: https://github.com/haskell-numerics/random-fu/pull/63 by going back to a version which didn't have overlapping instances. I'll add you as reviewers.

idontgetoutmuch commented 3 years ago

I closed the PR as it didn't seem to remove the offending files. I want to force push but this would be very bad practice. I am not sure how to work round this.

int-e commented 3 years ago

As far as I can see, that overlap was introduced by #45 (reverted in #55, reinstated in #56), which generalized

-- module Data.Random.Source.StdGen
instance (Monad m, ModifyRef (IORef   StdGen) m StdGen) => RandomSource m (IORef   StdGen) where

to

-- module Data.Random.Source.RandomGen
instance (Monad m, RandomGen g, ModifyRef (IORef g) m g) => RandomSource m (IORef g) where
int-e commented 3 years ago

This should be fixed in random-fu-0.2.7.7 which is now on hackage and provides the same interface as random-fu-0.2.7.4. I also deprecated the 0.2.7.6 version, so cabal-install at least should not pick that version anymore.

P.S.: The relevant package is random-source, for which there is a new 0.3.0.11 release that has the same API as 0.3.0.8, and whose 0.3.0.10 release is now deprecated.