0

I define a value "x" to be 2

Prelude> let x=2
Prelude> :sprint x
x = _
Prelude> show x
"2"
Prelude> :sprint x
x = _
Prelude> x
2
Prelude> :sprint x
x = _
  1. Does Haskell uses the concept "variable" at all? In FP like Haskell, everything is a function, but is "x" a function?
  2. if "let x=2" is only a name binding, without evaluation, and then "x" command shows "2", so it has been evaluated right? Why ":sprint x" still prints "_"?
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
vik santata
  • 2,989
  • 8
  • 30
  • 52
  • Haskell doesn't the concept of "variables". Names for values are not the same thing as variables. – John Coleman Feb 29 '16 at 00:45
  • 3
    @JohnColeman, I beg to differ. A variable in Haskell is like a variable in mathematics, not like a variable in a typical imperative language. – dfeuer Feb 29 '16 at 00:57
  • @dfeuer Fair enough -- but I find thinking of Haskell identifiers as being names is a good way to emphasize how they differ from the usual notion of mutable variables in most programming languages – John Coleman Feb 29 '16 at 01:00
  • @JohnColeman, in fact, many are familiar with C-like `const` declarations, which make things similar to haskell variables. – dfeuer Feb 29 '16 at 01:04
  • 4
    And no, not everything is a function in Haskell. See http://conal.net/blog/posts/everything-is-a-function-in-haskell – dfeuer Feb 29 '16 at 01:13

0 Answers0