在(香草)GHCi 8.6.5 中,以下功能完全有效:
f xs@ ~(x:xt) = xs
Run Code Online (Sandbox Code Playgroud)
如果我现在在 9.0.1 中执行相同操作,则会出现错误
Suffix occurrence of @. For an as-pattern, remove the leading whitespace.
Run Code Online (Sandbox Code Playgroud)
仅删除@和之间的空白~似乎还不够,因为那样@~会被解释为运算符,所以我发现的唯一有效变体是
f xs@(~(x:xt)) = xs
Run Code Online (Sandbox Code Playgroud)
我想知道以下内容,但在更改说明中找不到答案:
xs@(~(x:xt))真的写这种模式的最好方法,还是有超过这个优选的方法是什么?