173x Filetype PDF File size 0.44 MB Source: cnds.jacobs-university.de
Haskell Tutorial Notes Alexandru Hambasan (with some minor edits by Jurgen Schonwalder) ¨ ¨ ¨ Jacobs University Bremen September 28, 2018 Haskell - Introduction and Motivation ◮ Why this programming language? ◮ It’s fun to write and reason about ◮ Will most likely change the way you think about programming ◮ It’s safe (we will see later what this refers to) ◮ Seasoned Haskell users can read it easily ◮ It’s pure! (we will also see what this means later on) Haskell Environment ◮ GHC (Glasgow Haskell Compiler) ◮ used for ”real work” ◮ supports parallel execution ◮ provides performance analysis and debugging tools ◮ ghc → compiler for generating fast native code ◮ ghci → interpreter and debugger ◮ runghc → program for running Haskell programs as scripts Note: the last three represent the main components of GHC Lists, Characters and Strings ◮ Lists ◮ they are surrounded by square brackets and elements are separated by commas ◮ empty list → [ ] ◮ all elements must be of the same type ◮ Haskell supports enumeration notation i.e. [1..10] = [1,2,3,4,5,6,7,8,9,10] ◮ concatenate lists using the ++ operator e.g.: [1, 2, 1] ++ [1, 2] = [1, 2, 1, 1, 2] ◮ the cons (short for construct) operator adds an element to the front of a list symbol for cons → : e.g.: 1 : [2, 3] = [1, 2, 3] Note: only the construction < element > : < list > is allowed
no reviews yet
Please Login to review.