
Hi there, I hope i have sent this in the right format - i gather i may have been rude by sending it incorrectly - if this is still wrong give me a shout. Anyway today i am enquiring about how to use the !! operator - i have looked at Zvons Haskell refeernce and it says that it takes a list( like newLine below) and an Integer for the location of the item you wish to return. Basically in this example i would like to return the value 4 type Bob = [(Int, Int)] newLine :: Bob newLine = [(1,4)] i have tried to use the follwing but it returns the error below it. newLine !! 0 - (so that should give it the newLine list and try and return the 1st element of the list) the error reads thus ERROR file:.\VicotriaLine.txt:107 - Type error in final generator *** Term : newLine !! 0 *** Type : (Int,Int) *** Does not match : IO a Could someone please try and tell me what thats all about because i can't see what i am doing wrong based on the examples i have found from the website i detailed about. Cheers everyone Neil

Neil Rutland
type Bob = [(Int, Int)] newLine :: Bob newLine = [(1,4)]
i have tried to use the follwing but it returns the error below it.
newLine !! 0 - (so that should give it the newLine list and try and return the 1st element of the list)
the error reads thus
ERROR file:.\VicotriaLine.txt:107 - Type error in final generator *** Term : newLine !! 0 *** Type : (Int,Int) *** Does not match : IO a
newLine is already defined -- call it 'x' instead and !! will do what you expect. Tom

Tom Davies

Neil,
Basically in this example i would like to return the value 4
type Bob = [(Int, Int)] newLine :: Bob newLine = [(1,4)]
i have tried to use the follwing but it returns the error below it.
newLine !! 0 - (so that should give it the newLine list and try and return the 1st element of the list)
the error reads thus
ERROR file:.\VicotriaLine.txt:107 - Type error in final generator *** Term : newLine !! 0 *** Type : (Int,Int) *** Does not match : IO a
Instruct the interpreter to print it: print (snd (newLine !! 0)) HTH, Stefan
participants (3)
-
Neil Rutland
-
Stefan Holdermans
-
Tom Davies