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
I would simply use
g
and_G
. I think the underscore isn't too distracting.You could give them meaningful names. Just because mathematicians and physicists historically liked to use inscrutable symbols with no way of interpreting them other than rote memorisation doesn't mean you have to. We're typing now, not writing long-hand, so defining equations in terms of
earthGravity
andgravitationalConstant
isn't so much harder to write than in terms ofg
andG
, and it's a hell of a lot easier to read!Or, you could designate that all identifiers prefixed with something like
c
represent standard well known constants, and usecg
andcG
.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.