What will be the impacts if Haskell uses "!" instead of keyword "not" as the operator of logical not? [closed]

I'm a new Haskell learner. I do not know much about the syntax mechanism behind Haskell.

In some imperative programming languages, such as C/Java, the exclamation point "!" is used as logic not.

Meanwhile, Haskell use keyword "not" as "logical not". However, Haskell use "&&" and "||" as logical operators.

Obviously, Haskell avoids using "!" to express concepts of "not", e.g. "not equal" is "/=" but not "!=".

In another point of view, I guess, if the keyword "module" is changed to "package", nothing serious will happen except altering all "module" with "package" in all existing codes.

I wonder, if one changes the keyword "not" to "!" in Haskell, what will happen?

Complements:

  1. As pointed by @chi, i made a mistake. "not" is not a keyword, it is a library function.
  2. As pointed by @user202729, i did not tell my question clearly. I am wondering what will happen when "not" is replaced by "!". That is to say, when the founders design Haskell and they use "!" to work as logical not, MAYBE "!" cannot be used as array indexing. Then the founders try another way to index an element in array (with []? i don't know). Then something like chain-reacting goes on. Does this change Haskell much?
6

2 Answers

You can even try this if you are satisfied with a postfix operator, but this requires the use of the PostfixOperators language extension

{-# LANGUAGE PostfixOperators #-} (!) = not main = print (True !) -- False 

I find this to be quite reasonable, not.

2

Haskell does not have unary prefix operators, so you cannot define it as a library function like all the other operators.

The only exception to this is unary minus, which is a specific lexical hack to get around the fact that people expect to be able to write e.g.

x = (-y) * 5 

However this has the disadvantage that while (*5) is a "section" (i.e. a binary operator given one argument and returning a function that expects the other), (-y) is not a section, it is the negation of y.

So if you want to multiply all the members of a list by 5, you can do it like this

xs = map (*5) ys 

But if you want to subtract 5 from all the members of a list, this doesn't work:

xs = map (-5) ys 

Instead you have to write

xs = map (subtract 5) ys 
4

You Might Also Like