Haskell - Types, Enums, and Functions -


good morning everyone,

here's i'm working on today, , issue i'm running in to:

--a data row = | b | c | d | e | f | g | h | | j deriving (enum, ord, show, bounded, eq, read) data column = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ten  deriving (enum, ord, show, bounded, eq, read) --b data address = address row column deriving (show, read, eq) 

then few lines later problem child:

toaddress r c = address(toenum r, toenum c) 

i need feed address row , column, need turn r , c row , column (not ints)

obviously toaddress not structured correctly carry out task. requirement follows:

write function toaddress takes in row , column, each in [0 − 9]. construct address , return it. use toenum index row , column enums lists.

does have suggestions on how accomplish i'm going here?

thank you!

you got syntax wrong.

a function application of function f :: -> b -> c in haskell looks f b , not f(a,b). f(a,b) still correct syntax not want: passes 1 parameter function (i.e. tuple consisting of , b).

so correct implementation of toaddress looks this:

toaddress r c = address (toenum r) (toenum c) 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -