Created
April 10, 2018 09:42
-
-
Save m0ar/c08547d2b7f75794c1eab6d4ddada5a4 to your computer and use it in GitHub Desktop.
I want to do some kind of book-keeping in sequence after ams does its, but I cannot grasp the error.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
qual :: { LStmt GhcPs (LHsExpr GhcPs) } | |
: bindpat '<-' exp maybeweight {% (ams (sLL $1 $> $ mkBindStmt $1 $3) | |
[mu AnnLarrow $2]) >>= aw $4 } | |
-- ^ Would like to apply the returned value from ams (sLL $1 $> [...]) to aw (see below) | |
-- Fails with error (see below) | |
| exp maybeweight {% aw $2 (sL1 $1 $ mkBodyStmt $1) | |
-- ^ This is fine! | |
-- aw adds the found weight to the parser state, same style as ams | |
aw :: Maybe Weight -> Located a -> P (Located a) | |
aw Nothing a = return a | |
aw (Just w) a@(L l _) = addWeightAt l w >> return a | |
-- ams implementations for reference: | |
ams :: Located a -> [AddAnn] -> P (Located a) | |
ams a@(L l _) bs = addAnnsAt l bs >> return a | |
-- Some types | |
sLL :: Located a -> Located b -> c -> Located | |
mkBindStmt :: LPat idL -> Located (bodyR idR) -> StmtLR idL idR (Located (bodyR idR)) | |
{- row 2 of qual fails compilation with the following error: | |
compiler/stage1/build/Parser.hs:9908:33: error: | |
• Couldn't match type ‘Maybe Weight’ with ‘GenLocated SrcSpan b0’ | |
Expected type: Located b0 | |
Actual type: Maybe Weight | |
• In the second argument of ‘sLL’, namely ‘happy_var_4’ | |
In the expression: sLL happy_var_1 happy_var_4 | |
In the first argument of ‘ams’, namely | |
‘(sLL happy_var_1 happy_var_4 | |
$ mkBindStmt happy_var_1 happy_var_3)’ | |
| | |
9908 | ( (ams (sLL happy_var_1 happy_var_4 $ mkBindStmt happy_var_1 happy_var_3) | |
| ^^^^^^^^^^^ | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment