We can use the let keyword to give an expression a name by which we can refer to it later. Naming an expression may help clarify the meaning of code and can reduce duplication when the same expression is written more than once.
main =
doIf we let x equal 2, then x plus x equals 4.
let x = 2
putStrLn (show (x + x))You can define multiple variables at once.
let (b, c) = ("one", "two")
putStrLn b
putStrLn cYou can also define multiple variables within a single let clause.
let
d = True
e = [1,2,3]
putStrLn (show d)
putStrLn (show e)$ runhaskell variables.hs
4
one
two
True
[1,2,3]Next: Defining functions

