Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Haskell allow use of keywords in identifiers?

C# allows it if you put an @ before the variable name. So int @int = 0; is valid in C#.

Does Haskell have anything similar to this or it doesn't allow it altogether?

Thanks

like image 935
strider Avatar asked Feb 27 '11 06:02

strider


2 Answers

Some words are keywords in some contexts but can be freely used as identifiers in others, such as as and hiding.

The C# trick is nothing but just slightly changing the name so that is it no longer a keyword. In Haskell, you could put a _ before or after the name, or append a '.

like image 54
Martijn Avatar answered Oct 02 '22 03:10

Martijn


It appears that it is not allowed. Note that you can usually put ' after a keyword (since that is a valid identifier character) and get a non-keyword.

like image 27
Jeremiah Willcock Avatar answered Oct 02 '22 03:10

Jeremiah Willcock