Reputation: 553
I have been stuck with a particular situation. I am not sure what the error even is to be honest.
data Stream a = Cons a (Stream a)
streamToList :: Stream a -> [a]
streamToList (Cons x (Stream xs)) = x: streamToList (Stream xs)
Doing something like this, I got Not in scope : data constructor 'Stream', so I googled the error and some solutions were to change stream to a lower case
data Stream a = Cons a (Stream a)
streamToList :: Stream a -> [a]
streamToList (Cons x xs) = x: streamToList (stream xs)
But then I get Parse error in pattern : stream
I tried importing Data.Stream (googled on Hoogle) but Could not find module 'Data.Stream'
Currently using Haskell from Ubuntu packages
Upvotes: 1
Views: 66
Reputation: 205024
streamToList :: Stream a -> [a]
streamToList (Cons x xs) = x : streamToList xs
Stream
is the name of a type, so it can be used on the right-hand side of ::
. But it is not a data constructor, so it cannot be used as a value or in pattern matches.
Cons
is the name of a data constructor, so it can be used as a value or in pattern matches. But it is not a type.
Upvotes: 1