Why I am forced to write liOfLi
in place of LiOfLi
? Please guide.
code in baby.hs
LiOfLi = [ [1,3,4,5,6,8], [ 12, 13, 15, 16, 19, 20], [23, 24, 25, 45, 56] ]
ghci response:
ghci> :l baby
[1 of 1] Compiling Main ( baby.hs, interpreted )
Failed, modules loaded: none.ghci> baby.hs:29:1: Not in scope: data constructor `LiOfLi'
When changing the initial letter to smaller case
code in baby.hs
liOfLi = [ [1,3,4,5,6,8], [ 12, 13, 15, 16, 19, 20], [23, 24, 25, 45, 56] ]
ghci response:
ghci> :l baby
[1 of 1] Compiling Main ( baby.hs, interpreted )
Ok, modules loaded: Main.
Following are the SO questions I referred but I failed to understand the rules/ logic and get the answer for (my) abovementioned question.
Why does Haskell force data constructor's first letter to be upper case?
the variable names need to be lowercase. The official documentation related to this is at haskell.org/onlinereport/intro.html#namespaces – (the SO comment by) Chris Kuklewicz
liOfLi
is not a data constructor. It is a variable. – dave4420i
, one would writeis
orii
for a list of integers - I would then repeat the sameiss
oriii
. There is usually another name that comes to use for a list of lists of numbers -- matrix. butliOfLi
is hard to read and always reminds me of the german lullaby youtube.com/watch?v=2TS-W5woDcw ;-) – epsilonhalbe