开发者

Parse error in pattern in haskell

开发者 https://www.devze.com 2023-03-01 20:58 出处:网络
When implementing the DFS algorithm, I got to use the Imperative features. Here is the code type ST s a = s -> (a, s)

When implementing the DFS algorithm, I got to use the Imperative features. Here is the code

type ST s a = s -> (a, s)

returnST :: a -> ST s a
returnST a s = (a, s)

thenST :: ST s a -> (a -> ST s b) -> ST s b
(m 'thenST' k) s = k a t where (a, t) = m s

But the GHCi 6.12.3 give me a 'Parse error in pattern' in the last line of code. I get 开发者_如何学编程this piece of code from an paper. Is there any possibility that the complier used by the author of the paper got no strict grammar rules as now? And how to fix this error?


Change

'thenST'

to

`thenST`

The backticks turn an ordinary function name into an infix operator. They may have been turned into single quotes by an editor, word processor or document viewer.

0

精彩评论

暂无评论...
验证码 换一张
取 消