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.

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon university    KF8NH


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to