Haskell Alex - error in wrapper template

六月ゝ 毕业季﹏ 提交于 2019-12-04 06:42:13

This looks like a bug in Alex 3.0.1. It works fine in version 2.3.3 after dealing with some other unrelated issues in your code1. The problem is this line in the generated code:

ignorePendingBytes (p,c,ps,s) = (p,c,s)

By following the types in the generated code, it seems like this function should have the type AlexInput -> AlexInput, but AlexInput obviously can't be both a 3-tuple and a 4-tuple.

This likely occurred 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 tell, the correct code should be

ignorePendingBytes (p,c,ps,s) = (p,c,[],s)

and manually making this change in the generated code makes it compile after dealing with the other issues.

However, unless you need something from 3.0.1, I suggest downgrading until this is fixed, as having to maintain patches against generated code is usually more trouble than it's worth.

1 Your code is missing a Show instance for Lexeme and you're also calling return on alexMonadScan, which is already in the Alex monad.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!