2

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?

2
  • You know that DFS doesn't require mutable state, right? Your first sentence implies otherwise. Commented May 2, 2011 at 17:01
  • @TomMD I just read a paper and want to implement his idea. Commented May 3, 2011 at 0:33

1 Answer 1

6

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Sorry, I made a mistake in the question. In my code, it's thenST. So the problem has nothing related with backticks
@machinarium: then I can't help you any further. GHCi 6.12.1 loads the code you posted just fine when I insert backticks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.