[Haskell-cafe] (!!) operator usage

Stefan Holdermans stefan at cs.uu.nl
Fri Mar 24 17:53:18 EST 2006


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


More information about the Haskell-Cafe mailing list