To declare constant variables I can do following in Ruby
class COLOR
RED = 10
BLUE = 20
GREEM = 30
end
COLOR::RED returns 10, COLOR::BLUE returns 20, and so on. How do I accomplish that in Haskell?
I want to have a namespace name in front of my variable name. Maybe the example above is not a good example. For the case below, you can see including a namespace name will make a variable much easier to understand.
class BASEBALL_TEAM
GIANTS = 15
METS = 30
REDS = 45
...
end
BASEBALL_TEAM::GIANTS is much clear than GIANTS.
based on the comments below, it seems the only way I can accomplish it is by doing something like below:
module Color (Color) where
data Color = Red | Blue | Green deriving (Eq, Show, Ord, Bounded, Enum)
fromEnum' x = (fromEnum x) + 10
to get integer value of 10 for Color.Red, I have to write fromEnum Color.Red, the syntax is not very clean.