
Hi, looks like I hit a bug, but I'm not sure which software it belongs to, gcc, ghc or atlas? ---------- error doing "runhaskell Setup build" ---------- Preprocessing library hmatrix-0.4.1.0... /usr/bin/ld: dist/build/Numeric/GSL/Special/Internal_hsc_make: hidden symbol `__powidf2' in /usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.2/libgcc.a(_powidf2.o) isreferenced by DSO /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: ld returned 1 exit status linking dist/build/Numeric/GSL/Special/Internal_hsc_make.o failed command was: /usr/bin/ghc -optl-lgsl -optl-llapack dist/build/Numeric/GSL/Special/Internal_hsc_make.o -o dist/build/Numeric/GSL/Special/Internal_hsc_make ---------- error doing "runhaskell Setup build" ---------- I believe `__powidf2' is a internal symbol in gcc and it is hidden. The system is archlinux x86_64 and the software I used are atlas-lapack 3.8.2-1 gcc 4.3.2-1 Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: ../configure --prefix=/usr --enable-shared --enable-languages=c,c++,fortran,objc,obj-c++,treelang --enable-threads=posix --mandir=/usr/share/man --infodir=/usr/share/info --enable-__cxa_atexit --disable-multilib --libdir=/usr/lib --libexecdir=/usr/lib --enable-clocale=gnu --disable-libstdcxx-pch --with-tune=generic Thread model: posix gcc version 4.3.2 (GCC) ghc 6.8.2-2 [("Project name","The Glorious Glasgow Haskell Compilation System") ,("Project version","6.8.2") ,("Booter version","6.8.2") ,("Stage","2") ,("Interface file version","6") ,("Have interpreter","YES") ,("Object splitting","YES") ,("Have native code generator","YES") ,("Support SMP","YES") ,("Unregisterised","NO") ,("Tables next to code","YES") ,("Win32 DLLs","") ,("RTS ways"," debug thr thr_p thr_debug") ,("Leading underscore","NO") ] I googled but no useful information. Best, Xiao-Yong -- c/* __o/* <\ * (__ */\ <

Xiao-Yong Jin
Hi, looks like I hit a bug, but I'm not sure which software it belongs to, gcc, ghc or atlas?
---------- error doing "runhaskell Setup build" ---------- Preprocessing library hmatrix-0.4.1.0... /usr/bin/ld: dist/build/Numeric/GSL/Special/Internal_hsc_make: hidden symbol `__powidf2' in /usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.2/libgcc.a(_powidf2.o) isreferenced by DSO /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: ld returned 1 exit status linking dist/build/Numeric/GSL/Special/Internal_hsc_make.o failed command was: /usr/bin/ghc -optl-lgsl -optl-llapack dist/build/Numeric/GSL/Special/Internal_hsc_make.o -o dist/build/Numeric/GSL/Special/Internal_hsc_make ---------- error doing "runhaskell Setup build" ----------
It might be a problem of atlas. With Intel's MKL, it builds fine. -- c/* __o/* <\ * (__ */\ <

Hi, Im trying to overload a multiplication operator for scalars and vectors, but keep running into the error message "Functional dependencies conflict". What I think is going on is that the dependency check doesn't work with incoherent (or overlapping) instances. In the example below, the two instances of Mult are overlapping. What I want is the vector version to be used for vectors and the scalar version used for numbers, even if a vector-type is an instance of the Num-class (I believe -fallow-incoherent-instances would make that kind of choise for me, right?). Im using the Visual Studio plugin Visual Haskell, and thus GHC version 6.6. Otherwise I think associated types might have worked better for this... Regards Tobias Bexelius {-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances -fallow-incoherent-instances #-} data V2 a = V2 a a class Vec v a where dot :: v a -> v a -> a instance Num a => Vec V2 a where V2 a1 a2 `dot` V2 b1 b2 = a1*b1+a2*b2 class Mult a b c | a b -> c where (*.) :: a -> b -> c instance (Num x) => Mult x x x where (*.) = (*) instance (Vec a x) => Mult (a x) (a x) x where (*.) = dot

