Given the following types:
type A = Ann ()
type Exp = ExpA ()
type ExpA a = Ann a (IExpA a)
type IExp = IExpA ()
type OptionalExpA a = Ann a (Maybe (IExpA a))
type OptionalExp = OptionalExpA ()
r :: [a] -> [a]
r = reverse
argStmt :: (HasPositions b, HappyStatement s)
=> Token
-> b
-> [A (Maybe IExp)]
-> ArgSpec
-> ([Arg] -> s)
-> P Stmt
I am getting an error message:
/home/ppelleti/prg/hs/language-intybasic/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/Language/IntyBasic/HappyParser.hs:514:44: error:
ā¢ Couldn't match type āAnn () (IExpA ())ā with āIExpA ()ā
Expected type: [A (Maybe IExp)]
Actual type: [OptionalExp]
ā¢ In the third argument of āargStmtā, namely ā(r happy_var_2)ā
In the expression:
(argStmt
happy_var_1 happy_var_2 (r happy_var_2) borderArgs SBorder)
In a case alternative:
(HappyWrap13 happy_var_2)
-> (argStmt
happy_var_1 happy_var_2 (r happy_var_2) borderArgs SBorder)
|
514 | ( argStmt happy_var_1 happy_var_2 (r happy_var_2) borderArgs SBorder)}})
| ^^^^^^^^^^^^^
However, if I simply change:
type OptionalExp = OptionalExpA ()
to:
type OptionalExp = A (Maybe IExp)
then my program compiles without error.
Why is there a difference between OptionalExpA ()
and A (Maybe IExp)
, given that both ought to expand to Ann () (Maybe (IExpA ())
?
Iām using LTS-18.22. (Therefore, GHC 8.10.7.)