[Haskell-cafe] why doesn't ghc give you a type signature that works ?

wren ng thornton wren at freegeek.org
Wed May 18 07:41:05 CEST 2011


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,<briand at aracnet.com>  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



More information about the Haskell-Cafe mailing list