Greetings, I am new to Haskell and I've gotten stuck in defining a datatype for an assignment.
I need to create the "Strategy" type, it's basically a string with 1-6 characters each representing a numeric value, and I must represent values greater than 9 as a letter (up to 35 total different values), I tried defining an auxiliary type representing each possible value and using that to create my type, but my code isn't working and I have ran out of ideas. This is the definition I have been trying:
data Value = '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'A' | 'B' |
'C' | 'D' | 'E' | 'F' | 'G' | 'I' |'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' |
'Q' |'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'Y' | 'X' | 'Z'
data Strategy = Value | Value:Value | Value:Value:Value |
Value:Value:Value:Value | Value:Value:Value:Value:Value |
Value:Value:Value:Value:Value:Value
The Value type isn't accepting the numbers, and the Strategy type "sort of" works up to the second constructor after which it goes bust. Thanks for your help!
data IOMode = ReadMode | WriteMode | AppendMode | ReadWriteMode. Seems like you do know a bit about datatypes?