Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

please allow random-1.3 #30

Open
juhp opened this issue Jan 11, 2025 · 1 comment
Open

please allow random-1.3 #30

juhp opened this issue Jan 11, 2025 · 1 comment

Comments

@juhp
Copy link

juhp commented Jan 11, 2025

See commercialhaskell/stackage#7648

@RyanGlScott
Copy link
Contributor

This is not a simple matter of raising upper version bounds, as bv-sized fails to build if you attempt to allow building with random-1.3.0, i.e.,

Build failures with random-1.3.0
$ cabal test --enable-tests --allow-newer=hedgehog:random,MonadRandom:random
Downloading
https://hackage.haskell.org/package/random-1.3.0/random-1.3.0.tar.gz
Configuration is affected by the following files:
- cabal.project
- cabal.project.local
Build profile: -w ghc-9.4.8 -O1
In order, the following will be built (use -v for more details):
 - MonadRandom-0.6.1 (lib) (requires build)
 - bv-sized-1.0.5.99 (lib) (first run)
 - bv-sized-1.0.5.99 (test:bv-sized-tests) (first run)
Starting     MonadRandom-0.6.1 (lib)
Preprocessing library for bv-sized-1.0.5.99...
Building library for bv-sized-1.0.5.99...
[5 of 6] Compiling Data.BitVector.Sized.Signed ( src/Data/BitVector/Sized/Signed.hs, dist-newstyle/build/x86_64-linux/ghc-9.4.8/bv-sized-1.0.5.99/build/Data/BitVector/Sized/Signed.o, dist-newstyle/build/x86_64-linux/ghc-9.4.8/bv-sized-1.0.5.99/build/Data/BitVector/Sized/Signed.dyn_o )

src/Data/BitVector/Sized/Signed.hs:141:10: error:
    • Could not deduce (UniformRange (BV w))
        arising from a use of ‘System.Random.Internal.$dmisInRange’
      from the context: (KnownNat w, 1 <= w)
        bound by the instance declaration
        at src/Data/BitVector/Sized/Signed.hs:141:10-58
    • In the expression:
        System.Random.Internal.$dmisInRange @(SignedBV w)
      In an equation for ‘isInRange’:
          isInRange = System.Random.Internal.$dmisInRange @(SignedBV w)
      In the instance declaration for ‘UniformRange (SignedBV w)’
    |
141 | instance (KnownNat w, 1 <= w) => UniformRange (SignedBV w) where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[6 of 6] Compiling Data.BitVector.Sized.Unsigned ( src/Data/BitVector/Sized/Unsigned.hs, dist-newstyle/build/x86_64-linux/ghc-9.4.8/bv-sized-1.0.5.99/build/Data/BitVector/Sized/Unsigned.o, dist-newstyle/build/x86_64-linux/ghc-9.4.8/bv-sized-1.0.5.99/build/Data/BitVector/Sized/Unsigned.dyn_o )

src/Data/BitVector/Sized/Unsigned.hs:132:10: error:
    • No instance for (UniformRange (BV w))
        arising from a use of ‘System.Random.Internal.$dmisInRange’
    • In the expression:
        System.Random.Internal.$dmisInRange @(UnsignedBV w)
      In an equation for ‘isInRange’:
          isInRange = System.Random.Internal.$dmisInRange @(UnsignedBV w)
      In the instance declaration for ‘UniformRange (UnsignedBV w)’
    |
132 | instance UniformRange (UnsignedBV w) where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Building     MonadRandom-0.6.1 (lib)

Failed to build MonadRandom-0.6.1.
Build log (
/home/ryanscott/.cache/cabal/logs/ghc-9.4.8/MonadRandom-0.6.1-c07184826eed22405a5fd7d0fb8976854da954f149ae6cf37de73f6fde981be6.log
):
Configuring library for MonadRandom-0.6.1...
Warning: [git-protocol] Cloning over git:// might lead to an arbitrary code
execution vulnerability. Furthermore, popular forges like GitHub do not
support it. Use https:// or ssh:// instead.
Preprocessing library for MonadRandom-0.6.1...
Building library for MonadRandom-0.6.1...
[1 of 7] Compiling Control.Monad.Random.Class ( Control/Monad/Random/Class.hs, dist/build/Control/Monad/Random/Class.o, dist/build/Control/Monad/Random/Class.dyn_o )

Control/Monad/Random/Class.hs:390:1: warning: [-Wunused-top-binds]
    Defined but not used: ‘fromListMayOld’
    |
390 | fromListMayOld xs = do
    | ^^^^^^^^^^^^^^
[2 of 7] Compiling Control.Monad.Trans.Random.Strict ( Control/Monad/Trans/Random/Strict.hs, dist/build/Control/Monad/Trans/Random/Strict.o, dist/build/Control/Monad/Trans/Random/Strict.dyn_o )

Control/Monad/Trans/Random/Strict.hs:285:10: error:
    • Couldn't match type: MutableGen f0 (RandT g m)
                     with: RandGen g
        arising from a use of ‘System.Random.Internal.$dmuniformByteArrayM’
      The type variable ‘f0’ is ambiguous
    • In the expression:
        System.Random.Internal.$dmuniformByteArrayM
          @(RandGen g) @(RandT g m)
      In an equation for ‘uniformByteArrayM’:
          uniformByteArrayM
            = System.Random.Internal.$dmuniformByteArrayM
                @(RandGen g) @(RandT g m)
      In the instance declaration for
        ‘StatefulGen (RandGen g) (RandT g m)’
    • Relevant bindings include
        uniformByteArrayM :: Bool
                             -> Int -> RandGen g -> RandT g m Data.Array.Byte.ByteArray
          (bound at Control/Monad/Trans/Random/Strict.hs:285:10)
    |
285 | instance (Monad m, RandomGen g) => StatefulGen (RandGen g) (RandT g m) where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: [Cabal-7125]
Failed to build MonadRandom-0.6.1 (which is required by test:bv-sized-tests from bv-sized-1.0.5.99). See the build log above for details.
Failed to build bv-sized-1.0.5.99 (which is required by test:bv-sized-tests from bv-sized-1.0.5.99).

There are multiple problems here:

  1. bv-sized's UniformRange instances lack explicit implementations of the isInRange method, which was added in random-1.3.0, and the generic default implementation doesn't work for the BV types. We will need to implement isInRange explicity to make this typecheck.
  2. Neither hedgehog or MonadRandom (used in the bv-sized test suite) currrently support random-1.3.0. hedgehog compiles if you simply raise the upper version bounds on random, but MonadRandom does not compile against random-1.3.0. I've opened Build failure with random-1.3.0 byorgey/MonadRandom#54 for this. (As such, this issue is blocked on Build failure with random-1.3.0 byorgey/MonadRandom#54.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants