| Safe Haskell | Safe-Inferred |
|---|
Lessons.Lesson01
Description
Notes taken by Ugnė Pacevičiūtė
Module is a unit of compilation. A module can export values, functions,.. so they become accessible from other modules.
Core thing to remember: all values (not variables) are immutable!
Documentation
First let's declare some values. In Integer is unbounded (or endless) integer value which does not depend on your computer's architecture so never overflows. The first line is a signature (`::` is a delimiter between a name and a type). The second line is a body.
>>>i + i == 84True
An Int represents an integer which size respects your computer's architecture. Might overflow.
So, let's assume we know how to declare values, but what about functions? Functions and values are declared in a similar way, here we have a function which takes an Integer as a parameter and returns a Bool.
Values are functions which do not take any arguments!
>>>f 23True
>>>f 19False
add :: Integer -> Integer -> Integer Source #
This is a bit more sophisticated case: function takes two arguments.
>>>add 20 2242
But what is we pass less arguments than needed? You get a function as a result!
>>>:t add 20add 20 :: Integer -> Integer
>>>:t addadd :: Integer -> Integer -> Integer
This technique is called Currying