0
votes

I'm trying to use the Stream type defined in this package. After installing with with cabal, I tried defining the tail function on streams as a quick test :

import Stream  

tail' :: Stream a -> Stream a
tail' (Cons x s) = s

which gives me this error message :

test.hs:3:14: error:
    Not in scope: type constructor or class `Stream'
    Perhaps you meant `StreamT' (imported from Stream)

test.hs:3:26: error:
    Not in scope: type constructor or class `Stream'
    Perhaps you meant `StreamT' (imported from Stream)

test.hs:4:12: error: Not in scope: data constructor `Cons'
Failed, modules loaded: none.

after some searches, I thought the problem might be that importing the module does not automatically import the type constructor Stream and constructor Cons with it. So I changed it to

import Stream (Stream, Cons)

tail' :: Stream a -> Stream a
tail' (Cons x s) = s

after which I get

test.hs:1:20: error: Module `Stream' does not export `Stream'

test.hs:1:28: error: Module `Stream' does not export `Cons'
Failed, modules loaded: none.

and this is puzzling. Do I have to alter the installed package and add Stream and Cons to its export list? Or am I not importing the module correctly?

1
The package you link only has Data.Stream. You must be importing something else. - András Kovács

1 Answers

1
votes

You are importing the wrong module; looking at the top of your link, the module name is Data.Stream. (Stream is the name of the package -- it names a collection of modules to be installed.) So things should work better if you write

import Data.Stream

tail' :: Stream a -> Stream a
tail' (Cons x s) = s

The fact that the incantation import Stream worked at all indicates to me that you have another package installed that provides this module, though I'm not sure which.