Haskell Introduction CSCE 314 Spring 2016. CSCE 314 – Programming Studio Historical Background 1930s: Alonzo Church develops the lambda calculus, a simple.

Slides:



Advertisements
Similar presentations
Introduction to Compilation of Functional Languages Wanhe Zhang Computing and Software Department McMaster University 16 th, March, 2004.
Advertisements

1 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
1 Programming Languages (CS 550) Lecture Summary Functional Programming and Operational Semantics for Scheme Jeremy R. Johnson.
CSE 3302 Programming Languages Chengkai Li Fall 2007 Functional Programming Language (Introduction and Scheme) Lecture 17 – Functional Programming, Spring.
6. Introduction to the Lambda Calculus. © O. Nierstrasz PS — Introduction to the Lambda Calculus 6.2 Roadmap  What is Computability? — Church’s Thesis.
4. Functional Programming. © O. Nierstrasz PS — Functional Programming 4.2 Roadmap Overview  Functional vs. Imperative Programming  Pattern Matching.
0 PROGRAMMING IN HASKELL Chapter 1 - Introduction.
Chapter 15 Other Functional Languages. Copyright © 2007 Addison-Wesley. All rights reserved. Functional Languages Scheme and LISP have a simple syntax.
Programming Language Theory Leif Grönqvist The national Graduate School of Language Technology (GSLT) MSI.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Introduction to Functional Programming Notes for CSCE 190 Based on Sebesta,
Dr. Muhammed Al-Mulhem ICS An Introduction to Functional Programming.
0 PROGRAMMING IN HASKELL An Introduction Based on lecture notes by Graham Hutton The book “Learn You a Haskell for Great Good” (and a few other sources)
Copyright © 2009 Elsevier Chapter 10 :: Functional Languages Programming Language Pragmatics Michael L. Scott.
Functional Programing Referencing material from Programming Language Pragmatics – Third Edition – by Michael L. Scott Andy Balaam (Youtube.com/user/ajbalaam)
Haskell Chapter 1, Part I. Highly Recommended  Learn you a Haskell for Great Good. Miran Lipovaca.
Functional Languages. Why? Referential Transparency Functions as first class objects Higher level of abstraction Potential for parallel execution.
1 Functional Programming In Text: Chapter Chapter 2: Evolution of the Major Programming Languages Outline Functional programming (FP) basics A bit.
Dr. Muhammed Al-MulhemICS Chapter 5 The Algol Family and Haskell.
ISBN Chapter 15 Functional Programming Languages.
Haskell. 2 GHC and HUGS Haskell 98 is the current version of Haskell GHC (Glasgow Haskell Compiler, version 7.4.1) is the version of Haskell I am using.
Functional Programming Universitatea Politehnica Bucuresti Adina Magda Florea
Functional Programming Languages Chapter 14
Lambda Calculus History and Syntax. History The lambda calculus is a formal system designed to investigate function definition, function application and.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
ISBN Chapter 15 Functional Programming Languages.
1 COMP313A Functional Programming (1). 2 Main Differences with Imperative Languages Say more about what is computed as opposed to how Pure functional.
1 Programming Languages and Paradigms Functional Programming.
Sept 2004 SDP-MSc Slide 1 Section 6 Introduction to Functional Programming.
1 Functional Programming & Standard ML Hossein Hojjat et al.
Functional Programming Universitatea Politehnica Bucuresti Adina Magda Florea
Chapter Fifteen: Functional Programming Languages Lesson 12.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
TIVDM2Functional Programming Language Concepts 1 Concepts from Functional Programming Languages Peter Gorm Larsen.
COMP313A Functional Programming (1)
12/2/20151 GC16/3011 Functional Programming Lecture 2 The Lambda Calculus: A Simple Introduction.
Lee CSCE 314 TAMU 1 CSCE 314 Programming Languages Haskell 101 Dr. Hyunyoung Lee.
1-1 An Introduction to Functional Programming Sept
Functional Programming IN NON-FUNCTIONAL LANGUAGES.
Spring 2008Programming Development Techniques 1 Topic 5.5 Higher Order Procedures (This goes back and picks up section 1.3 and then sections in Chapter.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 190 Programming Language Paradigms Fall 2014
1 FP Foundations, Scheme In Text: Chapter Chapter 14: FP Foundations, Scheme Mathematical Functions Def: A mathematical function is a mapping of.
Functional Programming Part 1. Organization of Programming Languages-Cheng Big Picture u What we’ve learned so far: Imperative Programming Languages 
Copyright © 2009 Elsevier Chapter 10 :: Functional Languages Programming Language Pragmatics Michael L. Scott.
Erik Meijer FP101x - Functional Programming Programming in Haskell - Introduction.
Lambda Calculus A fairly simple system for representing functions The base of typed functional programming languages such as ML and Haskell.
C H A P T E R E I G H T Functional Programming Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
1 Introduction to Functional Programming in Racket CS 270 Math Foundations of CS Jeremy Johnson.
COMP 412, FALL Type Systems C OMP 412 Rice University Houston, Texas Fall 2000 Copyright 2000, Robert Cartwright, all rights reserved. Students.
1 PROGRAMMING IN HASKELL An Introduction Based on lecture notes by Graham Hutton The book “Learn You a Haskell for Great Good” (and a few other sources)
Functional Programming
Functional Programming
What is a Functional Language?
Midterm recap Total was 80 points Distribution range
CS 3304 Comparative Languages
Unit – 3 :LAMBDA CALCULUS AND FUNCTIONAL PROGRAMMING
More Functional Programming
Functional Programming
Fundamentals of Functional Programming Languages
Important Concepts from Clojure
Important Concepts from Clojure
FP Foundations, Scheme In Text: Chapter 14.
CSE 3302 Programming Languages
PROGRAMMING IN HASKELL
Important Concepts from Clojure
CSCE 314: Programming Languages Dr. Dylan Shell
Functional Programming and Haskell
PROGRAMMING IN HASKELL
Chapter 15 Functional Programming 6/1/2019.
Functional Programming and Haskell
Presentation transcript:

Haskell Introduction CSCE 314 Spring 2016

CSCE 314 – Programming Studio Historical Background 1930s: Alonzo Church develops the lambda calculus, a simple but powerful theory of functions.

Spring 2016 CSCE 314 – Programming Studio 1950s: John McCarthy develops Lisp, the first functional language, with some influences from the lambda calculus, but retaining variable assignments

Spring 2016 CSCE 314 – Programming Studio 1960s: Peter Landin develops ISWIM, the first pure functional language, based strongly on the lambda calculus, with no assignments

Spring 2016 CSCE 314 – Programming Studio 1970s: John Backus develops FP, a functional language that emphasizes higher order functions and reasoning about programs.

Spring 2016 CSCE 314 – Programming Studio 1970s: Robin Milner and others develop ML, the first modern functional language, which introduced type inference and polymorphic types.

Spring 2016 CSCE 314 – Programming Studio 1970s-1980s: David Turner develops a number of lazy functional languages, culminating in the Miranda system

Spring 2016 CSCE 314 – Programming Studio 1987: An international committee of researchers initiates the development of Haskell, a standard lazy pure functional language

Spring 2016 CSCE 314 – Programming Studio 2003: The committee publishes the Haskell 98 report, defining a stable version of the language. Since then, Haskell has become highly influential in language research and fairly widely used in open- source/commercial software.

Spring 2016 CSCE 314 – Programming Studio Haskell is a Lazy Pure Functional Language

Spring 2016 CSCE 314 – Programming Studio “Haskell is a Lazy Pure Functional Language” A Functional language supports the functional programming style where the basic method of computation is application of functions to arguments. For example, in C, int s = 0; for (int i=1; i <= 100; ++i) s = s + i; the computation method is variable assignment. In Haskell, sum [1..100] the computation method is function application.

Spring 2016 CSCE 314 – Programming Studio Briefly: Defining functions in Haskell To define a function, you state (in order): the name of the function the arguments it takes an equals sign the result of the function For example: double x = x + x says that double takes a parameter x and returns twice x, so that: double We will have much more to say about this in the future…

Spring 2016 CSCE 314 – Programming Studio Features of Functional Languages Higher-order functions are functions that take other functions as their arguments. e.g., > map reverse ["abc","def"] ["cba","fed”] Purity – prohibits side effects (Expressions may result in some actions in addition to return values, such as changing state and I/O; these actions are called side effects.) Recursion – the canonical way to iterate in functional languages

Spring 2016 CSCE 314 – Programming Studio “Haskell is a Lazy Pure Functional Language” A Lazy programming language only evaluates arguments when strictly necessary, thus, (1)avoiding unnecessary computation and (2)ensuring that programs terminate whenever possible.

Spring 2016 CSCE 314 – Programming Studio “Haskell is a Lazy Pure Functional Language” A Lazy programming language only evaluates arguments when strictly necessary, thus, (1)avoiding unnecessary computation and (2)ensuring that programs terminate whenever possible.

Spring 2016 CSCE 314 – Programming Studio “Haskell is a Lazy Pure Functional Language” A Lazy programming language only evaluates arguments when strictly necessary. For example, given the definitions omit x = 0 keep_going x = keep_going (x+1) what is the result of the following expression? omit (keep_going 1)

Spring 2016 CSCE 314 – Programming Studio “Haskell is a Lazy Pure Functional Language” A Lazy programming language only evaluates arguments when strictly necessary. For example, given the definitions omit x = 0 keep_going x = keep_going (x+1) what is the result of the following expression? omit (keep_going 1) Answer: 0 Since omit is defined to be 0, it doesn‘t matter what is inside.

Spring 2016 CSCE 314 – Programming Studio “Haskell is a Lazy Pure Functional Language” A Pure functional language, as with mathematical functions, prohibits side effects (or at least they are confined): Data is immutable: Instead of altering existing values, altered copies are created and the original is preserved. Thus, there’s no destructive assignment: a = 1; a = 2; -- illegal

Spring 2016 CSCE 314 – Programming Studio “Haskell is a Lazy Pure Functional Language” A Pure functional language, as with mathematical functions, prohibits side effects (or at least they are confined): Expressions yield the same value each time they are invoked. Referential transparency This helps with reasoning. An expression can be replaced with its value without changing the behavior of a program For example, if we have defined y = f x Then g = h y y and g = h (f x) (f x) are equivalent and will get the same result (value).

Spring 2016 CSCE 314 – Programming Studio “Haskell is a Lazy Pure Functional Language” A Pure functional language, as with mathematical functions, prohibits side effects (or at least they are confined): Referential Transparency: For example, if we have defined y = f x Then g = h y y and g = h (f x) (f x) are equivalent and will get the same result (value).