You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Haskell is a purely functional programming language. It is the language most commonly used to teach functional programming at A-Level. This lesson covers the essential Haskell syntax and features you need for your exam.
-- Simple function
double :: Int -> Int
double x = x * 2
-- Function with two parameters
add :: Int -> Int -> Int
add x y = x + y
-- Using the function
result = double 5 -- 10
sum = add 3 4 -- 7
The first line is the type signature (optional but recommended). The second line is the definition.
-- Takes an Int, returns an Int
square :: Int -> Int
square x = x * x
-- Takes two Ints, returns an Int
multiply :: Int -> Int -> Int
multiply x y = x * y
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.