SIMON THOMPSON LEARNING FUNCTIONAL PROGRAMMING
|
|
- Augustine Shelton
- 5 years ago
- Views:
Transcription
1 SIMON THOMPSON LEARNING FUNCTIONAL PROGRAMMING
2 The essence of functional programming Beginning to learn functional programming Resources, advice and bottlenecks
3 THE ESSENCE OF FUNCTIONAL PROGRAMMING
4 LISP Miranda Elm Erlang Idris F# Haskell Elixir Scala OCaml
5
6 higher-order functions pattern matching types data lambdas recursion
7 higher-order functions pattern matching types data lambdas recursion
8 reactive lenses higher-order functions dependent types DSLs lazy pattern matching types data monoids types, types, types, lambdas monads recursion immutability effects
9 fun
10 Model the world as data + Functions over the data + Functions as data
11 And when I say function I mean in the mathematical sense, taking inputs to outputs, and doing nothing else!
12 The approach underlies lots of examples,
13 The approach underlies lots of examples, libraries, laziness, monads, lenses
14 Rock-Paper-Scissors
15 Original image:
16 We choose what to play, depending on the history of all your moves. Original image:
17 data Move = Rock Paper Scissors We choose what to play, depending on the history of all your moves. beat :: [Move] -> Move beat [] = Rock beat (x:xs) = case x of Rock -> Scissors Paper -> Rock Scissors -> Paper Original image:
18 Parsers
19 text parse tree remaining text
20 text parse tree remaining text
21 Side-effects
22 store before input result store after
23 Delay/force streams
24 Original image:
25 cons(x,xs) -> fun() -> {X,Xs} end. head(l) -> case (L()) of {H,_} -> H end. tail(l) -> case (L()) of {_,T} -> T end. Original image:
26 -define(cons(x,xs), -> fun() fun() -> {X,Xs} -> {X,Xs} end. end). head(l) -> case (L()) of {H,_} -> H end. tail(l) -> case (L()) of {_,T} -> T end. Original image:
27 github.com/simonjohnthompson/streams github.com/simonjohnthompson/interaction
28 type
29 Functions give us expressivity + Types help to constrain that + Give a language for modelling
30 BEGINNING FUNCTIONAL PROGRAMMING
31 lambdas higher-order functions types data
32 higher-order functions pattern matching types data lambdas recursion
33 Pick any language Start with the concrete before going to complex abstractions.
34 PATTERN MATCHING
35 type Point = (Float,Float) data Shape = Circle Point Float Rectangle Point Float Float area :: Shape -> Float area (Circle _ r) = pi*r*r area (Rectangle _ h w) = h*w
36 type Point = (Float,Float) data Shape = Circle Point Float Rectangle Point Float Float area :: Shape -> Float -type area (Circle point() _:: r) {float(),float()}. = pi*r*r area (Rectangle _ h w) = h*w -type shape() :: {circle,point(),float()} {rectangle,point(),float(),float()}. -spec area(shape()) -> float(). area({circle,_,r}) -> math:pi()*r*r; area({rectangle,h,w}) -> H*W.
37 type Point = (Float,Float) data Shape = Circle Point Float Rectangle Point Float Float area :: Shape -> Float area (Circle _ r) = pi*r*r area (Rectangle _ h w) = h*w -type point() :: {float(),float()}. -type shape() :: {circle,point(),float()} {rectangle,point(),float(),float()}. -spec area(shape()) -> float(). area({circle,_,r}) -> math:pi()*r*r; area({rectangle,h,w}) -> H*W.
38 PATTERN MATCHING!
39 area :: Shape -> Float area (Circle _ r) = pi*r*r area (Rectangle _ h w) = h*w
40 area :: Shape -> Float area (Circle _ r) = pi*r*r area (Rectangle _ h w) = h*w Link to something more familiar
41 area :: Shape -> Float area (Circle _ r) = pi*r*r area (Rectangle _ h w) = h*w area shape = if is_circle shape then pi*(radius shape)*(radius shape) else height shape * width shape is_circle :: Shape -> Bool is_circle (Circle ) = True is_circle _ = False radius, height, width :: Shape -> Float radius (Circle _ r) = r height (Rectangle _ h _) = h width (Rectangle w) = w
42 area :: Shape -> Float area (Circle _ r) = pi*r*r area (Rectangle _ h w) = h*w area shape = if is_circle shape then pi*(radius shape)*(radius shape) else height shape * width shape is_circle :: Shape -> Bool is_circle (Circle ) = True is_circle _ = False radius, height, width :: Shape -> Float radius (Circle _ r) = r height (Rectangle _ h _) = h width (Rectangle w) = w
43 RECURSION
44 The nub of a list is the list with all duplicates removed. nub :: Eq a => [a] -> [a] nub [] = [] nub(x:xs) = if elem x xs then nub xs else x : nub xs
45 The nub of a list is the list with all duplicates removed. nub([]) -> []; nub([x Xs]) -> [X nub(remove(x,xs))]. remove(_,[]) -> []; remove(x,[x Xs]) -> remove(x,xs); remove(x,[y Xs]) -> [Y remove(x,xs)].
46 The nub of a list is the list with all duplicates removed. nub([]) -> []; nub([x Xs]) -> [X nub(remove(x,xs))]. remove(_,[]) -> []; remove(x,[x Xs]) -> remove(x,xs); remove(x,[y Xs]) -> [Y remove(x,xs)].
47 RECURSION!
48 The nub of a list is the list with all duplicates removed. nub :: Eq a => [a] -> [a] nub [] = [] nub(x:xs) = if elem x xs then nub xs else x : nub xs Generate all the answers? nub [] = [] nub [1] = nub (1:[]) = 1 : nub [] = [1] nub [2,1] = nub (2:[1]) = 2 : nub [1] = [2,1] nub [1,2,1] = nub (1:[2,1]) = nub [2,1] = [2,1]
49 The nub of a list is the list with all duplicates removed. nub :: Eq a => [a] -> [a] nub [] = [] nub(x:xs) = if elem x xs then nub xs else x : nub xs Generate all the answers? nub [] = [] nub [1] = nub (1:[]) = 1 : nub [] = [1] nub [2,1] = nub (2:[1]) = 2 : nub [1] = [2,1] nub [1,2,1] = nub (1:[2,1]) = nub [2,1] = [2,1]
50 The nub of a list is the list with all duplicates removed. nub :: Eq a => [a] -> [a] nub [] = [] nub(x:xs) = if elem x xs then nub xs else x : nub xs Generate all the answers? nub [] = [] nub [1] = nub (1:[]) = 1 : nub [] = [1] nub [2,1] = nub (2:[1]) = 2 : nub [1] = [2,1] nub [1,2,1] = nub (1:[2,1]) = nub [2,1] = [2,1]
51 The nub of a list is the list with all duplicates removed. nub :: Eq a => [a] -> [a] nub [] = [] nub(x:xs) = if elem x xs then nub xs else x : nub xs Generate all the answers? nub [] = [] nub [1] = nub (1:[]) = 1 : nub [] = [1] nub [2,1] = nub (2:[1]) = 2 : nub [1] = [2,1] nub [1,2,1] = nub (1:[2,1]) = nub [2,1] = [2,1]
52 The nub of a list is the list with all duplicates removed. nub :: Eq a => [a] -> [a] nub [] = [] nub(x:xs) = if elem x xs then nub xs else x : nub xs Rewrite work top down nub [1,2,1] = nub (1:[2,1]) = nub [2,1] = nub (2:[1]) = 2 : nub [1] = 2 : nub (1:[]) = 2 : 1 : nub [] = 2 : 1 : [] = 2 :[1] = [2,1]
53 The nub of a list is the list with all duplicates removed. nub :: Eq a => [a] -> [a] nub [] = [] nub(x:xs) = if elem x xs then nub xs else x : nub xs Rewrite work top down nub [1,2,1] = nub (1:[2,1]) = nub [2,1] = nub (2:[1]) = 2 : nub [1] = 2 : nub (1:[]) = 2 : 1 : nub [] = 2 : 1 : [] = 2 :[1] = [2,1]
54 The nub of a list is the list with all duplicates removed. nub :: Eq a => [a] -> [a] nub [] = [] nub(x:xs) = if elem x xs then nub xs else x : nub xs Rewrite work top down nub [1,2,1] = nub (1:[2,1]) = nub [2,1] = nub (2:[1]) = 2 : nub [1] = 2 : nub (1:[]) = 2 : 1 : nub [] = 2 : 1 : [] = 2 :[1] = [2,1]
55 The nub of a list is the list with all duplicates removed. nub :: Eq a => [a] -> [a] nub [] = [] nub(x:xs) = if elem x xs then nub xs else x : nub xs Rewrite work top down nub [1,2,1] = nub (1:[2,1]) = nub [2,1] = nub (2:[1]) = 2 : nub [1] = 2 : nub (1:[]) = 2 : 1 : nub [] = 2 : 1 : [] = 2 :[1] = [2,1]
56 The nub of a list is the list with all duplicates removed. nub :: Eq a => [a] -> [a] nub [] = [] nub(x:xs) = if elem x xs then nub xs else x : nub xs Rewrite work top down nub [1,2,1] = nub (1:[2,1]) = nub [2,1] = nub (2:[1]) = 2 : nub [1] = 2 : nub (1:[]) = 2 : 1 : nub [] = 2 : 1 : [] = 2 :[1] = [2,1]
57 The nub of a list is the list with all duplicates removed. nub :: Eq a => [a] -> [a] nub [] = [] nub(x:xs) = if elem x xs then nub xs else x : nub xs Rewrite work top down nub [1,2,1] = nub (1:[2,1]) = nub [2,1] = nub (2:[1]) = 2 : nub [1] = 2 : nub (1:[]) = 2 : 1 : nub [] = 2 : 1 : [] = 2 :[1] = [2,1]
58 The nub of a list is the list with all duplicates removed. nub :: Eq a => [a] -> [a] nub [] = [] nub(x:xs) = if elem x xs then nub xs else x : nub xs Rewrite work top down nub [1,2,1] = nub (1:[2,1]) = nub [2,1] = nub (2:[1]) = 2 : nub [1] = 2 : nub (1:[]) = 2 : 1 : nub [] = 2 : 1 : [] = 2 :[1] = [2,1]
59 The nub of a list is the list with all duplicates removed. nub :: Eq a => [a] -> [a] nub [] = [] nub(x:xs) = if elem x xs then nub xs else x : nub xs Rewrite work top down nub [1,2,1] = nub (1:[2,1]) = nub [2,1] = nub (2:[1]) = 2 : nub [1] = 2 : nub (1:[]) = 2 : 1 : nub [] = 2 : 1 : [] = 2 :[1] = [2,1]
60 The nub of a list is the list with all duplicates removed. nub :: Eq a => [a] -> [a] nub [] = [] nub(x:xs) = if elem x xs then nub xs else x : nub xs Rewrite work top down nub [1,2,1] = nub (1:[2,1]) = nub [2,1] = nub (2:[1]) = 2 : nub [1] = 2 : nub (1:[]) = 2 : 1 : nub [] = 2 : 1 : [] = 2 :[1] = [2,1]
61 The nub of a list is the list with all duplicates removed. nub :: Eq a => [a] -> [a] nub [] = [] nub(x:xs) = if elem x xs then nub xs else x : nub xs Rewrite work top down nub [1,2,1] = nub (1:[2,1]) = nub [2,1] = nub (2:[1]) = 2 : nub [1] = 2 : nub (1:[]) = 2 : 1 : nub [] = 2 : 1 : [] = 2 :[1] = [2,1]
62 The nub of a list is the list with all duplicates removed. nub :: Eq a => [a] -> [a] nub [] = [] nub(x:xs) = if elem x xs then nub xs else x : nub xs Accept the template: the lists get shorter foo [] = foo (x:xs) = x foo xs
63 The nub of a list is the list with all duplicates removed. nub :: Eq a => [a] -> [a] nub [] = [] nub(x:xs) = if elem x xs then nub xs else x : nub xs Accept the template: the lists get shorter foo [] = foo (x:xs) = x foo xs and look at some examples nub [1,2] = [1,2] nub [2,1,2] = [1,2]
64 How to get started (with recursion)? Examples, examples, examples. From simple five finger exercises, to a favourite small library.
65 RESOURCES
66
67
68
69
70
71
72
73 Online Wiki-books, MOOCs, video channels, try-xxx, tutorials
74
75
76 Working together XXX-bridge, code clubs, meet-ups, reading groups
77 AND THEN
78 Pick any language Start with the concrete before going to complex abstractions.
79 Choosing a language LISP Elm Idris F# Miranda Haskell Elixir Erlang OCaml Scala
80 Find a project Reimplement something Try something new Join an Open Source project
81 Systems
82 Abstraction This board belongs to Newcastle University PhD student Tom Fisher, who is doing research in homological algebra. Thanks to Christian Perfect for the photo. whatsonmyblackboard.wordpress.com
83 Enjoy! Type-driven development Functional Concurrency Systems programming in ML
84 SIMON THOMPSON LEARNING FUNCTIONAL PROGRAMMING
Introduction to Functional Programming and Haskell. Aden Seaman
Introduction to Functional Programming and Haskell Aden Seaman Functional Programming Functional Programming First Class Functions Expressions (No Assignment) (Ideally) No Side Effects Different Approach
More informationInformatics 1 Functional Programming Lecture 9. Algebraic Data Types. Don Sannella University of Edinburgh
Informatics 1 Functional Programming Lecture 9 Algebraic Data Types Don Sannella University of Edinburgh Part I Algebraic types Everything is an algebraic type data Bool = False True data Season = Winter
More informationAdvanced features of Functional Programming (Haskell)
Advanced features of Functional Programming (Haskell) Polymorphism and overloading January 10, 2017 Monomorphic and polymorphic types A (data) type specifies a set of values. Examples: Bool: the type of
More informationAn introduction to functional programming. July 23, 2010
An introduction to functional programming July 23, 2010 About Outline About About What is functional programming? What is? Why functional programming? Why? is novel. is powerful. is fun. About A brief
More informationConcepts of program design Exam January 31, 13:30 16:30
Concepts of program design 2016 2017 Exam January 31, 13:30 16:30 Name: Student number: Please read the following instructions carefully: Fill in your name and student number above. Be prepared to identify
More informationCS 11 Haskell track: lecture 1
CS 11 Haskell track: lecture 1 This week: Introduction/motivation/pep talk Basics of Haskell Prerequisite Knowledge of basic functional programming e.g. Scheme, Ocaml, Erlang CS 1, CS 4 "permission of
More informationLexical and Syntax Analysis. Abstract Syntax
Lexical and Syntax Analysis Abstract Syntax What is Parsing? Parser String of characters Data structure Easy for humans to write Easy for programs to process A parser also checks that the input string
More informationAdvanced Type System Features Tom Schrijvers. Leuven Haskell User Group
Advanced Type System Features Tom Schrijvers Leuven Haskell User Group Data Recursion Genericity Schemes Expression Problem Monads GADTs DSLs Type Type Families Classes Lists and Effect Free Other Handlers
More informationProgramming in Haskell Aug-Nov 2015
Programming in Haskell Aug-Nov 2015 LECTURE 14 OCTOBER 1, 2015 S P SURESH CHENNAI MATHEMATICAL INSTITUTE Enumerated data types The data keyword is used to define new types data Bool = False True data Day
More informationTopic 7: Algebraic Data Types
Topic 7: Algebraic Data Types 1 Recommended Exercises and Readings From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 5.5, 5.7, 5.8, 5.10, 5.11, 5.12, 5.14 14.4, 14.5, 14.6 14.9, 14.11,
More informationSOFTWARE VERIFICATION AND COMPUTER PROOF (lesson 1) Enrico Tassi Inria Sophia-Antipolis
SOFTWARE VERIFICATION AND COMPUTER PROOF (lesson 1) Enrico Tassi Inria Sophia-Antipolis Who am I? 1. I'm a researcher at Inria 2. I work on proof assistants, the kind of tools that we will be using for
More informationAlgebraic Types. Chapter 14 of Thompson
Algebraic Types Chapter 14 of Thompson Types so far Base types Int, Integer, Float, Bool, Char Composite types: tuples (t 1,t 2,,t n ) lists [t 1 ] functions (t 1 -> t 2 ) Algebraic types enumerated, product
More informationLexical and Syntax Analysis
Lexical and Syntax Analysis (of Programming Languages) Abstract Syntax Lexical and Syntax Analysis (of Programming Languages) Abstract Syntax What is Parsing? Parser String of characters Data structure
More informationHarvard School of Engineering and Applied Sciences CS 152: Programming Languages
Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 18 Thursday, March 29, 2018 In abstract algebra, algebraic structures are defined by a set of elements and operations
More informationFunctional Programming in Haskell for A level teachers
Functional Programming in Haskell for A level teachers About this document Functional Programming is now part of the A level curriculum. This document is intended to get those who already have some programming
More informationCS457/557 Functional Languages
CS457/557 Functional Languages Spring 2018 Lecture 1: Course Introduction Andrew Tolmach Portland State University (with thanks to Mark P. Jones) 1 Goals of this course Introduce the beautiful ideas of
More informationCSci 450: Org. of Programming Languages Overloading and Type Classes
CSci 450: Org. of Programming Languages Overloading and Type Classes H. Conrad Cunningham 27 October 2017 (after class) Contents 9 Overloading and Type Classes 1 9.1 Chapter Introduction.........................
More informationAnnouncements. CSCI 334: Principles of Programming Languages. Lecture 5: Fundamentals III & ML
Announcements CSCI 334: Principles of Programming Languages Lecture 5: Fundamentals III & ML Instructor: Dan Barowy Claire Booth Luce info session tonight for women interested in summer research (hopefully
More informationHaskell Overview II (2A) Young Won Lim 8/9/16
(2A) Copyright (c) 2016 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published
More informationPractical Haskell. An introduction to functional programming. July 21, Practical Haskell. Juan Pedro Villa-Isaza. Introduction.
Practical Practical An introduction to functional programming July 21, 2011 Contents Practical Practical is fun, and that s what it s all about! Even if seems strange to you at first, don t give up. Learning
More informationStandard ML. Data types. ML Datatypes.1
Standard ML Data types ML Datatypes.1 Concrete Datatypes The datatype declaration creates new types These are concrete data types, not abstract Concrete datatypes can be inspected - constructed and taken
More information02157 Functional Programming Lecture 1: Introduction and Getting Started
Lecture 1: Introduction and Getting Started nsen 1 DTU Informatics, Technical University of Denmark Lecture 1: Introduction and Getting Started MRH 6/09/2012 WELCOME to Teacher: nsen DTU Informatics, mrh@imm.dtu.dk
More informationFunctional Programming in Haskell Part I : Basics
Functional Programming in Haskell Part I : Basics Madhavan Mukund Chennai Mathematical Institute 92 G N Chetty Rd, Chennai 600 017, India madhavan@cmi.ac.in http://www.cmi.ac.in/ madhavan Madras Christian
More informationCS 360: Programming Languages Lecture 12: More Haskell
CS 360: Programming Languages Lecture 12: More Haskell Geoffrey Mainland Drexel University Adapted from Brent Yorgey s course Introduction to Haskell. Section 1 Administrivia Administrivia Homework 5 due
More informationQuickCheck, SmallCheck & Reach: Automated Testing in Haskell. Tom Shackell
QuickCheck, SmallCheck & Reach: Automated Testing in Haskell By Tom Shackell A Brief Introduction to Haskell Haskell is a purely functional language. Based on the idea of evaluation of mathematical functions
More informationHaskell 101. (Version 1 (July 18, 2012)) Juan Pedro Villa Isaza
Haskell 101 (Version 1 (July 18, 2012)) Juan Pedro Villa Isaza Haskell 101: Contents Introduction Tutorial Homework Bibliography Haskell 101: Contents Introduction Tutorial Homework Bibliography Haskell
More informationRefactoring to Functional. Hadi Hariri
Refactoring to Functional Hadi Hariri Functional Programming In computer science, functional programming is a programming paradigm, a style of building the structure and elements of computer programs,
More informationHaske k ll An introduction to Functional functional programming using Haskell Purely Lazy Example: QuickSort in Java Example: QuickSort in Haskell
Haskell An introduction to functional programming using Haskell Anders Møller amoeller@cs.au.dk The most popular purely functional, lazy programming language Functional programming language : a program
More informationImperative languages
Imperative languages Von Neumann model: store with addressable locations machine code: effect achieved by changing contents of store locations instructions executed in sequence, flow of control altered
More informationHaskell: From Basic to Advanced. Part 2 Type Classes, Laziness, IO, Modules
Haskell: From Basic to Advanced Part 2 Type Classes, Laziness, IO, Modules Qualified types In the types schemes we have seen, the type variables were universally quantified, e.g. ++ :: [a] -> [a] -> [a]
More informationCustom Types. Outline. COMP105 Lecture 19. Today Creating our own types The type keyword The data keyword Records
Outline COMP105 Lecture 19 Custom Types Today Creating our own types The type keyword The data keyword Records Relevant book chapters Programming In Haskell Chapter 8 Learn You a Haskell Chapter 8 The
More informationIntroduction to Functional Programming in Haskell 1 / 56
Introduction to Functional Programming in Haskell 1 / 56 Outline Why learn functional programming? The essence of functional programming What is a function? Equational reasoning First-order vs. higher-order
More informationTesting. Wouter Swierstra and Alejandro Serrano. Advanced functional programming - Lecture 2. [Faculty of Science Information and Computing Sciences]
Testing Advanced functional programming - Lecture 2 Wouter Swierstra and Alejandro Serrano 1 Program Correctness 2 Testing and correctness When is a program correct? 3 Testing and correctness When is a
More informationAn introduction introduction to functional functional programming programming using usin Haskell
An introduction to functional programming using Haskell Anders Møller amoeller@cs.au.dkau Haskell The most popular p purely functional, lazy programming g language Functional programming language : a program
More informationCSE 3302 Programming Languages Lecture 8: Functional Programming
CSE 3302 Programming Languages Lecture 8: Functional Programming (based on the slides by Tim Sheard) Leonidas Fegaras University of Texas at Arlington CSE 3302 L8 Spring 2011 1 Functional Programming Languages
More informationCSc 372. Comparative Programming Languages. 2 : Functional Programming. Department of Computer Science University of Arizona
1/37 CSc 372 Comparative Programming Languages 2 : Functional Programming Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2013 Christian Collberg 2/37 Programming Paradigms
More informationIntroduction to Programming: Lecture 6
Introduction to Programming: Lecture 6 K Narayan Kumar Chennai Mathematical Institute http://www.cmi.ac.in/~kumar 28 August 2012 Example: initial segments Write a Haskell function initsegs which returns
More informationIntroduction to Haskell
Introduction to Haskell Matt Mullins Texas A&M Computing Society October 6, 2009 Matt Mullins (TACS) Introduction to Haskell October 6, 2009 1 / 39 Outline Introduction to Haskell Functional Programming
More informationProgramming Systems in Artificial Intelligence Functional Programming
Click to add Text Programming Systems in Artificial Intelligence Functional Programming Siegfried Nijssen 8/03/16 Discover thediscover world at the Leiden world University at Leiden University Overview
More informationCSE341 Spring 2017, Midterm Examination April 28, 2017
CSE341 Spring 2017, Midterm Examination April 28, 2017 Please do not turn the page until 12:30. Rules: The exam is closed-book, closed-note, etc. except for one side of one 8.5x11in piece of paper. Please
More informationThese notes are intended exclusively for the personal usage of the students of CS352 at Cal Poly Pomona. Any other usage is prohibited without
These notes are intended exclusively for the personal usage of the students of CS352 at Cal Poly Pomona. Any other usage is prohibited without previous written authorization. 1 2 The simplest way to create
More informationCSE3322 Programming Languages and Implementation
Monash University School of Computer Science & Software Engineering Sample Exam 2004 CSE3322 Programming Languages and Implementation Total Time Allowed: 3 Hours 1. Reading time is of 10 minutes duration.
More informationIntroduction. chapter Functions
chapter 1 Introduction In this chapter we set the stage for the rest of the book. We start by reviewing the notion of a function, then introduce the concept of functional programming, summarise the main
More informationINTRODUCTION TO HASKELL
INTRODUCTION TO HASKELL PRINCIPLES OF PROGRAMMING LANGUAGES Norbert Zeh Winter 2018 Dalhousie University 1/81 HASKELL: A PURELY FUNCTIONAL PROGRAMMING LANGUAGE Functions are first-class values: Can be
More informationn n Try tutorial on front page to get started! n spring13/ n Stack Overflow!
Announcements n Rainbow grades: HW1-6, Quiz1-5, Exam1 n Still grading: HW7, Quiz6, Exam2 Intro to Haskell n HW8 due today n HW9, Haskell, out tonight, due Nov. 16 th n Individual assignment n Start early!
More informationCOS 326 Functional programming: an elegant weapon for the modern age
COS 326 Functional programming: an elegant weapon for the modern age In 1936, Alonzo Church invented the lambda calculus. He called it a logic, but it was a language of pure functions -- the world's first
More informationWayne State University Department of Computer Science CSC 5991: Advanced Web Technologies. Functional (Scala) Programming for the Web.
Wayne State University Department of Computer Science CSC 5991: Advanced Web Technologies Functional (Scala) Programming for the Web Fall 2016 A Hybrid Course or/ and Traditional: Hybrid section: CSC 5991,
More informationCSCE 314 Programming Languages
CSCE 314 Programming Languages Final Review Part I Dr. Hyunyoung Lee 1 Programming Language Characteristics Different approaches to describe computations, to instruct computing devices E.g., Imperative,
More informationIntroduction to Typed Racket. The plan: Racket Crash Course Typed Racket and PL Racket Differences with the text Some PL Racket Examples
Introduction to Typed Racket The plan: Racket Crash Course Typed Racket and PL Racket Differences with the text Some PL Racket Examples Getting started Find a machine with DrRacket installed (e.g. the
More informationLogic - CM0845 Introduction to Haskell
Logic - CM0845 Introduction to Haskell Diego Alejandro Montoya-Zapata EAFIT University Semester 2016-1 Diego Alejandro Montoya-Zapata (EAFIT University) Logic - CM0845 Introduction to Haskell Semester
More informationFunctional Programming in Haskell Part 2 : Abstract dataypes and infinite structures
Functional Programming in Haskell Part 2 : Abstract dataypes and infinite structures Madhavan Mukund Chennai Mathematical Institute 92 G N Chetty Rd, Chennai 600 017, India madhavan@cmi.ac.in http://www.cmi.ac.in/
More informationAbstract Types, Algebraic Types, and Type Classes
Informatics 1 Functional Programming Lectures 13 and 14 Monday 9 and Tuesday 10 November 2009 Abstract Types, Algebraic Types, and Type Classes Philip Wadler University of Edinburgh Reminders Tutorial
More informationCOSE212: Programming Languages. Lecture 3 Functional Programming in OCaml
COSE212: Programming Languages Lecture 3 Functional Programming in OCaml Hakjoo Oh 2017 Fall Hakjoo Oh COSE212 2017 Fall, Lecture 3 September 18, 2017 1 / 44 Why learn ML? Learning ML is a good way of
More informationPROGRAMMING IN HASKELL. CS Chapter 6 - Recursive Functions
PROGRAMMING IN HASKELL CS-205 - Chapter 6 - Recursive Functions 0 Introduction As we have seen, many functions can naturally be defined in terms of other functions. factorial :: Int Int factorial n product
More informationBackground Type Classes (1B) Young Won Lim 6/14/18
Background Type Classes (1B) Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2
More informationHaskell Scripts. Yan Huang
Haskell Scripts Yan Huang yh33@indiana.edu Last Quiz Objectives Writing Haskell programs in.hs files Note some differences between programs typed into GHCi and programs written in script files Operator
More informationFunctional Programming Principles in Scala. Martin Odersky
Functional Programming Principles in Scala Martin Odersky Programming Paradigms Paradigm: In science, a paradigm describes distinct concepts or thought patterns in some scientific discipline. Main programming
More informationIntroduction to Prof. Clarkson Fall Today s music: Prelude from Final Fantasy VII by Nobuo Uematsu (remastered by Sean Schafianski)
Introduction to 3110 Prof. Clarkson Fall 2018 Today s music: Prelude from Final Fantasy VII by Nobuo Uematsu (remastered by Sean Schafianski) Programming is not hard Programming well is very hard Folklore:
More informationBackground Type Classes (1B) Young Won Lim 6/28/18
Background Type Classes (1B) Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2
More informationQuick announcement. Midterm date is Wednesday Oct 24, 11-12pm.
Quick announcement Midterm date is Wednesday Oct 24, 11-12pm. The lambda calculus = ID (λ ID. ) ( ) The lambda calculus (Racket) = ID (lambda (ID) ) ( )
More informationAlgebra 1. Standard 11 Operations of Expressions. Categories Combining Expressions Multiply Expressions Multiple Operations Function Knowledge
Algebra 1 Standard 11 Operations of Expressions Categories Combining Expressions Multiply Expressions Multiple Operations Function Knowledge Summative Assessment Date: Wednesday, February 13 th Page 1
More informationLogical Methods in... using Haskell Getting Started
Logical Methods in... using Haskell Getting Started Jan van Eijck May 4, 2005 Abstract The purpose of this course is to teach a bit of functional programming and logic, and to connect logical reasoning
More informationMini-ML. CS 502 Lecture 2 8/28/08
Mini-ML CS 502 Lecture 2 8/28/08 ML This course focuses on compilation techniques for functional languages Programs expressed in Standard ML Mini-ML (the source language) is an expressive core subset of
More informationLecture 13 CIS 341: COMPILERS
Lecture 13 CIS 341: COMPILERS Announcements HW4: OAT v. 1.0 Parsing & basic code generation Due: March 28 th START EARLY! Midterm Exam Grades Available on Gradescope Zdancewic CIS 341: Compilers 2 Midterm
More informationWeek 5 Tutorial Structural Induction
Department of Computer Science, Australian National University COMP2600 / COMP6260 Formal Methods in Software Engineering Semester 2, 2016 Week 5 Tutorial Structural Induction You should hand in attempts
More informationCS 415 Midterm Exam Spring 2002
CS 415 Midterm Exam Spring 2002 Name KEY Email Address Student ID # Pledge: This exam is closed note, closed book. Good Luck! Score Fortran Algol 60 Compilation Names, Bindings, Scope Functional Programming
More informationJVM ByteCode Interpreter
JVM ByteCode Interpreter written in Haskell (In under 1000 Lines of Code) By Louis Jenkins Presentation Schedule ( 15 Minutes) Discuss and Run the Virtual Machine first
More informationProgramming Paradigms and Languages Introduction to Haskell. dr Robert Kowalczyk WMiI UŁ
Programming Paradigms and Languages Introduction to Haskell dr Robert Kowalczyk WMiI UŁ Functional programming In functional programming (special type of declarative programming), programs are executed
More information02157 Functional Programming. Michael R. Ha. Disjoint Unions and Higher-order list functions. Michael R. Hansen
Disjoint Unions and Higher-order list functions nsen 1 DTU Compute, Technical University of Denmark Disjoint Unions and Higher-order list functions MRH 27/09/2018 Overview Recap Disjoint union (or Tagged
More informationHaskell in the Software Industry
Haskell in the Software Industry What is Haskell? Haskell in a nutshell Haskell is a pure, non-strict, statically typed, garbage collected, general purpose, functional programming language. Early history
More informationFunctional Logic Programming Language Curry
Functional Logic Programming Language Curry Xiang Yin Department of Computer Science McMaster University November 9, 2010 Outline Functional Logic Programming Language 1 Functional Logic Programming Language
More informationIntroduction to ML. Mooly Sagiv. Cornell CS 3110 Data Structures and Functional Programming
Introduction to ML Mooly Sagiv Cornell CS 3110 Data Structures and Functional Programming The ML Programming Language General purpose programming language designed by Robin Milner in 1970 Meta Language
More informationProgramming Languages Fall 2013
Programming Languages Fall 2013 Lecture 2: types Prof. Liang Huang huang@qc.cs.cuny.edu Recap of Lecture 1 functional programming vs. imperative programming basic Haskell syntax function definition lazy
More informationFunctional Programming
Functional Programming Björn B. Brandenburg The University of North Carolina at Chapel Hill Based in part on slides and notes by S. Olivier, A. Block, N. Fisher, F. Hernandez-Campos, and D. Stotts. Brief
More informationProgramming Languages
Programming Languages Andrea Flexeder Chair for Theoretical Computer Science Prof. Seidl TU München winter term 2010/2011 Lecture 10 Side-Effects Main Points you should get: Why monads? What is a monad?
More informationHaskell Overview II (2A) Young Won Lim 8/23/16
(2A) Copyright (c) 2016 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published
More informationHaskell Overview III (3A) Young Won Lim 10/4/16
(3A) Copyright (c) 2016 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published
More informationInformatics 1 Functional Programming 19 Tuesday 23 November IO and Monads. Philip Wadler University of Edinburgh
Informatics 1 Functional Programming 19 Tuesday 23 November 2010 IO and Monads Philip Wadler University of Edinburgh The 2010 Informatics 1 Competition Sponsored by Galois (galois.com) List everyone who
More informationLecture 19: Functions, Types and Data Structures in Haskell
The University of North Carolina at Chapel Hill Spring 2002 Lecture 19: Functions, Types and Data Structures in Haskell Feb 25 1 Functions Functions are the most important kind of value in functional programming
More informationHaskell Making Our Own Types and Typeclasses
Haskell Making Our Own Types and Typeclasses http://igm.univ-mlv.fr/~vialette/?section=teaching Stéphane Vialette LIGM, Université Paris-Est Marne-la-Vallée January 13, 2015 Making Our Own Types and Typeclasses
More informationCS 457/557: Functional Languages
CS 457/557: Functional Languages Lists and Algebraic Datatypes Mark P Jones Portland State University 1 Why Lists? Lists are a heavily used data structure in many functional programs Special syntax is
More informationLittle and not so big bits of Haskell
Little and not so big bits of Haskell D. Renault Haskell (small) School LaBRI October 2015, v. 1.2.1 D. Renault (LaBRI) Little and not so big bits of Haskell October 2015, v. 1.2.1 1 / 45 1990 - A committee
More informationF# for Industrial Applications Worth a Try?
F# for Industrial Applications Worth a Try? Jazoon TechDays 2015 Dr. Daniel Egloff Managing Director Microsoft MVP daniel.egloff@quantalea.net October 23, 2015 Who are we Software and solution provider
More informationCOS 326 David Walker. Thanks to Kathleen Fisher and recursively to Simon Peyton Jones for much of the content of these slides.
COS 326 David Walker Thanks to Kathleen Fisher and recursively to Simon Peyton Jones for much of the content of these slides. Optional Reading: Beautiful Concurrency, The Transactional Memory / Garbage
More informationTrees. Solution: type TreeF a t = BinF t a t LeafF 1 point for the right kind; 1 point per constructor.
Trees 1. Consider the following data type Tree and consider an example inhabitant tree: data Tree a = Bin (Tree a) a (Tree a) Leaf deriving Show tree :: Tree Int tree = Bin (Bin (Bin Leaf 1 Leaf ) 2 (Bin
More informationCOP4020 Programming Languages. Functional Programming Prof. Robert van Engelen
COP4020 Programming Languages Functional Programming Prof. Robert van Engelen Overview What is functional programming? Historical origins of functional programming Functional programming today Concepts
More informationDependently Typed Functional Programming with Idris
Dependently Typed Functional Programming with Idris Lecture 2: Embedded Domain Specific Languages Edwin Brady University of St Andrews ecb10@st-andrews.ac.uk @edwinbrady Introduction In this lecture: Some
More informationProgramming Paradigms
PP 2017/18 Unit 12 Functions and Data Types in Haskell 1/45 Programming Paradigms Unit 12 Functions and Data Types in Haskell J. Gamper Free University of Bozen-Bolzano Faculty of Computer Science IDSE
More informationAbout the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Haskell Programming
About the Tutorial Haskell is a widely used purely functional language. Functional programming is based on mathematical functions. Besides Haskell, some of the other popular languages that follow Functional
More informationCIS 194: Homework 5. Due Friday, October 3, Rings. No template file is provided for this homework. Download the
CIS 194: Homework 5 Due Friday, October 3, 2014 No template file is provided for this homework. Download the Ring.hs and Parser.hs files from the website, and make your HW05.hs Haskell file with your name,
More informationCSE341 Autumn 2017, Midterm Examination October 30, 2017
CSE341 Autumn 2017, Midterm Examination October 30, 2017 Please do not turn the page until 2:30. Rules: The exam is closed-book, closed-note, etc. except for one side of one 8.5x11in piece of paper. Please
More informationCMSC 330: Organization of Programming Languages. Functional Programming with OCaml
CMSC 330: Organization of Programming Languages Functional Programming with OCaml 1 What is a functional language? A functional language: defines computations as mathematical functions discourages use
More informationType families and data kinds
Type families and data kinds AFP Summer School Wouter Swierstra 1 Today How do GADTs work? Kinds beyond * Programming with types 2 Calling functions on vectors Given two vectors xs : Vec a n and ys : Vec
More informationIntro. Scheme Basics. scm> 5 5. scm>
Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if
More informationShell CSCE 314 TAMU. Functions continued
1 CSCE 314: Programming Languages Dr. Dylan Shell Functions continued 2 Outline Defining Functions List Comprehensions Recursion 3 A Function without Recursion Many functions can naturally be defined in
More informationHaskell An Introduction
Haskell An Introduction What is Haskell? General purpose Purely functional No function can have side-effects IO is done using special types Lazy Strongly typed Polymorphic types Concise and elegant A First
More information(Algebraically oriented) domain modeling in Haskell
(Algebraically oriented) domain modeling in Haskell Ralf Lämmel Software Languages Team Faculty of Computer Science University of Koblenz-Landau Acknowledgment: This is joint work with Magne Haveraaen,
More informationKINDERGARTEN MATH STANDARDS BASED RUBRIC NUMBER SENSE Essential Standard: 1.0 STUDENTS UNDERSTAND THE RELATIONSHIP BETWEEN NUMBERS AND QUANTITIES.
KINDERGARTEN MATH STANDARDS BASED RUBRIC NUMBER SENSE 1.0 STUDENTS UNDERSTAND THE RELATIONSHIP BETWEEN NUMBERS AND QUANTITIES. Unable to compare 2 or more In consistently compare 2 or Compare 2 or more
More informationFunctional Programming in C++
Functional Programming in C++ David Letscher Saint Louis University Programming Languages Letscher (SLU) Functional Programming in C++ Prog Lang 1 / 17 What is needed to incorporate functional programming?
More informationCMSC 330: Organization of Programming Languages. Functional Programming with Lists
CMSC 330: Organization of Programming Languages Functional Programming with Lists CMSC330 Spring 2018 1 Lists in OCaml The basic data structure in OCaml Lists can be of arbitrary length Implemented as
More information