[Haskell-cafe] (!!) operator usage

Neil Rutland neilrutland2 at hotmail.com
Fri Mar 24 17:29:42 EST 2006


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




More information about the Haskell-Cafe mailing list