user3637052
user3637052

Reputation: 35

How to generate a list with own data type in haskell

I am trying to create an infinite list with my own data type in haskell

data Color = Black | White       deriving (Show, Eq)
data Cell  = Empty | Stone Color deriving (Show, Eq)

makeRow :: Int -> Row
makeRow 0 = []
makeRow n = take n (repeat Cell Empty)

And it gives me the error :

Data constructor not in scope: Cell

Upvotes: 1

Views: 489

Answers (1)

fdreger
fdreger

Reputation: 12505

You get this error because Cell is - indeed - not a value constructor. Just use plain Empty instead (note that you don't write Bool True or Bool False - you just write True or False).

Upvotes: 2

Related Questions