Skip to main content
edited body
Source Link
sepp2k
  • 4.3k
  • 1
  • 28
  • 25

If I understood your last comment correctly, your question is why Haskell often uses symbolic operators in places where it could as well use alphanumeric keywords (or function names)?

Regarding keywords one answer would be that keywords prevent you using certain words as variable names. For example I'm always annoyed when I want to call my variables from and to in a languages where one of those is a keywords - like in Python.

Another reason for symbolic operators in general is conciseness. That doesn't really apply in your specific examples of list comprehensions (<- isn't shorter than in), but in many cases it does.

Yet another reason is readability. That might seem counter-intuitive because symbolic operators are often harder to learn since their "names" don't really tell you anything about what they do (while a function's name usually will), but once you do know what a given operator does, expressions with infix symbolic operators are often easier to parse for a human than one with lots of alpha-numeric prefix function calls since the operators are more easily visually distinguished from the operands that way. For example most people would agree that 2 * 3 + 4 is more easily readable than add (mult 2 (add 3) 4) or add(mult(2, add(3), 4)).

If I understood your last comment correctly, your question is why Haskell often uses symbolic operators in places where it could as well use alphanumeric keywords (or function names)?

Regarding keywords one answer would be that keywords prevent you using certain words as variable names. For example I'm always annoyed when I want to call my variables from and to in a languages where one of those is a keywords - like in Python.

Another reason for symbolic operators in general is conciseness. That doesn't really apply in your specific examples of list comprehensions (<- isn't shorter than in), but in many cases it does.

Yet another reason is readability. That might seem counter-intuitive because symbolic operators are often harder to learn since their "names" don't really tell you anything about what they do (while a function's name usually will), but once you do know what a given operator does, expressions with infix symbolic operators are often easier to parse for a human than one with lots of alpha-numeric prefix function calls since the operators are more easily visually distinguished from the operands that way. For example most people would agree that 2 * 3 + 4 is more easily readable than mult 2 (add 3 4) or mult(2, add(3, 4)).

If I understood your last comment correctly, your question is why Haskell often uses symbolic operators in places where it could as well use alphanumeric keywords (or function names)?

Regarding keywords one answer would be that keywords prevent you using certain words as variable names. For example I'm always annoyed when I want to call my variables from and to in a languages where one of those is a keywords - like in Python.

Another reason for symbolic operators in general is conciseness. That doesn't really apply in your specific examples of list comprehensions (<- isn't shorter than in), but in many cases it does.

Yet another reason is readability. That might seem counter-intuitive because symbolic operators are often harder to learn since their "names" don't really tell you anything about what they do (while a function's name usually will), but once you do know what a given operator does, expressions with infix symbolic operators are often easier to parse for a human than one with lots of alpha-numeric prefix function calls since the operators are more easily visually distinguished from the operands that way. For example most people would agree that 2 * 3 + 4 is more easily readable than add (mult 2 3) 4 or add(mult(2, 3), 4).

added 1 characters in body
Source Link
sepp2k
  • 4.3k
  • 1
  • 28
  • 25

If I understood your laselast comment correctly, your question is why Haskell often uses symbolic operators in places where it could as well use alphanumeric keywords (or function names)?

Regarding keywords one answer would be that keywords prevent you using certain words as variable names. For example I'm always annoyed when I want to call my variables from and to in a languages where one of those is a keywords - like in Python.

Another reason for symbolic operators in general is concisenesconciseness. That doesn't really apply in your specific examples of list comprehensions (<- isn't shorter than in), but in many cases it does.

Yet another reason is readability. That might seem counter-intuitive because symbolic operators are often harder to learn since their "names" don't really tell you anything about what they do (while a function's name usually will), but once you do know what a given operator does, expressions with infix symbolic operators are often easier to parse for a human than one with lots of alpha-numeric prefix function calls since the operators are more easily visually distinguished from the operands that way. For example most people would agree that 2 * 3 + 4 is more easily readable than mult 2 (add 3 4) or mult(2, add(3, 4)).

If I understood your lase comment correctly, your question is why Haskell often uses symbolic operators in places where it could as well use alphanumeric keywords (or function names)?

Regarding keywords one answer would be that keywords prevent you using certain words as variable names. For example I'm always annoyed when I want to call my variables from and to in a languages where one of those is a keywords - like in Python.

Another reason for symbolic operators in general is concisenes. That doesn't really apply in your specific examples of list comprehensions (<- isn't shorter than in), but in many cases it does.

Yet another reason is readability. That might seem counter-intuitive because symbolic operators are often harder to learn since their "names" don't really tell you anything about what they do (while a function's name usually will), but once you do know what a given operator does, expressions with infix symbolic operators are often easier to parse for a human than one with lots of alpha-numeric prefix function calls since the operators are more easily visually distinguished from the operands that way. For example most people would agree that 2 * 3 + 4 is more easily readable than mult 2 (add 3 4) or mult(2, add(3, 4)).

If I understood your last comment correctly, your question is why Haskell often uses symbolic operators in places where it could as well use alphanumeric keywords (or function names)?

Regarding keywords one answer would be that keywords prevent you using certain words as variable names. For example I'm always annoyed when I want to call my variables from and to in a languages where one of those is a keywords - like in Python.

Another reason for symbolic operators in general is conciseness. That doesn't really apply in your specific examples of list comprehensions (<- isn't shorter than in), but in many cases it does.

Yet another reason is readability. That might seem counter-intuitive because symbolic operators are often harder to learn since their "names" don't really tell you anything about what they do (while a function's name usually will), but once you do know what a given operator does, expressions with infix symbolic operators are often easier to parse for a human than one with lots of alpha-numeric prefix function calls since the operators are more easily visually distinguished from the operands that way. For example most people would agree that 2 * 3 + 4 is more easily readable than mult 2 (add 3 4) or mult(2, add(3, 4)).

Source Link
sepp2k
  • 4.3k
  • 1
  • 28
  • 25

If I understood your lase comment correctly, your question is why Haskell often uses symbolic operators in places where it could as well use alphanumeric keywords (or function names)?

Regarding keywords one answer would be that keywords prevent you using certain words as variable names. For example I'm always annoyed when I want to call my variables from and to in a languages where one of those is a keywords - like in Python.

Another reason for symbolic operators in general is concisenes. That doesn't really apply in your specific examples of list comprehensions (<- isn't shorter than in), but in many cases it does.

Yet another reason is readability. That might seem counter-intuitive because symbolic operators are often harder to learn since their "names" don't really tell you anything about what they do (while a function's name usually will), but once you do know what a given operator does, expressions with infix symbolic operators are often easier to parse for a human than one with lots of alpha-numeric prefix function calls since the operators are more easily visually distinguished from the operands that way. For example most people would agree that 2 * 3 + 4 is more easily readable than mult 2 (add 3 4) or mult(2, add(3, 4)).