Hi,
On Wed, Oct 8, 2008 at 2:31 PM, Tobias Bexelius
Hi,
Im trying to overload a multiplication operator for scalars and vectors, but keep running into the error message "Functional dependencies conflict". What I think is going on is that the dependency check doesn't work with incoherent (or overlapping) instances. In the example below, the two instances of Mult are overlapping. What I want is the vector version to be used for vectors and the scalar version used for numbers, even if a vector-type is an instance of the Num-class (I believe -fallow-incoherent-instances would make that kind of choise for me, right?).
Im using the Visual Studio plugin Visual Haskell, and thus GHC version 6.6. Otherwise I think associated types might have worked better for this...
{-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances -fallow-incoherent-instances #-}
data V2 a = V2 a a
class Vec v a where dot :: v a -> v a -> a instance Num a => Vec V2 a where V2 a1 a2 `dot` V2 b1 b2 = a1*b1+a2*b2
class Mult a b c | a b -> c where (*.) :: a -> b -> c instance (Num x) => Mult x x x where (*.) = (*) instance (Vec a x) => Mult (a x) (a x) x where (*.) = dot
According to the definition of Mult the parameter 'c' from above should be uniquely determined by a pair of types 'a' and 'b'. Now, lets say we have a type NumVec that instantiates both the Vec class and the Num as in instance Num (NumVec a) where instance Vec NumVec a where Then according to the instance declaration instance (Num x) => Mult x x x where ... (NumVec a) (NumVec a) (NumVec a) instantiates the class. On the other hand looking at the instance declaration: instance (Vec a x) => Mult (a x) (a x) x where ... (NumVec a) (NumVec a) a , is also an instance why the fun dep (a b -> c) is violated. Regards, Joel

Yeah, I realized that. But heres where I would like the undecidable incoherent instances to kick in, i.e. as long as I haven't got any NumVec instances GHC should be able to choose only one of the Mult instances. Or do I have too much faith in the -fallow-incoherent-instances flag now? :/ I would like to be able to write something like
instance (Vec a x, -Num (a x)) => Mult (a x) (a x) x where (*.) = dot where -Num (a x) means that (a x) must not be an instance of Num. Can I express this in some way?
Regards
Tobias
-----Original Message-----
From: Joel Björnson [mailto:joel.bjornson@gmail.com]
Sent: den 8 oktober 2008 15:50
To: Tobias Bexelius
Cc: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] Functional dependencies and incoherent instances
Hi,
On Wed, Oct 8, 2008 at 2:31 PM, Tobias Bexelius
Hi,
Im trying to overload a multiplication operator for scalars and vectors, but keep running into the error message "Functional dependencies conflict". What I think is going on is that the dependency check doesn't work with incoherent (or overlapping) instances. In the example below, the two instances of Mult are overlapping. What I want is the vector version to be used for vectors and the scalar version used for numbers, even if a vector-type is an instance of the Num-class (I believe -fallow-incoherent-instances would make that kind of choise for me, right?).
Im using the Visual Studio plugin Visual Haskell, and thus GHC version 6.6. Otherwise I think associated types might have worked better for this...
{-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances -fallow-incoherent-instances #-}
data V2 a = V2 a a
class Vec v a where dot :: v a -> v a -> a instance Num a => Vec V2 a where V2 a1 a2 `dot` V2 b1 b2 = a1*b1+a2*b2
class Mult a b c | a b -> c where (*.) :: a -> b -> c instance (Num x) => Mult x x x where (*.) = (*) instance (Vec a x) => Mult (a x) (a x) x where (*.) = dot
According to the definition of Mult the parameter 'c' from above should be uniquely determined by a pair of types 'a' and 'b'. Now, lets say we have a type NumVec that instantiates both the Vec class and the Num as in instance Num (NumVec a) where instance Vec NumVec a where Then according to the instance declaration instance (Num x) => Mult x x x where ... (NumVec a) (NumVec a) (NumVec a) instantiates the class. On the other hand looking at the instance declaration: instance (Vec a x) => Mult (a x) (a x) x where ... (NumVec a) (NumVec a) a , is also an instance why the fun dep (a b -> c) is violated. Regards, Joel

On Wed, Oct 8, 2008 at 2:59 PM, Tobias Bexelius
Or do I have too much faith in the -fallow-incoherent-instances flag now? :/
Overlapping instances are an "instance definition"-time feature; incoherent instances only become applicable at the call site for polymorphic functions in the presence of overlapping instances. As an example, consider the following overlapping instances: {-# LANGUAGE OverlappingInstances #-} class Foo a where foo :: a -> Bool instance Foo a where foo x = False instance Foo Integer where foo x = (x == 3) test1 :: String -> Bool test1 x = foo x -- uses "Foo a" instance test2 :: Integer -> Bool test2 x = foo x -- uses "Foo Integer" instance test3 :: a -> Bool test3 x = foo x -- incoherent! Consider (test3 (3 :: Integer)). This should definitely use the implementation for instance Foo Integer. But it can't, because test3 doesn't know what type its argument is! Incoherent instances still allows test3 to compile, but it may choose the "wrong" instance. In this case, test3 will use the "Foo a" instance no matter what type of argument you pass it. But the incoherency only arises at a call-site for the class method; if you take test3 out of this program, the instances are still overlapping but there is no compile problem (assuming -foverlapping-instances). If you are getting an error because of an instance definition, as opposed to a call site, incoherent instances won't help you. -- ryan

I think the technique described at http://haskell.org/haskellwiki/GHC/AdvancedOverlap may give you what you want. I've never tried it myself though. / Emil Tobias Bexelius skrev:
Yeah, I realized that.
But heres where I would like the undecidable incoherent instances to kick in, i.e. as long as I haven't got any NumVec instances GHC should be able to choose only one of the Mult instances. Or do I have too much faith in the -fallow-incoherent-instances flag now? :/
I would like to be able to write something like
instance (Vec a x, -Num (a x)) => Mult (a x) (a x) x where (*.) = dot where -Num (a x) means that (a x) must not be an instance of Num. Can I express this in some way?
Regards Tobias

Hi Xiao-Yong, In i686 Arch linux, with the normal blas and lapack, I need: extra-libraries: gsl lapack blas gslcblas gfortran But using atlas-lapack: extra-libraries: gsl lapack f77blas gslcblas atlas gcc_s I don't know how I found that "__powidf2" is in libgcc_s :) I will add these options to hmatrix.cabal. -Alberto Xiao-Yong Jin wrote:
Hi, looks like I hit a bug, but I'm not sure which software it belongs to, gcc, ghc or atlas?
---------- error doing "runhaskell Setup build" ---------- Preprocessing library hmatrix-0.4.1.0... /usr/bin/ld: dist/build/Numeric/GSL/Special/Internal_hsc_make: hidden symbol `__powidf2' in /usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.2/libgcc.a(_powidf2.o) isreferenced by DSO /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: ld returned 1 exit status linking dist/build/Numeric/GSL/Special/Internal_hsc_make.o failed command was: /usr/bin/ghc -optl-lgsl -optl-llapack dist/build/Numeric/GSL/Special/Internal_hsc_make.o -o dist/build/Numeric/GSL/Special/Internal_hsc_make ---------- error doing "runhaskell Setup build" ----------
I believe `__powidf2' is a internal symbol in gcc and it is hidden.
The system is archlinux x86_64 and the software I used are
atlas-lapack 3.8.2-1
gcc 4.3.2-1 Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: ../configure --prefix=/usr --enable-shared --enable-languages=c,c++,fortran,objc,obj-c++,treelang --enable-threads=posix --mandir=/usr/share/man --infodir=/usr/share/info --enable-__cxa_atexit --disable-multilib --libdir=/usr/lib --libexecdir=/usr/lib --enable-clocale=gnu --disable-libstdcxx-pch --with-tune=generic Thread model: posix gcc version 4.3.2 (GCC)
ghc 6.8.2-2 [("Project name","The Glorious Glasgow Haskell Compilation System") ,("Project version","6.8.2") ,("Booter version","6.8.2") ,("Stage","2") ,("Interface file version","6") ,("Have interpreter","YES") ,("Object splitting","YES") ,("Have native code generator","YES") ,("Support SMP","YES") ,("Unregisterised","NO") ,("Tables next to code","YES") ,("Win32 DLLs","") ,("RTS ways"," debug thr thr_p thr_debug") ,("Leading underscore","NO") ]
I googled but no useful information.
Best, Xiao-Yong

Alberto Ruiz
Hi Xiao-Yong,
In i686 Arch linux, with the normal blas and lapack, I need:
extra-libraries: gsl lapack blas gslcblas gfortran
But using atlas-lapack:
extra-libraries: gsl lapack f77blas gslcblas atlas gcc_s
I guess you want cblas instead of gslcblas, since atlas has it.
I don't know how I found that "__powidf2" is in libgcc_s :)
References and bibliography is truly important.
I will add these options to hmatrix.cabal.
-Alberto
Thanks a lot for the excellent work. Xiao-Yong -- c/* __o/* <\ * (__ */\ <
participants (6)
-
Alberto Ruiz
-
Emil Axelsson
-
Joel Björnson
-
Ryan Ingram
-
Tobias Bexelius
-
Xiao-Yong Jin