Search code examples
haskellnaming-conventions

How to name Haskell variables which in physics are uppercase


Variable names in haskell need to be in small case, but

How to declare variables in .hs file, if we want to store g = 9.8 and G = 6.67300 × 10-11 (in following scenario) ?

Conventionally Physicists mention :

(1) Acceleration due to gravity on earth

g = 9.8 m/sec^2

(2) Universal Gravitational constant

G = 6.67300 × 10-11 m3 kg-1 s-2


Solution

  • You will just have to come up with another name. The distinction between names starting with upper- and lowercase letters is part of the syntax.

    While this may be unfortunate in your case, it's a design trade-off. In order to simplify differentiating between different things (e.g. between variables and constructors), identifiers starting with lowercase letters and ones starting with uppercase letters are fundamentally different.