
Hi, the following code goes through parsec-2 (and parsec1) but is rejected by parsec-3 import Text.ParserCombinators.Parsec gqrrel = many1 (alphaNum <|> char '_') myparser = sepBy gqrrel (char ',') The error message is: No instance for (parsec-3.1.1:Text.Parsec.Prim.Stream s m Char) arising from a use of `char' at P3.hs:3:25-32 Possible fix: add an instance declaration for (parsec-3.1.1:Text.Parsec.Prim.Stream s m Char) In the second argument of `sepBy', namely `(char ',')' In the expression: sepBy gqrrel (char ',') In the definition of `myparser': myparser = sepBy gqrrel (char ',') Please review your decision to put parsec-3 into the HP. Cheers Christian

On Fri, Feb 18, 2011 at 7:27 AM, Christian Maeder
Hi,
the following code goes through parsec-2 (and parsec1) but is rejected by parsec-3
import Text.ParserCombinators.Parsec
gqrrel = many1 (alphaNum <|> char '_') myparser = sepBy gqrrel (char ',')
With top level type annotations, it compiles just fine. These annotations are considered a best practice, their absence is even complained about with -Wall, and the extra utility of parsec-3 far outweighs their cost, IMHO. gqrrel :: Parser String gqrrel = many1 (alphaNum <|> char '_') myparser :: Parser [String] myparser = sepBy gqrrel (char ',') The problem is that the Stream class is an MPTC deliberately crafted without a fundep between the stream type and the monad in question. Any fix is likely to be worse than the disease, since to make type inference work for all scenarios that it works in Parsec-2, you'd need the fundeps for the stream class to be able to infer the other 2 arguments given any one of them. You'd lose the stream instances for lists, bytestring, etc. that work for all monads rather than just Identity. I still remain enthusiastic about the prospect of including parsec-3 in the platform. -Edward Kmett

I'm only unhappy about the compatibility layer that now turns out to be not 100% compatible. Therefore I've created a light-weight parsec1 because parsec-3 is overkill for many cases. It seems that I have to rename the modules in parsec1 to avoid overlapping module names with parsec-3, unless parsec-3 drops the compatibility layer (as I have done in parsec3) before it goes into the platform, because dropping it later is much more difficult. Christian Am 18.02.2011 14:01, schrieb Edward Kmett:
On Fri, Feb 18, 2011 at 7:27 AM, Christian Maeder
mailto:Christian.Maeder@dfki.de> wrote: Hi,
the following code goes through parsec-2 (and parsec1) but is rejected by parsec-3
import Text.ParserCombinators.Parsec gqrrel = many1 (alphaNum <|> char '_') myparser = sepBy gqrrel (char ',')
With top level type annotations, it compiles just fine. These annotations are considered a best practice, their absence is even complained about with -Wall, and the extra utility of parsec-3 far outweighs their cost, IMHO.
gqrrel :: Parser String gqrrel = many1 (alphaNum <|> char '_')
myparser :: Parser [String] myparser = sepBy gqrrel (char ',')
The problem is that the Stream class is an MPTC deliberately crafted without a fundep between the stream type and the monad in question. Any fix is likely to be worse than the disease, since to make type inference work for all scenarios that it works in Parsec-2, you'd need the fundeps for the stream class to be able to infer the other 2 arguments given any one of them. You'd lose the stream instances for lists, bytestring, etc. that work for all monads rather than just Identity.
I still remain enthusiastic about the prospect of including parsec-3 in the platform.
-Edward Kmett
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

On Fri, Feb 18, 2011 at 9:43 AM, Christian Maeder
I'm only unhappy about the compatibility layer that now turns out to be not 100% compatible. Therefore I've created a light-weight parsec1 because parsec-3 is overkill for many cases.
It seems that I have to rename the modules in parsec1 to avoid overlapping module names with parsec-3, unless parsec-3 drops the compatibility layer (as I have done in parsec3) before it goes into the platform, because dropping it later is much more difficult.
The compatibility layer wasn't intended to be 100% compatible. It was intended that it would be compatible enough that existing libraries on Hackage wouldn't break. The type signature requirement is certainly a weakness - it could probably be fixed by introducing a new parser type for the compatibility layer. I don't have my utility scripts around that found packages on Hackage which did not specify a 'parsec' upper bound, so I do not know the current count of what would break if we removed the compatibility layer. But even if Hackage compiled cleanly with the changes, there is also the cost of causing tutorials and other references to become outdated, and the breaking of non-public code. So to me it seems there are a few choices: 1. Improve the compatibility layer (with a cost of new types and many, uninteresting, wrappers and the cost of more maintenance) 2. Drop the compatibility layer (with the cost of updating version restrictions across Hackage and the cost of non-Hackage breakage and confusion) 3. Do nothing. I'm leaning towards 1 & 3, but I also know that I have a fairly strong bias towards not breaking working libraries. So I may be being overly cautious. Antoine
Christian
Am 18.02.2011 14:01, schrieb Edward Kmett:
On Fri, Feb 18, 2011 at 7:27 AM, Christian Maeder
mailto:Christian.Maeder@dfki.de> wrote: Hi,
the following code goes through parsec-2 (and parsec1) but is rejected by parsec-3
import Text.ParserCombinators.Parsec gqrrel = many1 (alphaNum <|> char '_') myparser = sepBy gqrrel (char ',')
With top level type annotations, it compiles just fine. These annotations are considered a best practice, their absence is even complained about with -Wall, and the extra utility of parsec-3 far outweighs their cost, IMHO.
gqrrel :: Parser String gqrrel = many1 (alphaNum <|> char '_')
myparser :: Parser [String] myparser = sepBy gqrrel (char ',')
The problem is that the Stream class is an MPTC deliberately crafted without a fundep between the stream type and the monad in question. Any fix is likely to be worse than the disease, since to make type inference work for all scenarios that it works in Parsec-2, you'd need the fundeps for the stream class to be able to infer the other 2 arguments given any one of them. You'd lose the stream instances for lists, bytestring, etc. that work for all monads rather than just Identity.
I still remain enthusiastic about the prospect of including parsec-3 in the platform.
-Edward Kmett
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

On Fri, Feb 18, 2011 at 11:13 AM, Antoine Latter
On Fri, Feb 18, 2011 at 9:43 AM, Christian Maeder
wrote: I'm only unhappy about the compatibility layer that now turns out to be not 100% compatible. Therefore I've created a light-weight parsec1 because parsec-3 is overkill for many cases.
It seems that I have to rename the modules in parsec1 to avoid overlapping module names with parsec-3, unless parsec-3 drops the compatibility layer (as I have done in parsec3) before it goes into the platform, because dropping it later is much more difficult.
The compatibility layer wasn't intended to be 100% compatible. It was intended that it would be compatible enough that existing libraries on Hackage wouldn't break.
The type signature requirement is certainly a weakness - it could probably be fixed by introducing a new parser type for the compatibility layer.
I don't have my utility scripts around that found packages on Hackage which did not specify a 'parsec' upper bound, so I do not know the current count of what would break if we removed the compatibility layer.
But even if Hackage compiled cleanly with the changes, there is also the cost of causing tutorials and other references to become outdated, and the breaking of non-public code.
So to me it seems there are a few choices:
1. Improve the compatibility layer (with a cost of new types and many, uninteresting, wrappers and the cost of more maintenance)
2. Drop the compatibility layer (with the cost of updating version restrictions across Hackage and the cost of non-Hackage breakage and confusion)
3. Do nothing.
I'm leaning towards 1 & 3, but I also know that I have a fairly strong bias towards not breaking working libraries. So I may be being overly cautious.
Just to be clear, this issue was known when the compatibility layer was first made and option 3 was chosen for exactly the reasons Edward mentioned. As far as choosing option 2, this isn't a compelling reason to choose it, which is not to say there might not be other reasons to choose it.

* Christian Maeder
Hi,
the following code goes through parsec-2 (and parsec1) but is rejected by parsec-3
import Text.ParserCombinators.Parsec gqrrel = many1 (alphaNum <|> char '_') myparser = sepBy gqrrel (char ',')
The error message is:
No instance for (parsec-3.1.1:Text.Parsec.Prim.Stream s m Char) arising from a use of `char' at P3.hs:3:25-32 Possible fix: add an instance declaration for (parsec-3.1.1:Text.Parsec.Prim.Stream s m Char) In the second argument of `sepBy', namely `(char ',')' In the expression: sepBy gqrrel (char ',') In the definition of `myparser': myparser = sepBy gqrrel (char ',')
Works just fine here. % cat psc.hs import Text.ParserCombinators.Parsec gqrrel = many1 (alphaNum <|> char '_') myparser = sepBy gqrrel (char ',') % ghci -package parsec-3.1.0 psc.hs GHCi, version 6.12.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Loading package bytestring-0.9.1.5 ... linking ... done. Loading package mtl-1.1.0.2 ... linking ... done. Loading package syb-0.1.0.2 ... linking ... done. Loading package parsec-3.1.0 ... linking ... done. [1 of 1] Compiling Main ( psc.hs, interpreted ) Ok, modules loaded: Main. *Main> :t myparser myparser :: (Text.Parsec.Prim.Stream s m Char) => Text.Parsec.Prim.ParsecT s u m [[Char]] -- Roman I. Cheplyaka :: http://ro-che.info/ Don't worry what people think, they don't do it very often.

On 19 February 2011 09:27, Roman Cheplyaka
Works just fine here.
myparser = sepBy gqrrel (char ',')
myparser :: (Text.Parsec.Prim.Stream s m Char) => Text.Parsec.Prim.ParsecT s u m [[Char]]
Have you turned off the monomorphism restriction globally? I wouldn't have thought that myparser would get an overloaded type otherwise. Max

* Max Bolingbroke
On 19 February 2011 09:27, Roman Cheplyaka
wrote: Works just fine here.
myparser = sepBy gqrrel (char ',')
myparser :: (Text.Parsec.Prim.Stream s m Char) => Text.Parsec.Prim.ParsecT s u m [[Char]]
Have you turned off the monomorphism restriction globally? I wouldn't have thought that myparser would get an overloaded type otherwise.
Indeed, I have (in ~/.ghci). I suspected this is the reason, but: *Main> :set -XMonomorphismRestriction *Main> :r Ok, modules loaded: Main. Can you explain this? (Now I've checked that if I first launch ghci, then turn the MR on and load the file, the error appears.) -- Roman I. Cheplyaka :: http://ro-che.info/ Don't worry what people think, they don't do it very often.

On 19 February 2011 13:14, Roman Cheplyaka
Indeed, I have (in ~/.ghci). I suspected this is the reason, but:
*Main> :set -XMonomorphismRestriction *Main> :r Ok, modules loaded: Main.
Can you explain this?
(Now I've checked that if I first launch ghci, then turn the MR on and load the file, the error appears.)
I'm just speculating here, but could this be caused by the compilation manager not recompiling Main.hs because it notices that the file is unchanged? If you open it in GHCi, touch it and then do :set -XMonomorphismRestriction followed by :r, does it then give an error? If so, this would indicate that GHCi is avoiding reloading the file with the new dynflags. This is probably a known bug - Simon Marlow recently created a ticket about making ghc --make recompilation avoidance more respectful of flag changes. Cheers, Max

On Saturday 19 February 2011 13:55:42, Max Bolingbroke wrote:
On 19 February 2011 09:27, Roman Cheplyaka
wrote: Works just fine here.
myparser = sepBy gqrrel (char ',')
myparser :: (Text.Parsec.Prim.Stream s m Char) => Text.Parsec.Prim.ParsecT s u m [[Char]]
Have you turned off the monomorphism restriction globally?
Probably. Works here with MR off, doesn't compile with MR on (6.12.3 and 7.0.1)
I wouldn't have thought that myparser would get an overloaded type otherwise.
Max
participants (7)
-
Antoine Latter
-
Christian Maeder
-
Daniel Fischer
-
Derek Elkins
-
Edward Kmett
-
Max Bolingbroke
-
Roman Cheplyaka