Hi Michel
I think you are reading empty string inside index function. I figured out little bit and some where you are reading empty string but could not concentrate enough ( or expert enough :) ) to see more because you are parsing you code based on counting the number of characters ( take 6 inside index function ).
*Main> read ""::Int
*** Exception: Prelude.read: no parse
Except the first test case, I changed the space between 0 and 2 ( for last test case, I reduced the space between 0 and 4 ) to seven and now it's not parsing completely but there is no error.
I have posted the code on ideone[1]. Here is the output on my system. I have also attached the code.
*Main> :load "/Users/mukeshtiwari/Programming/Haskell/ParsingAtto.hs"
[1 of 1] Compiling Main ( /Users/mukeshtiwari/Programming/Haskell/ParsingAtto.hs, interpreted )
Ok, modules loaded: Main.
*Main> test1
Done "\n" [(1,IndexedFaceTriangle 10 1 9),(2,IndexedFaceTriangle 1 2 9)]
*Main> test2
Done " 12 8 1 0\n" [[(1,IndexedFaceTriangle 10 1 9),(2,IndexedFaceTriangle 1 2 9),(11,IndexedFaceQuad 9 2 0 4)]]
*Main> test3
Done " 12 8 1 0\n" [[(1,IndexedFaceTriangle 10 1 9),(2,IndexedFaceTriangle 1 2 9),(11,IndexedFaceQuad 9 2 0 4)]]
*Main> test4
Done " 12 8 1 0\n" [[(1,IndexedFaceTriangle 10 1 9),(2,IndexedFaceTriangle 1 2 9),(11,IndexedFaceQuad 9 2 0 4)]]
*Main> test5
Done " 12 8 1 0\n" [[(1,IndexedFaceTriangle 10 1 9),(2,IndexedFaceTriangle 1 2 9),(11,IndexedFaceQuad 9 2 0 4)]]
[1]
http://ideone.com/x75C3j