I'm writing a parser for a language in Haskell with Alex + Happy.
What I want to do is: in Alex, skip whitespaces and newlines, but keep them as state, and then emit tokens which contain the newlines and the indent before the token.
I guess I could emit extra tokens for indent and newlines, and then collapse them later, but I'd prefer a cleaner approach.
Is there any way to wrap the token processing in alex in a monad that carries the indent/newline information and is accesible inside the actions that emit tokens?