haskell-numerics / random-fu

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

Couldn't match expected type `RVar Char' against inferred type `random-fu-0.1.4:Data.Random.RVar.RVar Char' #4

Closed mcandre closed 12 years ago

mcandre commented 12 years ago

Something may have changed in the random-fu API, because my Haskell project, genetics, fails to compile in Ubuntu.

Specs:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 10.04.3 LTS
Release:    10.04
Codename:   lucid

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.12.1

$ cabal --version
cabal-install version 0.8.0
using version 1.8.0.2 of the Cabal library

$ cabal list random-fu --installed
* random-fu
    Synopsis: Random number generation
    Latest version available: 0.2.1.0
    Latest version installed: 0.2.1.0
    Homepage: https://github.com/mokus0/random-fu
    License:  PublicDomain

Trace:

$ git clone https://github.com/mcandre/genetics.git
$ cd genetics
$ make
ghc --make -O2 -fforce-recomp -optl"-Wl,-no_compact_unwind" hellogenetics.hs genetics.hs -package base -package random-extras -package random-fu
[1 of 2] Compiling Genetics         ( genetics.hs, genetics.o )
[2 of 2] Compiling Main             ( hellogenetics.hs, hellogenetics.o )

hellogenetics.hs:16:22:
    Couldn't match expected type `RVar Char'
           against inferred type `random-fu-0.1.4:Data.Random.RVar.RVar Char'
    In the first argument of `runRVar', namely `(choice ['a' .. 'z'])'
    In the expression: runRVar (choice ['a' .. 'z']) DevRandom
    In the definition of `randomChar':
        randomChar = runRVar (choice ['a' .. 'z']) DevRandom

hellogenetics.hs:25:20:
    Couldn't match expected type `RVar a'
           against inferred type `random-fu-0.1.4:Data.Random.RVar.RVar Int'
    In the first argument of `runRVar', namely
        `(choice [0 .. length target - 1])'
    In a stmt of a 'do' expression:
        index <- runRVar (choice [0 .. length target - 1]) DevRandom
    In the expression:
        do { index <- runRVar (choice [0 .. length target - 1]) DevRandom;
             ch <- randomChar;
               return $ take index gene ++ [ch] ++ drop (index + 1) gene }
make: *** [all] Error 1
mokus0 commented 12 years ago
Couldn't match expected type `RVar Char'
       against inferred type `random-fu-0.1.4:Data.Random.RVar.RVar Char'

This part looks suspect to me; something in your ghc-pkg database appears to still want an old version of random-fu. Is 'choice' the one from "random-extras"? If so, I'm not sure whether the author of that package maintains it, but its cabal file demands random-fu version 0.1.*, so that's probably the problem. As far as I know, though, most of its "extras" are already in random-fu, so you may not need it anyway. "choice", for example, does the same thing as "randomElement". If there's a performance difference or some other reason to prefer the random-extras version, I'd like to hear about that anyway so I can fix mine ;)

mcandre commented 12 years ago

Thanks, randomElement does exactly that, and I was able to remove random-extras as a dependency from genetics.