1 Replies - 679 Views - Last Post: 06 September 2016 - 03:02 AM

#1 O'Niel  Icon User is offline

  • D.I.C Regular

Reputation: 14
  • View blog
  • Posts: 378
  • Joined: 13-September 15

Data constructor not in scope

Posted 06 September 2016 - 01:05 AM

Hi

I tried to make a data-typea and to print it out. I get this error:
haskell.hs:4:23: error: Data constructor not in scope: Days :: [a0]



Code:
data Days = Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday deriving(Eq, Ord, Show, Read, Bounded, Enum)

main =
    putStrLn $ show $ Days !! 1




I'm reading a book about Haskell, and they gave this in an example.
Why ain't this working? I derived classes.

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Data constructor not in scope

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2507
  • View blog
  • Posts: 3,961
  • Joined: 21-June 11

Re: Data constructor not in scope

Posted 06 September 2016 - 03:02 AM

It's a type, not a value. It's certainly no list. If you want a list of days, you can use the derived Enum instance and define allDays = [Monday .. Sunday].
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1