haskell-numerics / hmatrix

Linear algebra and numerical computation
381 stars 104 forks source link

Build failure with GHC 8.2 #232

Closed snoyberg closed 6 years ago

snoyberg commented 7 years ago
src/Internal/Util.hs:625:5: error:
    • Could not deduce (Eq t)
      from the context: (Indexable (c t) a, Indexable (c t) t,
                         Linear t c, Num (c t), Fractional t, Num a, Eq a)
        bound by the inferred type for ‘redu’:
                   forall a t (c :: * -> *).
                   (Indexable (c t) a, Indexable (c t) t, Linear t c, Num (c t),
                    Fractional t, Num a, Eq a) =>
                   (Int, [c t]) -> [c t]
        at src/Internal/Util.hs:(625,5)-(632,20)
    • In the ambiguity check for the inferred type for ‘redu’
      To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
      When checking the inferred type
        redu :: forall a t (c :: * -> *).
                (Indexable (c t) a, Indexable (c t) t, Linear t c, Num (c t),
                 Fractional t, Num a, Eq a) =>
                (Int, [c t]) -> [c t]
      In an equation for ‘pivotDown’:
          pivotDown t n xs
            | t == n = []
            | otherwise = y : pivotDown t (n + 1) ys
            where
                y : ys = redu (pivot n xs)
                pivot k
                  = (const k &&& id) . sortBy (flip compare `on` (abs . (! k)))
                redu (k, x : zs)
                  | p == 0 = error "gauss: singular!"
                  | otherwise = u : map f zs
                  where
                      p = x ! k
                      u = scale (recip (x ! k)) x
                      ....
                redu (_, []) = []
    |
625 |     redu (k,x:zs)
    |     ^^^^^^^^^^^^^...
albertoruiz commented 7 years ago

I think this problem has been solved in https://github.com/albertoruiz/hmatrix/pull/231

mstksg commented 7 years ago

Anything in particular keeping this from being pushed to hackage? :)

albertoruiz commented 7 years ago

I'm on a trip, without a computer :) I will push a new version to hackage in a few days.

albertoruiz commented 7 years ago

I have pushed the package. Please check that it works, I cannot properly test it at the moment.

aligusnet commented 7 years ago

Yes, it works now, thanks.

I have successfully built my mltool with the following stack.yaml:

resolver: nightly-2017-08-09
packages:
- '.'
extra-deps: [hmatrix-0.18.1.0, hmatrix-gsl-0.18.0.1, hmatrix-gsl-stats-0.4.1.6]
flags: {}
extra-package-dbs: []
extra-lib-dirs: [/usr/lib]
idontgetoutmuch commented 6 years ago

It doesn't work for me

nix-shell -p "haskell.packages.ghc822.ghcWithPackages (pkgs: [pkgs.hmatrix-gsl])"
[20 of 27] Compiling Internal.Util    ( src/Internal/Util.hs, dist/build/Internal/Util.o )

src/Internal/Util.hs:625:5: error:
    • Could not deduce (Eq t)
      from the context: (Indexable (c t) a, Indexable (c t) t,
                         Linear t c, Num (c t), Fractional t, Num a, Eq a)
        bound by the inferred type for ‘redu’:
                   forall a t (c :: * -> *).
                   (Indexable (c t) a, Indexable (c t) t, Linear t c, Num (c t),
                    Fractional t, Num a, Eq a) =>
                   (Int, [c t]) -> [c t]
        at src/Internal/Util.hs:(625,5)-(632,20)
    • In the ambiguity check for the inferred type for ‘redu’
      To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
      When checking the inferred type
        redu :: forall a t (c :: * -> *).
                (Indexable (c t) a, Indexable (c t) t, Linear t c, Num (c t),
                 Fractional t, Num a, Eq a) =>
                (Int, [c t]) -> [c t]
      In an equation for ‘pivotDown’:
          pivotDown t n xs
            | t == n = []
            | otherwise = y : pivotDown t (n + 1) ys
            where
                y : ys = redu (pivot n xs)
                pivot k
                  = (const k &&& id) . sortBy (flip compare `on` (abs . (! k)))
                redu (k, x : zs)
                  | p == 0 = error "gauss: singular!"
                  | otherwise = u : map f zs
                  where
                      p = x ! k
                      u = scale (recip (x ! k)) x
                      ....
                redu (_, []) = []
    |
625 |     redu (k,x:zs)
    |     ^^^^^^^^^^^^^...
idontgetoutmuch commented 6 years ago

Must be an old version of nixpkgs. I downloaded it from git and now it works.

nix-shell -p "haskell.packages.ghc822.ghcWithPackages (pkgs: [pkgs.hmatrix-gsl])" -I nixpkgs=/Users/dom/nixpkgs
idontgetoutmuch commented 6 years ago

@albertoruiz @snoyberg I think this ticket can be closed?

albertoruiz commented 6 years ago

Yes, thanks!