Perplexing GHC-7.0.3 behavior with hairy type-level code (regression from 6.12.3??)
Bjorn Buckwalter
bjorn at buckwalter.se
Fri Apr 22 17:18:51 CEST 2011
Hello all,
I am doing some fairly hairy type-level stuff with
FunctionalDependencies, UndecidableInstances, and other. Without going
into details I have the following function which compiles fine:
vecMat :: (Transpose m m', MatrixVector m' v v', Num a)
=> Vec v a -> Mat m a -> Vec v' a
vecMat v m = transpose m `matVec` v
However, I am perplexed by the following:
1. This does NOT compile despite the type signature being identical to
that of 'vecMat':
vecMat2 :: (Transpose m m', MatrixVector m' v v', Num a)
=> Vec v a -> Mat m a -> Vec v' a
vecMat2 v m = vecMat v m
The error message is along the lines of the below where 'HMap ...' is
the context for the MatrixVector instance... I'll provide more details
as needed.
Could not deduce (HMap (DotProd, v) m' v')
arising from a use of `vecMat'
from the context (Transpose m m', MatrixVector m' v v', Num a)
bound by the type signature for
vecMat2 :: (Transpose m m', MatrixVector m' v v', Num a) =>
Vec v a -> Mat m a -> Vec v' a
2. If I omit the type signature the definition of 'vecMat2' does compile:
vecMat2 v m = vecMat v m
3. If I omit the second argument it also compiles:
vecMat2 v = vecMat v
4. However, if I omit both arguments it does NOT compile:
vecMat2 = vecMat
So I guess I have two questions. First: why would 1 not compile?
Second: why are 2, 3, and 4 not equivalent? Pointers to relevant
documentation welcome.
I broke my GHC-6.12.3 installation when upgrading to the latest HP
with GHC-7.0.3 so I cannot test 2, 3, and 4 but I know that 1 DID
compile on GHC-6.12.3. Is the change of behavior in GHC-7.0.3 a bug or
a bug fix?
I'll be happy to elaborate on the code if it would be useful, and try
to find a minimal example. But I wanted to check if the behavior I am
seeing makes any sense at all first. In case you cannot wait the
'matVec' definition is from:
https://github.com/bjornbm/dimensional-vectors/blob/master/Numeric/Units/Dimensional/LinearAlgebra/Matrix.hs
Thanks,
Bjorn
More information about the Glasgow-haskell-users
mailing list