4

I have noticed the frequent appearance of two consecutive apostrophes in Haskell code.

Like this:

newtype Date = Date Integer
data EndDate = Fixed Integer | Never
unstableMakeIsData ''Date
unstableMakeIsData ''EndDate

What does '' mean in haskell?

3

The apostrophe(s) in Haskell (and thus Plutus) are part of the name; they do not hold any specific meaning.

Haskell as a functional programming language borrows from mathematical notation. An apostrophe on a variable name conveys that it is somewhat related to another variable (without or with more apostrophes).

Imagine a simple function that adds three values. You could write these several ways.

addThreeNumbers a b c = a + b + c
addThreeNumbers' a b c = b + c + a
addThreeNumbers'' a b c = b + a + c
addThreeNumbers''' a b c = c + a + b

and so on. The result will always be the same.


The apostrophes in your example are, however, not of the same type as the prefix data types. This is an indicator that template haskell is being used.

4
  • but in my case, unstableMakeIsData is a function name and ''Date is not defined before. The apostrophe(s) is a prefix not suffix, I think It might be different.
    – mackie
    Jun 8 at 3:13
  • I found your example in this commit: github.com/input-output-hk/plutus/commit/… -- take a look at the Instances.hs
    – Matthias Sieber
    Jun 8 at 5:28
  • I apologize for the confusion. The apostrophes in front of the type hint at template haskell
    – Matthias Sieber
    Jun 8 at 5:31
  • Thank you a lot!
    – Java
    Jun 27 at 15:44

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .