Types And Categories. Anat Gilboa
|
|
- Edwin Leonard
- 5 years ago
- Views:
Transcription
1 Types And Categories Anat Gilboa 1
2 Background 2
3 The Plan 3
4 The Plan 4
5 The Plan 5
6 6
7 What to expect "Functional Swift" Closures Types & Categories 7
8 8
9 Swift Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns. Swift.org 9
10 Features Closures unified with function pointers Tuples and multiple return values Generics Fast and concise iteration over a range or collection Structs that support methods, extensions, and protocols Functional programming patterns, e.g., map and filter Powerful error handling built-in Advanced control flow with do, guard, defer, and repeat keywords 10
11 Features Functional programming patterns, e.g., map and filter Closures unified with function pointers 11
12 Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids changing state and mutable data. 12
13 Functional Programming Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids changing state and mutable data. paradigm. (n) A worldview underlying the theories and methodology of a particular scientific subject 13
14 Some Paradigms Procedural (imperative) programming - decomposing problems into a sequence of actions Object-oriented programming - decomposing problems into self-contained properties and methods to manipulate them Functional programming - decomposing problems into functions that accept and return immutable values Generic programming - general purpose algorithms that can be applied to arbitrary types 14
15 Higher-order A higher-order function is a function that does at least one of the following: - takes one or more functions as arguments - returns a function as its result Examples: - map, flatmap - filter - reduce 15
16 map let values: [Int] = [1, 2, 3, 4] let squaredvalues = values.map { $0 * $0 } print(squaredvalues) // [1, 4, 9, 16] 16
17 17
18 Closures a self-contained block of functionality that can be passed around and used in code. can capture and store references to any constants and variables from the context in which they are defined. 18
19 extension UIView { } open class func animate(withduration duration: TimeInterval, () -> Swift.Void, completion: ((Bool) -> Swift.Void)? = nil) // delay = 0.0, options = 0 19
20 class MyView: UIView { let label = UILabel() //... func update(title: NSAttributedString, color: UIColor, animated: Bool) { UIView.transition(with: self, duration: animated? 0.5 : 0, options:.transitioncrossdissolve, animations: { self.label.attributedtext = title self.backgroundcolor = color }, completion: { completed in if completed == true { print("we finished the animation!") } }) } } 20
21 Promise A Promise is a way to represent a value that will exist (or will fail with an error) at some point in the future. Similar to how an Optional represents a value that may or may not exist. let userspromise = fetchusers() // Promise<[User]> userspromise.then({ users in self.users = users }) 21
22 Promise struct User { let age: Int let givenname: String } func fetchusers() -> Promise<[User]> { // get a list of users return Promise(value: users) } fetchusers().then { users -> [User] in return users.filter { $0.givenName == "Lucy" } }.catch { error in displayerror(error) } 22
23 Promise fetchusers().then { users -> [User] in return users.filter { $0.givenName == "Lucy" } }.then { lucys -> Promise<[User]> in guard let firstlucy = lucys.first else { return Promise(error: LucyError()) } return fetchfollowers(for: firstlucy) }.then { [weak self] followers in guard followers.count > 0 else { return } self?.dosomething(with: followers) }.catch { error in displayerror(error) } 23
24 !?.then { users ->??? in //??? }.then { lucys ->??? in //??? } 24
25 Type " 25
26 Type Systems Comprised of a collection of rules that assign a property (type) to various constructs in a computer program, such as variables, expressions, functions or modules 26
27 So What? 27
28 28
29 A monad is just a monoid in the category of endofunctors, what's the problem? James Iry, Brief, Incomplete and Mostly Wrong History of Programming Languages 29
30 "All told, a monad in X is just a monoid in the category of endofunctors of X, with product [operation] replaced by composition of endofunctors and unit set by the identity endofunctor." Saunders MacLane, Categories for the Working Mathematician 30
31 Category A category consists of: - a collection of objects - a collection of morphisms - every morphism has a source and object 31
32 Composition 101 func incr(_ x: Int) -> Int { return x + 1 } func square(_ x: Int) -> Int { return x * x } square(incr(2)) // 9 32
33 Composition 101 f(x) = x 2 g(x) = x + 1 (f g)(x) = f(g(x)) = (x + 1) 2 (f g)(2) = f(g(2)) = (2 + 1) 2 = 9 33
34 Category Laws 34
35 Recap category: objects and arrows associativity: f : a b, g : b c and h : c d, h (g f) = (h g) f identity: 1x : x x 35
36 Category example: Set big small 36
37 A monad is a monoid is the category of endofunctors category monoid 37
38 Monoid A set M equipped with a binary operation μ: M M M and a special element 1 M such that 1 and x y=μ(x,y) satisfy the usual axioms of associativity: * (x y) z=x (y z) and the left and right unit laws: * 1 x = x = x 1 38
39 Recap category monoid: a set associativity: f : a b, g : b c and h : c d, h (g f) = (h g) f identity: 1x : x x 39
40 A monad is a monoid is the category of endofunctors category monoid monoidal category 40
41 Monoidal Category A monoidal category is a category equipped with some notion of tensor product (bifunctor): 41
42 Product Set of pairs (Cartesian product) typealias A = String typealias B = Int struct Product<A,B> { let a: A let b: B } let projectiona: (Product<A,B>) -> A = { $0.a } let projectionb: (Product<A,B>) -> B = { $0.b } let prod = Product(a: "Hello", b: 3) projectiona(prod) // "Hello" projectionb(prod) // 3 42
43 Product 43
44 Coproduct typealias A = String typealias B = Int enum Coproduct<A,B> { case a(a) case b(b) } let injecta: (A) -> Coproduct<A,B> = {.a($0) } let injectb: (B) -> Coproduct<A,B> = {.b($0) } let left = "left" let right = 3 injecta(left) // a("left") injectb(right) // b(3) 44
45 Coproduct 45
46 Either enum Either<String, Int> { case Left(String) case Right(Int) } let possibleinjectiona: Either<String,Int> =.Left("Hello") let possibleinjectionb: Either<String,Int> =.Right(3) 46
47 Optional enum Optional<T> { case None case Some(T) } 47
48 Result enum Result<T> { case Value(value: T) case Error(error: Error) } 48
49 Bifunctor : C C C 49
50 Monoidal Category category monoid monoidal category: Objects and arrows Product associativity identity Coproduct associativity identity 50
51 A monad is a monoid is the category of endofunctors category monoid monoidal category functor 51
52 Functor Structure-preserving mapping between categories Objects to objects Arrows to arrows 52
53 Functor A simple intuition is that a Functor represents a container of some sort, along with the ability to apply a function uniformly to every element in the container. For example, a list is a container of elements, and we can apply a function to every element of a list, using map. 53
54 Functor enum Result<T> { case Value(value: T) case Error(error: Error) } extension Result { func map<u>(f: (T) -> U) -> Result<U> { switch self { case let.value(value): return Result<U>.Value(value: f(value)) case let.error(error): return Result<U>.Error(error: error) } } } 54
55 55
56 56
57 A monad is just a monoid in the category of endofunctors category monoid monoidal category functor 57
58 Endofunctors An endofunctor is a functor from one category back to the same category 58
59 59
60 60
61 Example func map<u>(f: (T) -> U) -> Result<U> 61
62 Example func map(f: (Data) -> Result<String>) -> Result<Result<String>> 62
63 Example func map(f: (Data) -> Result<String>) -> Result<Result<String>> extension Result { static func flatten<t>(result: Result<Result<T>>) -> Result<T> { switch result { case let.value(innerresult): return innerresult case let.error(error): return Result<T>.Error(error: error) } } } 63
64 A monad is just a monoid in the category of endofunctors 64
65 If you can define flatmap for a type, the type is often called a monad. Chris Eidhof 65
66 Result extension Result { func flatmap<u>(f: T -> Result<U>) -> Result<U> { return Result.flatten(map(f)) } } 66
67 A monad is just a monoid in the category of endofunctors category monoid monoidal category functor endofunctor 67
68 HOW! THIS! ALL! CONNECTS! 68
69 69
70 Programming Languages, Dr. Westley Weimer 70
71 Types 71
72 Types A set of values A set of valid operations on those values 72
73 Type Checking Statically Dynamically Untyped 73
74 Hole-driven (or compiler-driven) development with types seeing the compiler not as an enemy you have to fight, but as a tool that guides you almost magically to a solution for your problem, one step at a time, using types..then { users ->??? in //??? }.then { lucys ->??? in //??? } Ole Begemann 74
75 Embracing the Type System Hole-driven development is a fantastic technique for modeling data structures and data transformations 75
76 Take aways No need to fear the definition of a "monad" We use monads all the time Swift has monads built in, but extending your type to be a monad is simple There's lots more category theory out there Closures and maps allow us to embrace our type system 76
77 Thanks! 77
78 Helpful Resources nlab Category Theory for Programmers Proof in Functions Grokking Lazy Sequences & Collections Functional Swift Conference Talks - Beyond Type Safety - A Type System From Scratch 78
79 Helpful Resources Point-Free Swift Talk Monads are Burritos #1 Monads are Burritos #2 Monad Tutorial Fallacy The Swift Type System Under the Hood Implementing Swift Generics Leveraging Swift's Type System 79
Functional Programming Concepts for Data Processing
Functional Programming Concepts for Data Processing Chris Lindholm UCAR SEA 2018 1 / 70 About Me I work at CU LASP I work primarily with Scala I teach Haskell at work Goal: leverage FP to improve scientific
More informationAll About Comonads (Part 1) An incomprehensible guide to the theory and practice of comonadic programming in Haskell
All About Comonads (Part 1) An incomprehensible guide to the theory and practice of comonadic programming in Haskell Edward Kmett http://comonad.com/ Categories Categories have objects and arrows Every
More informationStanford CS193p. Developing Applications for ios. Fall CS193p. Fall
Stanford Developing Applications for ios Today Mostly Swift but some other stuff too Autolayout teaser Quick review of what we learned in Concentration CountableRange of floating point numbers Tuples Computed
More informationITP 342 Mobile App Dev. Animation
ITP 342 Mobile App Dev Animation Views Views are the fundamental building blocks of your app's user interface, and the UIView class defines the behaviors that are common to all views. Responsibilities
More informationStanford CS193p. Developing Applications for ios. Fall CS193p. Fall
Stanford Developing Applications for ios Today Mostly more Swift but some other stuff too Quick demo of mutating protocols String NSAttributedString Closures (and functions as types in general) Data Structures
More informationMonads T T T T T. Dually (by inverting the arrows in the given definition) one can define the notion of a comonad. T T
Monads Definition A monad T is a category C is a monoid in the category of endofunctors C C. More explicitly, a monad in C is a triple T, η, µ, where T : C C is a functor and η : I C T, µ : T T T are natural
More informationself Some(1) self y 1 .Some Optional, if let Optional<Int>.None Optional<Int>.None
let tq: Int? = 1 let b = tq.map { (a: Int) -> Int? in if a % 2 == 0 { return a else { return Optional.None if let _ = b { print("not nil") self Some(1) self y 1 f, : Optional.None public func
More informationCSCI 2041: Lazy Evaluation
CSCI 2041: Lazy Evaluation Chris Kauffman Last Updated: Wed Dec 5 12:32:32 CST 2018 1 Logistics Reading Module Lazy on lazy evaluation Module Stream on streams Lambdas/Closures Briefly discuss these as
More informationMonads and More: Part 3
Monads and More: Part 3 Tarmo Uustalu, Tallinn Nottingham, 14 18 May 2007 Arrows (Hughes) Arrows are a generalization of strong monads on symmetric monoidal categories (in their Kleisli triple form). An
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 informationChapter 11 :: Functional Languages
Chapter 11 :: Functional Languages Programming Language Pragmatics Michael L. Scott Copyright 2016 Elsevier 1 Chapter11_Functional_Languages_4e - Tue November 21, 2017 Historical Origins The imperative
More informationCategory Theory & Functional Data Abstraction
Category Theory & Functional Data Abstraction Brandon Shapiro Math 100b 1. Introduction Throughout mathematics, particularly algebra, there are numerous commonalities between the studies of various objects
More informationCrash Course in Monads. Vlad Patryshev
Crash Course in Monads Vlad Patryshev Introduction Monads in programming seem to be the most mysterious notion of the century. I find two reasons for this: lack of familiarity with category theory; many
More informationHaskell 98 in short! CPSC 449 Principles of Programming Languages
Haskell 98 in short! n Syntax and type inferencing similar to ML! n Strongly typed! n Allows for pattern matching in definitions! n Uses lazy evaluation" F definition of infinite lists possible! n Has
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 informationPresented By Andrew Butt
Presented By Andrew Butt Overview A Brief History of Functional Programming Comparison Between OOP and Functional programming Paradigms and Concepts Functional Programming in Other Languages An Overview
More informationAn introduction to Category Theory for Software Engineers*
An introduction to Category Theory for Software Engineers* Dr Steve Easterbrook Associate Professor, Dept of Computer Science, University of Toronto sme@cs.toronto.edu *slides available at http://www.cs.toronto.edu/~sme/presentations/cat101.pdf
More informationLESSONS LEARNED. SWIFT. Dagna Bieda, 7th April 2016
LESSONS LEARNED. SWIFT Dagna Bieda, 7th April 2016 SWIFT & XCODE Brief Intro Language that essentially marries the readability of Python with the speed of C++. @jeremyconkin SWIFT mix of good practices
More informationGeneric Programming with Protocol in Swift. ios
Generic Programming with Protocol in Swift ios Generic Programming with Protocol in Swift ios func swapint(inout a: Int, inout _ b: Int) { let tmp = a a = b b = tmp var someint = 1 var anotherint = 5
More informationCS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011
CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e
More informationProgramming with Math and Logic
.. Programming with Math and Logic an invitation to functional programming Ed Morehouse Wesleyan University The Plan why fp? terms types interfaces The What and Why of Functional Programming Computing
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 informationProgramming Languages Lecture 14: Sum, Product, Recursive Types
CSE 230: Winter 200 Principles of Programming Languages Lecture 4: Sum, Product, Recursive Types The end is nigh HW 3 No HW 4 (= Final) Project (Meeting + Talk) Ranjit Jhala UC San Diego Recap Goal: Relate
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 informationImperative programming in F#
Imperative programming in F# Björn Lisper School of Innovation, Design, and Engineering Mälardalen University bjorn.lisper@mdh.se http://www.idt.mdh.se/ blr/ Imperative programming in F# (revised 2015-05-05)
More informationThe three faces of homotopy type theory. Type theory and category theory. Minicourse plan. Typing judgments. Michael Shulman.
The three faces of homotopy type theory Type theory and category theory Michael Shulman 1 A programming language. 2 A foundation for mathematics based on homotopy theory. 3 A calculus for (, 1)-category
More informationios Application Development Lecture 2: Seminar and Unit 1
ios Application Development Lecture 2: Seminar and Unit 1 Dr. Simon Völker & Philipp Wacker Media Computing Group RWTH Aachen University Winter Semester 2017/2018 http://hci.rwth-aachen.de/ios Swift 18
More informationIntroduction 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 informationSwift, functional programming, and does it matter? Alexis
Swift, functional programming, and does it matter? Alexis Gallagher @alexisgallagher Questions What s new in Swift? Is Swift a functional programming language? And what is functional anyway? How useful
More informationFunctional Languages. CSE 307 Principles of Programming Languages Stony Brook University
Functional Languages CSE 307 Principles of Programming Languages Stony Brook University http://www.cs.stonybrook.edu/~cse307 1 Historical Origins 2 The imperative and functional models grew out of work
More informationFunctional Programming in Java. CSE 219 Department of Computer Science, Stony Brook University
Functional Programming in Java CSE 219, Stony Brook University What is functional programming? There is no single precise definition of functional programming (FP) We should think of it as a programming
More informationHaskell Monads CSC 131. Kim Bruce
Haskell Monads CSC 131 Kim Bruce Monads The ontological essence of a monad is its irreducible simplicity. Unlike atoms, monads possess no material or spatial character. They also differ from atoms by their
More informationModule 10: Imperative Programming, Modularization, and The Future
Module 10: Imperative Programming, Modularization, and The Future If you have not already, make sure you Read How to Design Programs Sections 18. 1 CS 115 Module 10: Imperative Programming, Modularization,
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 informationInductive Types for Free
Inductive Types for Free Representing Nested Inductive Types using W-types Michael Abbott (U. Leicester) Thorsten Altenkirch (U. Nottingham) Neil Ghani (U. Leicester) Inductive Types for Free p.1/22 Ideology
More informationStanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017
Stanford Developing Applications for ios Today Error Handling in Swift try Extensions A simple, powerful, but easily overused code management syntax Protocols Last (but certainly not least important) typing
More informationChapter 13: Reference. Why reference Typing Evaluation Store Typings Safety Notes
Chapter 13: Reference Why reference Typing Evaluation Store Typings Safety Notes References Computational Effects Also known as side effects. A function or expression is said to have a side effect if,
More informationStanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016
Stanford Developing Applications for ios Today Memory Management for Reference Types Controlling when things leave the heap Closure Capture Closures capture things into the heap too Extensions A simple,
More informationITP 342 Mobile App Dev. Animation
ITP 342 Mobile App Dev Animation Core Animation Introduced in Mac OS X Leopard Uses animatable "layers" built on OpenGL UIKit supports Core Animation out of the box Every UIView has a CALayer behind it
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 informationPRO SWIFT BOOK AND VIDEOS M A S E. Break out of beginner s Swift. with this hands-on guide
PRO SWIFT BOOK AND VIDEOS Break out of beginner s Swift E L P with this hands-on guide M A S E E Paul Hudson R F Chapter 1 Syntax Wendy Lu (@wendyluwho), ios engineer at Pinterest Use final on properties
More informationJSJS - Project Proposal
JSJS - Project Proposal A general purpose, strongly typed programming language for the web Jain Bahul Srivastav Prakhar Jain Ayush Sadekar Gaurang bkj2111 ps2894 aj2672 gss2147 Description JSJS is a strongly
More informationA Type is Worth a Thousand Tests
A Type is Worth a Thousand Tests Manuel M T Chakravarty Applicative & Tweag I/O mchakravarty TacticalGrace justtesting.org haskellformac.com Let s talk about Let s talk about Swift Let s talk about Language
More informationLecture 4: Higher Order Functions
Lecture 4: Higher Order Functions Søren Haagerup Department of Mathematics and Computer Science University of Southern Denmark, Odense September 26, 2017 HIGHER ORDER FUNCTIONS The order of a function
More informationIntroduction to Swift. Dr. Sarah Abraham
Introduction to Swift Dr. Sarah Abraham University of Texas at Austin CS329e Fall 2018 What is Swift? Programming language for developing OSX, ios, WatchOS, and TvOS applications Best of C and Objective-C
More informationSome notes about Event-B and Rodin
Some notes about Event-B and Rodin Résumé This document briefly presents the language event-b and the tool Rodin. For a comprehensive presentation, refer to the event-b page http://www.event-b.org/, the
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 informationAn experiment with variable binding, denotational semantics, and logical relations in Coq. Adam Chlipala University of California, Berkeley
A Certified TypePreserving Compiler from Lambda Calculus to Assembly Language An experiment with variable binding, denotational semantics, and logical relations in Coq Adam Chlipala University of California,
More informationStanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017
Stanford Developing Applications for ios Today Timer Periodically execute a block of code Blinking FaceIt Demo Animation Animating changes to UIViews Smoother Blinking FaceIt Head-shaking FaceIt Animating
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 informationApplicative, traversable, foldable
Applicative, traversable, foldable Advanced functional programming - Lecture 3 Wouter Swierstra 1 Beyond the monad So far, we have seen how monads define a common abstraction over many programming patterns.
More informationCSCI-GA Scripting Languages
CSCI-GA.3033.003 Scripting Languages 12/02/2013 OCaml 1 Acknowledgement The material on these slides is based on notes provided by Dexter Kozen. 2 About OCaml A functional programming language All computation
More informationCategorical models of type theory
1 / 59 Categorical models of type theory Michael Shulman February 28, 2012 2 / 59 Outline 1 Type theory and category theory 2 Categorical type constructors 3 Dependent types and display maps 4 Fibrations
More informationfunctional programming in Python, part 2
Programming Languages Week 2 functional programming in Python, part 2 College of Information Science and Engineering Ritsumeikan University review of part 1 eliminating assignment makes programs easier
More informationCOMP-520 GoLite Tutorial
COMP-520 GoLite Tutorial Alexander Krolik Sable Lab McGill University Winter 2019 Plan Target languages Language constructs, emphasis on special cases General execution semantics Declarations Types Statements
More informationTopics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited
CMSC 330: Organization of Programming Languages Type Systems, Names & Binding Topics Covered Thus Far Programming languages Syntax specification Regular expressions Context free grammars Implementation
More informationOn the Recognizability of Arrow and Graph Languages
On the Recognizability of Arrow and Graph Languages Christoph Blume Sander Bruggink Barbara König Universität Duisburg-Essen, Germany Background Applications of finite automata and regular (word) languages
More information1c) (iv) and (v) OR (v) only (hindsight showed that the question was more ambiguous than intended)
Answers to 2008/2009 G52CFJ exam Below are the answers to last year s exam, so that you can check how you did. In many cases I have given an example answer and an idea of what elements we would look for.
More informationCategory Theory. & Functional Data Abstraction. Brandon Shapiro. Math 100b
& Functional Data Abstraction Math 100b Categories A category C is a collection of objects with arrows (often called morphisms) pointing between them Hom C (X, Y ) is the set of morphisms in C from X to
More informationThe Truth about Types. Bartosz Milewski
The Truth about Types Bartosz Milewski Truth Truth Logic Types Categories Truth intro Unit type Terminal object true I () : () Proofs Logic Types Categories Proof of proposition A Type A is inhabited Morphism
More informationCOMS 1003 Fall Introduction to Computer Programming in C. Bits, Boolean Logic & Discrete Math. September 13 th
COMS 1003 Fall 2005 Introduction to Computer Programming in C Bits, Boolean Logic & Discrete Math September 13 th Hello World! Logistics See the website: http://www.cs.columbia.edu/~locasto/ Course Web
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Type Systems, Names and Binding CMSC 330 - Spring 2013 1 Topics Covered Thus Far! Programming languages Ruby OCaml! Syntax specification Regular expressions
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 informationIntroduction to Homotopy Type Theory
Introduction to Homotopy Type Theory Lecture notes for a course at EWSCS 2017 Thorsten Altenkirch March 5, 2017 1 What is this course about? To explain what Homotopy Type Theory is, I will first talk about
More informationLeinster s globular theory of weak -categories
Leinster s globular theory of weak -categories Ed Morehouse April 16, 2014 (last updated August 8, 2014) These are my notes for a series of lectures that I gave at the Homotopy Type Theory seminar at Carnegie
More informationMore Lambda Calculus and Intro to Type Systems
More Lambda Calculus and Intro to Type Systems Plan Heavy Class Participation Thus, wake up! Lambda Calculus How is it related to real life? Encodings Fixed points Type Systems Overview Static, Dyamic
More informationFunctional Languages. Hwansoo Han
Functional Languages Hwansoo Han Historical Origins Imperative and functional models Alan Turing, Alonzo Church, Stephen Kleene, Emil Post, etc. ~1930s Different formalizations of the notion of an algorithm
More informationObject-Oriented Programming
iuliana@cs.ubbcluj.ro Babes-Bolyai University 2018 Overview 1 2 3 4 5 6 7 I No beard, no belly, no guru... Ken Thompson (B), Dennis Ritchie (C) - UNIX Bjarne Stroustrup (C++) James Gosling (Java) Figure:
More information\n is used in a string to indicate the newline character. An expression produces data. The simplest expression
Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of
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 informationCOALGEBRAIC MODELS FOR COMBINATORIAL MODEL CATEGORIES
COALGEBRAIC MODELS FOR COMBINATORIAL MODEL CATEGORIES MICHAEL CHING AND EMILY RIEHL Abstract. We show that the category of algebraically cofibrant objects in a combinatorial and simplicial model category
More informationLast time: generic programming
1/ 55 Last time: generic programming val (=) : { D: DATA } D. t D. t bool 2/ 55 This time: monads etc., continued >>= effect E 3/ 55 Recap: monads, bind and let An imperative program let id =! counter
More informationACLT: Algebra, Categories, Logic in Topology - Grothendieck's generalized topological spaces (toposes)
ACLT: Algebra, Categories, Logic in Topology - Grothendieck's generalized topological spaces (toposes) Steve Vickers CS Theory Group Birmingham 1. Sheaves "Sheaf = continuous set-valued map" TACL Tutorial
More informationProgramming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture 04 Programs with IO and Loop We will now discuss the module 2,
More informationCom S 541. Programming Languages I
Programming Languages I Lecturer: TA: Markus Lumpe Department of Computer Science 113 Atanasoff Hall http://www.cs.iastate.edu/~lumpe/coms541.html TR 12:40-2, W 5 Pramod Bhanu Rama Rao Office hours: TR
More informationCONTROL AND HIGHER ORDER FUNCTIONS 1
CONTROL AND HIGHER ORDER FUNCTIONS 1 COMPUTER SCIENCE 61A January 29, 2015 1 Control Control structures direct the flow of logic in a program. For example, conditionals allow a program to skip sections
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 informationSWIFT BASICS
SWIFT BASICS jhkim@dit.ac.kr www.facebook.com/jhkim3217 2014. 7. 19 Reference Swift Guide, 2014 AppCode.com Swift Tutorial: A Quick Start, Ray Wenderlich background new programming language for ios, OS
More informationMetrics on diagrams and persistent homology
Background Categorical ph Relative ph More structure Department of Mathematics Cleveland State University p.bubenik@csuohio.edu http://academic.csuohio.edu/bubenik_p/ July 18, 2013 joint work with Vin
More informationENGR 102 Engineering Lab I - Computation
ENGR 102 Engineering Lab I - Computation Learning Objectives by Week 1 ENGR 102 Engineering Lab I Computation 2 Credits 2. Introduction to the design and development of computer applications for engineers;
More informationIndex. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309
A Arithmetic operation floating-point arithmetic, 11 12 integer numbers, 9 11 Arrays, 97 copying, 59 60 creation, 48 elements, 48 empty arrays and vectors, 57 58 executable program, 49 expressions, 48
More informationRecap: Functions as first-class values
Recap: Functions as first-class values Arguments, return values, bindings What are the benefits? Parameterized, similar functions (e.g. Testers) Creating, (Returning) Functions Iterator, Accumul, Reuse
More informationAbram Hindle Kitchener Waterloo Perl Monger October 19, 2006
OCaml Tutorial Abram Hindle Kitchener Waterloo Perl Monger http://kw.pm.org abez@abez.ca October 19, 2006 Abram Hindle 1 OCaml Functional Language Multiple paradigms: Imperative, Functional, Object Oriented
More informationFunctional Programming and Haskell
Functional Programming and Haskell Tim Dawborn University of Sydney, Australia School of Information Technologies Tim Dawborn Functional Programming and Haskell 1/22 What are Programming Paradigms? A programming
More informationMonads. Prof. Clarkson Fall Today s music: Vámanos Pal Monte by Eddie Palmieri
Monads Prof. Clarkson Fall 2017 Today s music: Vámanos Pal Monte by Eddie Palmieri Review Currently in 3110: Advanced topics Futures: Async: deferreds, return, bind Today: Monads Monad tutorials since
More informationFor your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to
For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to access them. Contents at a Glance About the Author...
More informationCS 242. Fundamentals. Reading: See last slide
CS 242 Fundamentals Reading: See last slide Syntax and Semantics of Programs Syntax The symbols used to write a program Semantics The actions that occur when a program is executed Programming language
More informationTopos Theory. Lectures 3-4: Categorical preliminaries II. Olivia Caramello. Topos Theory. Olivia Caramello. Basic categorical constructions
Lectures 3-4: Categorical preliminaries II 2 / 17 Functor categories Definition Let C and D be two categories. The functor category [C,D] is the category having as objects the functors C D and as arrows
More informationProgrammazione Avanzata
Programmazione Avanzata Programmazione Avanzata Corso di Laurea in Informatica (L31) Scuola di Scienze e Tecnologie Programmazione Avanzata 1 / 51 Programming paradigms Programmazione Avanzata Corso di
More informationCollege Functors, Applicatives
College 2016-2017 Functors, Applicatives Wouter Swierstra with a bit of Jurriaan Hage Utrecht University Contents So far, we have seen monads define a common abstraction over many programming patterns.
More informationCIS 194: Homework 3. Due Wednesday, February 11, Interpreters. Meet SImPL
CIS 194: Homework 3 Due Wednesday, February 11, 2015 Interpreters An interpreter is a program that takes another program as an input and evaluates it. Many modern languages such as Java 1, Javascript,
More informationIntroduction to Concepts in Functional Programming. CS16: Introduction to Data Structures & Algorithms Spring 2017
Introduction to Concepts in Functional Programming CS16: Introduction to Data Structures & Algorithms Spring 2017 Outline Functions State Functions as building blocks Higher order functions Map Reduce
More informationMore Lambda Calculus and Intro to Type Systems
More Lambda Calculus and Intro to Type Systems #1 One Slide Summary The lambda calculus is a model of computation or a programming language that is as expressive as a Turing machine. The lambda calculus
More informationFunctions and Collections. Dr. Sarah Abraham
Functions and Collections Dr. Sarah Abraham University of Texas at Austin CS329e Fall 2016 Functions Self-contained chunks of code to perform a specific task Function name is called in order to perform
More informationIndex. Cambridge University Press Functional Programming Using F# Michael R. Hansen and Hans Rischel. Index.
(),23 (*,3 ->,3,32 *,11 *),3.[...], 27, 186 //,3 ///,3 ::, 71, 80 :=, 182 ;, 179 ;;,1 @, 79, 80 @"...",26 >,38,35
More informationPLT Fall Shoo. Language Reference Manual
PLT Fall 2018 Shoo Language Reference Manual Claire Adams (cba2126) Samurdha Jayasinghe (sj2564) Rebekah Kim (rmk2160) Cindy Le (xl2738) Crystal Ren (cr2833) October 14, 2018 Contents 1 Comments 2 1.1
More informationAnnouncements. Lecture Agenda. Class Exercise. Hashable. Mutability. COMP10001 Foundations of Computing Iteration
COMP10001 Foundations of Computing Iteration Announcements Semester 1, 2017 Tim Baldwin & Egemen Tanin First Guest Lecture on Friday (examinable) Grok Worksheets 5 7 due at the end of this week version:
More informationCSCE 314 Programming Languages Functors, Applicatives, and Monads
CSCE 314 Programming Languages Functors, Applicatives, and Monads Dr. Hyunyoung Lee 1 Motivation Generic Functions A common programming pattern can be abstracted out as a definition. For example: inc ::
More informationThe essence of dataflow programming. Teooriapäevad Kokel 2,
The essence of dataflow programming Tarmo UUSTALU Varmo VENE Teooriapäevad Kokel 2, 4.-6.2.2005 Motivation Following Moggi and Wadler, it is standard in programming and semantics to analyze various notions
More informationCMSC 330: Organization of Programming Languages. Ownership, References, and Lifetimes in Rust
CMSC 330: Organization of Programming Languages Ownership, References, and Lifetimes in Rust CMSC330 Spring 2018 1 Memory: the Stack and the Heap The stack constant-time, automatic (de)allocation Data
More information