Haskell Language Getting started with Haskell Language Declaring Values


Example

We can declare a series of expressions in the REPL like this:

Prelude> let x = 5
Prelude> let y = 2 * 5 + x
Prelude> let result = y * 10
Prelude> x
5
Prelude> y
15
Prelude> result
150

To declare the same values in a file we write the following:

-- demo.hs

module Demo where
-- We declare the name of our module so 
-- it can be imported by name in a project.

x = 5

y = 2 * 5 + x

result = y * 10

Module names are capitalized, unlike variable names.