0

Possible Duplicate:
The meaning of ' in Haskell function name?
Apostrophe in identifiers in Haskell

I'm working my way though this and implementing it as best I can in Clojure. While I don't know any Gofer (or Haskell), I am figuring out enough as I go. However, I can't seem to find anywhere that explains what the single quotes and double single quotes after inp are supposed to function as.

seq :: Parser a -> Parser b -> Parser (a,b)
p `seq` q = \inp -> [((v,w),inp'') | (v,inp') <- p inp
     , (w,inp'') <- q inp']

Help would be much appreciated.

Community
  • 1
  • 1
pondermatic
  • 6,453
  • 10
  • 48
  • 63
  • 3
    They don't signify anything, they're part of the names. It's a common motif to name related entities similar, using apostrophes to distinguish them. `inp'` (spoken inp-prime) is the input left over after running the first parser on the original input, `inp''` the remaining input after running the second parser on what's left after the the first. Another way would be calling them `inp_1`, `inp_2` or something like that. – Daniel Fischer Jun 26 '12 at 01:54
  • Ahhh, thanks, no wonder I couldn't find them in a language reference :) – pondermatic Jun 26 '12 at 01:59
  • To quote the Haskell report: "An identifier consists of a letter followed by zero or more letters, digits, underscores, and single quotes." – augustss Jun 26 '12 at 11:00
  • Gofer! Wow, that takes me back. Last release 13 years ago, Gofer is a lovely implementation of Haskell 1.2, with support for some nice syntactic extensions. However, you should consider using [a modern Haskell](http://haskell.org/platform) – Don Stewart Jun 26 '12 at 12:19

1 Answers1

0

(Copied from Don's answer to a previous question)


The apostrophe is just part of the name. It is a naming convention (idiom) adopted in Haskell.

The convention in Haskell is that, like in math, the apostrophe on a variable name represents a variable that is somehow related, or similar, to a prior variable.

An example:

let x  = 1
    x' = x * 2
in x'

x' is related to x, and we indicate that with the apostrophe.

Chris Taylor
  • 46,912
  • 15
  • 110
  • 154