types - Defining a datatype in Haskell -


greetings, new haskell , i've gotten stuck in defining datatype assignment.

i need create "strategy" type, it's string 1-6 characters each representing numeric value, , must represent values greater 9 letter (up 35 total different values), tried defining auxiliary type representing each possible value , using create type, code isn't working , have ran out of ideas. definition 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 numbers, , strategy type "sort of" works second constructor after goes bust. help!

just previous (deleted) question, looks lot homework. helps if pick real name , not use throw-away account.

this page tells how use haskell's data type declarations. doing different/wrong?

  1. you use characters instead of constructors value. '1' '2', etc characters, need constructor along 0 or more fields valuecon1 char , valuecon2 string

  2. you using list constructors , assume field of value instead of defining new constructors strategy. perhaps want data strategy = strat [value], accept list of size. while more painful can define many many strategy constructors finite number of separate value fields.

btw - course taught? seems late in term covering these basics.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -