Re: [Haskell-cafe] Parsec bug, or...?

2009-10-20 Thread S . Doaitse Swierstra
After some private exchange of info between Uwe and me it became clear that it may not have been immediately clear that the error messages in my original posting where actually part of a more involved process. By removing the optional part in the pCommand (i.e. making the part starting

Re: [Haskell-cafe] Parsec bug, or...?

2009-10-15 Thread wren ng thornton
Uwe Hollerbach wrote: Yes, I've looked at that and am thinking about it. I'm not quite certain it's needed in my real program... I seem to have convinced myself that if I actually specify a proper set of unique prefixes, ie, set the required lengths for both frito and fromage to 3 in the test

Re: [Haskell-cafe] Parsec bug, or...?

2009-10-15 Thread Uwe Hollerbach
Hi, all, thanks for the further inputs, all good stuff to think about... although it's going to be a little while before I can appreciate the inner beauty of Doaitse's version! :-) I had considered the approach of doing a post-parsec verification, but decided I wanted to keep it all inside the

Re: [Haskell-cafe] Parsec bug, or...?

2009-10-15 Thread S. Doaitse Swierstra
On 15 okt 2009, at 16:58, Uwe Hollerbach wrote: Hi, all, thanks for the further inputs, all good stuff to think about... although it's going to be a little while before I can appreciate the inner beauty of Doaitse's version! :-) The nice thing is that you do not have to understand the inner

Re: [Haskell-cafe] Parsec bug, or...?

2009-10-14 Thread S. Doaitse Swierstra
I could not resist this. The code import Text.ParserCombinators.UU.Parsing pCommand [] = pure [] pCommand xxs@(x:xs) = ((:) $ pSym x * pCommand xs) `opt` xxs pCommands = amb . foldr (|) pFail . map pCommand $ [banana, chocolate, frito, fromage] t :: String - ([String], [Error Char Char

Re: [Haskell-cafe] Parsec bug, or...?

2009-10-13 Thread Martijn van Steenbergen
Brandon S. Allbery KF8NH wrote: My fix would be to have myPrefixOf require the prefix be terminated in whatever way is appropriate (end of input, white space, operator?) instead of simply accepting as soon as it gets a prefix match regardless of what follows. Maybe you can use notFollowedBy

Re: [Haskell-cafe] Parsec bug, or...?

2009-10-13 Thread Uwe Hollerbach
On 10/12/09, Martijn van Steenbergen mart...@van.steenbergen.nl wrote: Brandon S. Allbery KF8NH wrote: My fix would be to have myPrefixOf require the prefix be terminated in whatever way is appropriate (end of input, white space, operator?) instead of simply accepting as soon as it gets a

[Haskell-cafe] Parsec bug, or...?

2009-10-12 Thread Uwe Hollerbach
a brain fart? Hi, cafe, I've been playing a little bit with a small command processor, and I decided it'd be nice to allow the user to not have to enter a complete command, but to recognize a unique prefix of it. So I started with the list of allowed commands, used filter and isPrefixOf, and was

Re: [Haskell-cafe] Parsec bug, or...?

2009-10-12 Thread Brandon S. Allbery KF8NH
On Oct 12, 2009, at 22:28 , Uwe Hollerbach wrote: parsePrefixOf n str = string (take n str) opts (drop n str) return str where opts [] = return () opts (c:cs) = optional (char c opts cs) Seems to me this will succeed as soon as it possibly can... myTest = myPrefixOf 1 banana

Re: [Haskell-cafe] Parsec bug, or...?

2009-10-12 Thread Uwe Hollerbach
On 10/12/09, Derek Elkins derek.a.elk...@gmail.com wrote: On Mon, Oct 12, 2009 at 9:28 PM, Uwe Hollerbach uhollerb...@gmail.com wrote: a brain fart? Hi, cafe, I've been playing a little bit with a small command processor, and I decided it'd be nice to allow the user to not have to enter a