This seems like a bug in Alex 3.0.1. It works great in version 2.3.3 after addressing some other unrelated issues in code 1 . The problem is this line in the generated code:
ignorePendingBytes (p,c,ps,s) = (p,c,s)
Following the types in the generated code, it seems that this function should be of type AlexInput -> AlexInput
, but AlexInput
, obviously, cannot be either a 3-tuple or a 4-tuple.
This probably happened because the definition of AlexInput
was changed between the two versions.
type AlexInput = (AlexPosn, Char, String) -- v2.3.3 type AlexInput = (AlexPosn, Char, [Byte], String) -- v3.0.1
From what I can say, the correct code should be
ignorePendingBytes (p,c,ps,s) = (p,c,[],s)
and manually making this change to the generated code makes it compile after solving other problems.
However, if you do not need something from 3.0.1, I suggest lowering it until it is fixed, since the availability of corrections from the generated code is usually more of a problem than it costs.
1 There is no Show
instance for Lexeme
in your code, and you also call return
on alexMonadScan
, which is already in the monad Alex
.sub>