Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the semantic difference between "varid", "varsym" in Haskell Report?

Tags:

haskell

I am reading the Haskell report 2010 and has some questions with regarding to the meta-logical representation in section 2.4Here:

  1. In the mnemonics of "varid" and "varsym", does "var" mean variable?
  2. My understanding are that "varid" are identifiers for variables and functions, while "varsym" are identifiers also, but for operators. Is this understanding correct?
  3. If 1 and 2 are correct, does it mean operator is also a kind of variable? (I am very confused because this is likely not right.)

Appreciate any advice.

like image 215
modeller Avatar asked Sep 30 '22 01:09

modeller


1 Answers

As far as I can tell, the report is defining the difference between symbols that are used prefix, and those that are used infix, for example:

f x y -- f is used prefix

a / b -- / is used infix

This is just a syntactic convenience, as all prefix symbols can be used infix with backticks, and all infix symbols can be used prefix with ()s:

x `f` y -- infix

(/) a b -- prefix
(a /) b -- operator section
(/ b) a -- operator section

Sub-questions:

  1. yes, but I can't figure out any meaningful mnemonic for the id and sym parts. :(

  2. operators are in the realm of Haskell syntax, not its semantics. They're only used to provide a more convenient syntax for writing some expressions. As far as I know, if they were removed from Haskell, the only loss would be convenient syntax -- i.e. there's nothing that you need operators for, other than convenient syntax, and you can replace every single use of operators with non-operator symbols. They are completely identical to variables -- they are variables -- but require different syntax for their use.

  3. yes, I would agree that operator symbols are variables. However, the values bound to oerators symbols would not be variables.

like image 129
Matt Fenwick Avatar answered Nov 15 '22 09:11

Matt Fenwick