On Sun, 2008-05-04 at 23:58 -0400, Brandon S. Allbery KF8NH wrote: > On 2008 May 4, at 23:40, Ross Boylan wrote: > > > ERROR "grammar.hsl":21 - Type error in explicitly typed binding > > *** Term : envEnd > > *** Type : String -> GenParser Char a [Char] > > *** Does not match : String -> Parser () > > Hugs is prone to error messages that obscure the problem. The trick > here is to realize that the type "Parser ()" is the same as "GenParser > Char a ()"; this then tells you that you have used a function that > returns a [Char] (aka String) where a type () (Haskell's version of > (void)) is expected. > > > envEnd :: String -> Parser () > > envEnd name = do{ reserved "\\end" > > ; braces (string name) > > } > > > Line 21 is "; braces (string name)"; it is producing a String, when > you need a (). One fix is to add one more line: > > > envEnd :: String -> Parser () > > envEnd name = do reserved "\\end" > > braces (string name) > > return () > > Another possible fix is to change the type of "envEnd" to "String -> > Parser String"; this may depend on how it's used.
First, I'm really impressed with the fast and helpful responses from several people! So the example is wrong? What inference should I draw about the state of Parsec and its documentation? I was thinking of trying Frost et al's X-SAIGA, but that the better documentation for parsec would be a plus. I had thought HUGS made more sense for fiddling around, but it seems all I'm doing is loading files anyway. What is the style people use for this exploratory work? I've already installed haskell-mode for emacs and ghc6, but it's not clear to me to what extent the former servers as a development environment rather than just a language formatter. Thanks. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe