why doesn't ghc give you a type signature that works ?

for example: I will ask the glorious compiler, and it says: *Main> :t calcFFT calcFFT :: (Math.FFT.Base.FFTWReal r) => V.Vector (Complex r) -> V.Vector (Complex r) I then put the signature in my code, reload it, and: Not in scope: type constructor or class `Math.FFT.Base.FFTWReal' It seems very strange to me that the fully qualified module name doesn't work, nor does any combination thereof, e.g. FFT.FFTWReal, FFT.Base.FFTWReal, etc... I'm importing FFT as: import qualified Math.FFT as FFT I'm not sure if that causes the problem. Generally speaking this happens to me quite a lot, and I've never tried to understand what's going on, because the signature is not required. I've decided to try now :-) Obviously I'll need some help. Thanks, Brian

On 18 May 2011 13:44,
for example:
I will ask the glorious compiler, and it says:
*Main> :t calcFFT calcFFT :: (Math.FFT.Base.FFTWReal r) => V.Vector (Complex r) -> V.Vector (Complex r)
I then put the signature in my code, reload it, and:
Not in scope: type constructor or class `Math.FFT.Base.FFTWReal'
It seems very strange to me that the fully qualified module name doesn't work, nor does any combination thereof, e.g. FFT.FFTWReal, FFT.Base.FFTWReal, etc...
I'm importing FFT as:
import qualified Math.FFT as FFT
What's happening is that the type involves the FFTWReal class. However, this isn't immediately visible to ghci as it isn't in scope, but it can figure out that it's found in Math.FFT.Base. As such, you need to import that module as well (as opposed to just the Math.FFT class you have already imported). -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

If you're importing the module as
import qualified Math.FFT as FFT
Shouldn't "Math.FFT" become "FFT"? :)
On Tue, May 17, 2011 at 8:44 PM,
for example:
I will ask the glorious compiler, and it says:
*Main> :t calcFFT calcFFT :: (Math.FFT.Base.FFTWReal r) => V.Vector (Complex r) -> V.Vector (Complex r)
I then put the signature in my code, reload it, and:
Not in scope: type constructor or class `Math.FFT.Base.FFTWReal'
It seems very strange to me that the fully qualified module name doesn't work, nor does any combination thereof, e.g. FFT.FFTWReal, FFT.Base.FFTWReal, etc...
I'm importing FFT as:
import qualified Math.FFT as FFT
I'm not sure if that causes the problem.
Generally speaking this happens to me quite a lot, and I've never tried to understand what's going on, because the signature is not required. I've decided to try now :-)
Obviously I'll need some help.
Thanks,
Brian
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- -- Regards, KC

On 5/17/11 11:53 PM, KC wrote:
If you're importing the module as
import qualified Math.FFT as FFT
Shouldn't "Math.FFT" become "FFT"? :)
Nope. Depending on your definition of "should" at least. Hierarchical modules are not considered entities exported by modules further up on the tree. So that's not the specified behavior of qualified imports. (Whether it should be is a separate debate.)
On Tue, May 17, 2011 at 8:44 PM,
wrote: for example:
I will ask the glorious compiler, and it says:
*Main> :t calcFFT calcFFT :: (Math.FFT.Base.FFTWReal r) => V.Vector (Complex r) -> V.Vector (Complex r)
I then put the signature in my code, reload it, and:
Not in scope: type constructor or class `Math.FFT.Base.FFTWReal'
You can have functions in scope whose types include types which are not themselves in scope. In these situations, GHC/GHCi is smart enough to know where those types live, so it tells you; but since they're not in the current namespace you have no way of referring to them yourself. The solution is just to import Math.FFT.Base (or any other module that re-exports FFTWReal). -- Live well, ~wren
participants (4)
-
briand@aracnet.com
-
Ivan Lazar Miljenovic
-
KC
-
wren ng thornton