A Modular Package Language for Haskell
|
|
- Emma Kelly
- 5 years ago
- Views:
Transcription
1 A Modular Package Language for Haskell Scott Kilpatrick MPI-SWS Joint work with: Derek Dreyer (MPI-SWS) Simon Marlow (Microsoft Research) Simon Peyton Jones (Microsoft Research) University of Pennsylvania 28 November 2012
2 Haskell Packages Today... 2
3 Modules Organize Code unit of programming & reasoning Data/Set.hs module Data.Set where data Set a =... add s x = GHC Haskell compiler; compiles modules access other mods code via importing Foo.hs module Foo where import Data.Set data T =... Set... foo x y =... add... 3
4 Packages Organize Modules unit of distribution & authorship alicelib.cabal name: alicelib version: 1.0 build-depends: data == 2.* exposed-modules: Alice use names & versions to track package dependencies Alice.hs module Alice where import Data.Set <code> Cabal package specification and tool suite for building/ distributing packages 4
5 Building Packages alicelib.cabal name: alicelib version: 1.0 build-depends: data == 2.* exposed-modules: Alice data == 2.* data Alice.hs module Alice where import Data.Set <code> Ingrid 5
6 Four weaknesses: 6
7 Problem #1: Uncheckable alicelib.cabal name: alicelib version: 1.0 build-depends: data == 2.* exposed-modules: Alice Alice.hs module Alice where import Data.Set <code> Alice must build data to type check Alice.hs Builds, say, data-2.1 But Ingrid picked 2.4! Informal policy re: version numbers and types Hoping, not checking 7
8 Problem #2: Linear Development alicelib boblib Pkgs must be created in dependency order alicelib, then boblib, then carollib carollib 8
9 Problem #2: Linear Development alicelib impl s Alice API Pkgs must be created in dependency order alicelib, then boblib, boblib impl s Bob API then carollib Program against APIs Develop in any order carollib Link together in the end 9
10 Problem #2: Linear Development Alice.hs module Alice where x = 5 impl s Alice API x :: Int Bob.hs module Bob where import Alice y = iszero x impl s Bob API y :: Bool incremental vs. separate compilation Carol.hs module Carol where import Bob z = not y 10
11 Problem #3: Too Inflexible data-2.* qc-2.* public private alicelib-2.0 data >= 2 && < 4 public boblib-1.0 qc-3.* private Ingrid wants carollib public public carollib-0.0 Ingrid 11
12 Problem #3: Too Inflexible data-2.* data >= 2 && < 4 alicelib-2.0 qc-2.* boblib-1.0 qc-3.* Ingrid wants carollib Cabal requires single version for all depend s Can satisfy data constraints but not qc carollib-0.0 Ingrid Cabal naively complains Code would be fine if Cabal considered types 12
13 Problem #4: Weak Reusability Ingrid alicelib-1.0 Ingrid.hs module Ingrid where import Alice import Data3.0Stuff <code> Ingrid uses alicelib and data-3.0 together Can t satisfy dependency But Alice code would also work with data-3.0 data-2.* data-3.0 data-2.* dependency was too limiting! 13
14 Diagnosis: Informal APIs boblib.cabal name: boblib version: 1.0 build-depends: data >= 2 && < 4 qc == 3.*... I 2 I 1 Package name and version range form an API! Informal, intended API No formal checking 14
15 Packages Need Interfaces! 15
16 Using Mixins Packages are mixin modules Namespaces containing defined and undefined components, each with name and interface Link together by name to fill in components Permits recursive linking * based on MixML [Dreyer and Rossberg, ICFP 2008] 16
17 Mixin Solution package data-2-sigs where Data.Set :: [ data Socket];... package alicelib-1.0 where include data-2-sigs; Alice = import Data.Set <code> dependency abstracted over an interface, not a name and version range use structural matching to link in anything that provides a compatible Data.Set 17
18 Contributions Package language and type system based on mixins Introduces proper abstraction of dependencies Offers greater flexibility, checkability, reuse Largely agnostic to underlying language 18
19 Outline 1. Introduction 2. Language features 3. Semantics 4. The rest 19
20 Package Definitions and Bindings package threemods where A = [First.hs]; B = [Second.hs]; C = B Defines package with 3 bindings (2 distinct mods) Separates file names from bindings names -- First.hs x = 5 -- Second.hs import A y = x + 5 Binding order explicit Earlier bindings bound in the context of later ones 20
21 Signatures (Holes) package onehole where A :: [Sig.hsig]; B = [Other.hs] Signatures are abstract mods; defined eventually Variable references look like defined mods -- Sig.hsig x :: Int only static info -- Other.hs import A y = x + 5 But someone must eventually impl them! Package definition encapsulates holes; others instantiate them 21
22 Package Dependencies package twomods where A = [First.hs]; B = [Second.hs] package threeagain where include twomods; C = B include injects bindings into present namespace Realizes dependencies Gets both mods & holes Included bindings merge with explicit bindings All part of this package 22
23 Linking Bindings Link/merge bindings by name Unifies compatible module components Performs linking, not shadowing Three cases when linking two components with same name: mod/mod mod/sig sig/sig 23
24 mod/mod Linking package top where Top = [T.hs] package left where include top; Left = [L.hs] package right where include top; Right = [R.hs] package bottom where include left; include right; Bottom = [B.hs] unifies identical* Top modules from left and right * identity discussed later 24
25 sig/sig Linking package mylib where View :: [JustX.hsig];... x :: Int package yourlib where View :: [JustY.hsig];... y :: Bool package ourlib where include mylib; within mylib, View has x :: Int include yourlib; yourlib, y :: Bool... ourlib, { x :: Int y :: Bool unifies View sigs into glb sig 25
26 mod/sig Linking package httplib where Socket :: [ ]; HTTP =... data Socket new :: () -> Socket package socketlib where Socket = [ ] data Socket = MkS Int new _ = MkS 4 package main where include socketlib; include httplib checks that the mod matches the sig 26
27 Outline 1. Introduction 2. Language features 3. Semantics 4. The rest 27
28 Module Identity Each module is given an identity Parameterized by identities of imports Captures dependency graph package mod import graph identities package idents where A = [1.hs]; B = [2.hs]; C = [3.hs]; D = C; A C B D ν A #(1.hs) ν B #(2.hs) ν A ν C #(3.hs) ν A ν B ν D ν C 28
29 Applicative Identities Distinguish instantiations of modules Share identical instantiations Permit multiple instantiations in one package package onehole where A :: [ x :: Int ]; B = [Other.hs] ν B #(Other.hs) α A, for α A = ν impl1, ν impl2,... 29
30 Type Representation Need to know when types equivalent! module where import A (T) gett :: () -> T module where import B (T) putt :: T -> ()... putt (gett ())... T = T?? 30
31 Type Representation Today, Haskell types represented as GHC.Types.Bool defining module s name syntactic constructor We represent types similarly [ν]bool defining module s semantic identity syntactic constructor 31
32 package httpd where Socket :: [ ]; Server = [ ] data T import Socket(T) data Conn = MkConn T package yourlib where include httpd; include socket-1.0 package mylib where include httpd; include socket-1.0 package main where A = include yourlib ; B = include mylib ; Main = [ ] import A.Server(Conn) import B.Server(Conn)... only one Conn type: [#(Server.hs) ν Sock1.0 ]Conn 32
33 package httpd where Socket :: [ ]; Server = [ ] data T import Socket(T) data Conn = MkConn T package yourlib where include httpd; include socket-1.0 package mylib where include httpd; include socket-1.5 package main where A = include yourlib ; B = include mylib ; Main = [ ] import A.Server(Conn) import B.Server(Conn)... two distinct Server identities two distinct Conn types: [#(Server.hs) ν Sock1.0 ]Conn [#(Server.hs) ν Sock1.5 ]Conn 33
34 Elaboration Package specifications/tools are too weak Our language improves those weaknesses and offers a translation down into the ordinary Haskell modules packages with interfaces elaboration plain Haskell modules GHC compilation 34
35 Elaboration Idea: Create a mod file for each identity Rewrite logical imports to hard links Similar to C++ template expansion Soundness (Conjecture!): Well-typed package elaborates to a set of import-closed, well-typed Haskell modules 35
36 Elaboration package httpd where Socket :: [ ]; Server = [ ] data T import Socket(T) data Conn = MkConn T α module data T where module #(Server.hs) α where import α (T) data Conn = MkConn T a GHC boot file imports are rewritten to access semantic hard links 36
37 Elaboration package main where A = include yourlib ; B = include mylib ; Main = [ ] import A.Server(Conn) import B.Server(Conn) from Socket1.0 module ν 1.0 where data T = module #(Server.hs) ν 1.0 import ν 1.0 (T) data Conn = MkConn T where module #(Main.hs) (#(Server.hs) ν 1.0 )(#(Server.hs) ν 1.0 ) import #(Server.hs) ν 1.0 (Conn) import #(Server.hs) ν 1.0 (Conn)... Socket impl, single Server instance, and Main importing it (x2) where 37
38 Elaboration package main where A = include yourlib ; B = include mylib ; Main = [ ] import A.Server(Conn) import B.Server(Conn)... module import import from Socket1.0 module ν 1.0 where data T = from Socket1.5 module ν 1.5 where data T = module #(Server.hs) ν 1.0 where module #(Server.hs) ν 1.5 import ν 1.0 (T) import ν 1.5 (T) data Conn = MkConn T data Conn = MkConn T #(Main.hs) (#(Server.hs) ν 1.0 )(#(Server.hs) ν 1.5 ) #(Server.hs) ν 1.0 #(Server.hs) ν 1.5 (Conn) (Conn) where source file for Server duplicated where the two distinct Conn types are clear 38
39 Outline 1. Introduction 2. Language features 3. Semantics 4. The rest 39
40 Not Covered Haskell type classes Mixins vs. functors Package thinning Recursion within/between packages Type checking and specification 40
41 Conclusion Today s untyped pkgs suffer weaknesses Pkgs benefit from typed module system Abstract over dependencies Clean elaboration into ordinary source files 41
42 Conclusion Today s untyped pkgs suffer weaknesses Pkgs benefit from typed module system Abstract over dependencies Clean elaboration into ordinary source files Thanks! 41
43 Backup Slides 42
44 Why Not (ML) Modules? Different model of program modularity Pkg lang encapsulates entire Haskell progs: Core lang terms are whole Haskell modules Core lang types are whole Haskell signatures val x : int = 3 ( ) signature where val M : data T = y :: T ( ) module where data T = MkT Int y = MkT 5 43
45 Why Not (ML) Modules? Could represent packages with functors With dependencies as functor params mylib-1.0 fun( ){ ( )} B : BASESIG4, val Mine = Q : QCSIG2 module where import B.Prelude... 44
46 Why Not (ML) Modules? Need dependencies to agree on things Functors require verbose sharing specs! How to avoid that? fun( B : BASESIG4, *) { } M : MYLIBSIG,... Y : YRLIBSIG * s.t. B = (base of M) = (base of Y) 45
47 Thinning Use thinning to filter packages, P only p At defn site, expose only public modules At use site, get only desired mods from pkg containers = mylib = filters out Tree Set =...; Tree =... include (containers only Set); Foo = [...Set...] filters out Set only Foo 46
48 Closer Look at Thinning We can t ignore holes via thinning! Forms partition on pkg s dep. graph 1. Directly desired modules 2. Indirectly desired modules (trans. closure) 3. Irrelevant modules Discard the irrelevant stuff 47
49 Closer Look at Thinning containers = include basesig; Set = [...Prelude...]; include arraysig; Graph = [...Array...] inherits an Array hole from arraysig; Graph uses that hole foolib = foolib : include containers; Foo = [...Set...] Prelude Set Array Graph Foo hole def d hole def d def d Foo doesn t need Graph, but still clients must provide Array! 48
50 Closer Look at Thinning containers = include basesig; Set = [...Prelude...]; include arraysig; Graph = [...Array...] : Prelude Set Array Graph hole def d hole def d containers only Set necessary desired irrelevant Prelude Set Array Graph : Prelude Set hole def d foolib = include (containers only Set); Foo = [...Set...] : Prelude Set Foo hole def d def d 49
51 Semantics Static semantics based on MixML s New additions: Module identities / stamps Initial static shaping pass 50
52 Pkg Shaping Type checking for pkg s structure only Performs no GHC type checking Determines dep. graph of all entities Necessary for recursive modules But handled differently in MixML 51
53 Judgments Typing Γ; Σ E :Σ Shaping Γ sh E : α.(l; Σ) Thinning }} \ (L; Ξ) only p (L p ; Ξ ); ν ; p 52
54 MixML Linking { R } { } { } R L 1 locates α 1 R 1 # Σ 2 Γ; R R 1 L 1 ; β 1 mod 1 : Σ 1 L 2 locates α 2 R 2 # Σ 1 Γ, X: Σ 1 ; R R 2 L 2 ; β 2 stat mod 2 : Σ 2 (L 1 ; Σ 1 ) (L 2 ; Σ 2) δ α 1, α 2 fresh Γ, X: δσ 1 ; R R 2 δl 2 ; β 2 mod 2 : Σ 2 δσ 1 + Σ 2 Σ Γ; R R 1 R 2 ; β 1, β 2 (X = mod 1 ) with mod 2 : Σ (LINK) 53
55 Related Work SMLSC [Swasey et al., ML 2006] Package impls and package interfaces Unify dependencies when linking Nix [Dolstra et al.] Packages as a functional language, but untyped 54
Mixin Up the ML Module System
Mixin Up the ML Module System Derek Dreyer and Andreas Rossberg Max Planck Institute for Software Systems Saarbrücken, Germany ICFP 2008 Victoria, British Columbia September 24, 2008 The ML Module System
More informationSimple Unification-based Type Inference for GADTs
Simple Unification-based Type Inference for GADTs Stephanie Weirich University of Pennsylvania joint work with Dimitrios Vytiniotis, Simon Peyton Jones and Geoffrey Washburn Overview Goal: Add GADTs to
More informationDerek Dreyer. WG2.8 Meeting, Iceland July 16-20, 2007
Why Applicative Functors Matter Derek Dreyer Toyota Technological Institute at Chicago WG2.8 Meeting, Iceland July 16-20, 2007 Matthias Felleisen Gets In a Good Jab Matthias Felleisen, POPL PC Chair report,
More informationArbitrary-rank polymorphism in (GHC) Haskell
Arbitrary-rank polymorphism in (GHC) Haskell CAS 743 Stephen Forrest 20 March 2006 Damas-Milner Type System A Damas-Milner type system (also called Hindley-Milner) is a traditional type system for functional
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 informationChapter 5: Procedural abstraction. Function procedures. Function procedures. Proper procedures and function procedures
Chapter 5: Procedural abstraction Proper procedures and function procedures Abstraction in programming enables distinction: What a program unit does How a program unit works This enables separation of
More informationTYPE INFERENCE. François Pottier. The Programming Languages Mentoring ICFP August 30, 2015
TYPE INFERENCE François Pottier The Programming Languages Mentoring Workshop @ ICFP August 30, 2015 What is type inference? What is the type of this OCaml function? let f verbose msg = if verbose then
More informationF-ing Applicative Functors
F-ing Applicative Functors Andreas Rossberg, Google Claudio Russo, MSR Derek Dreyer, MPI-SWS ML Workshop, Copenhagen 2012/09/13 The Functor Schism The Functor Schism SML: generative functors return fresh
More informationCalculus INT. Value Types A, B ::= types of the low-level language Interactive Types X, Y ::= [A] A X X Y A X
Calculus INT Calculus INT Value Types A, B ::= types of the low-level language Interactive Types X, Y ::= [A] A X X Y A X X Y α A. X α A. X Related: Call-by-Push-Value [Levy 2004] Enrichted Effect Calculus
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 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 informationLecture #23: Conversion and Type Inference
Lecture #23: Conversion and Type Inference Administrivia. Due date for Project #2 moved to midnight tonight. Midterm mean 20, median 21 (my expectation: 17.5). Last modified: Fri Oct 20 10:46:40 2006 CS164:
More informationConversion vs. Subtyping. Lecture #23: Conversion and Type Inference. Integer Conversions. Conversions: Implicit vs. Explicit. Object x = "Hello";
Lecture #23: Conversion and Type Inference Administrivia. Due date for Project #2 moved to midnight tonight. Midterm mean 20, median 21 (my expectation: 17.5). In Java, this is legal: Object x = "Hello";
More informationTopics Covered Thus Far CMSC 330: Organization of Programming Languages
Topics Covered Thus Far CMSC 330: Organization of Programming Languages Names & Binding, Type Systems Programming languages Ruby Ocaml Lambda calculus Syntax specification Regular expressions Context free
More informationLecture #13: Type Inference and Unification. Typing In the Language ML. Type Inference. Doing Type Inference
Lecture #13: Type Inference and Unification Typing In the Language ML Examples from the language ML: fun map f [] = [] map f (a :: y) = (f a) :: (map f y) fun reduce f init [] = init reduce f init (a ::
More informationAdding GADTs to OCaml the direct approach
Adding GADTs to OCaml the direct approach Jacques Garrigue & Jacques Le Normand Nagoya University / LexiFi (Paris) https://sites.google.com/site/ocamlgadt/ Garrigue & Le Normand Adding GADTs to OCaml 1
More informationINF 212 ANALYSIS OF PROG. LANGS Type Systems. Instructors: Crista Lopes Copyright Instructors.
INF 212 ANALYSIS OF PROG. LANGS Type Systems Instructors: Crista Lopes Copyright Instructors. What is a Data Type? A type is a collection of computational entities that share some common property Programming
More informationFirst-Class Type Classes
First-Class Type Classes Matthieu Sozeau Joint work with Nicolas Oury LRI, Univ. Paris-Sud - Démons Team & INRIA Saclay - ProVal Project Gallium Seminar November 3rd 2008 INRIA Rocquencourt Solutions for
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Operational Semantics CMSC 330 Summer 2018 1 Formal Semantics of a Prog. Lang. Mathematical description of the meaning of programs written in that language
More informationSimon Peyton Jones Microsoft Research August 2013
Simon Peyton Jones Microsoft Research August 2013 reverse :: a. [a] -> [a] xs :: [Bool] foo :: [Bool] foo = reverse xs Instantiate reverse with a unification variable, standing for an as-yet-unknown type.
More informationDependent types and program equivalence. Stephanie Weirich, University of Pennsylvania with Limin Jia, Jianzhou Zhao, and Vilhelm Sjöberg
Dependent types and program equivalence Stephanie Weirich, University of Pennsylvania with Limin Jia, Jianzhou Zhao, and Vilhelm Sjöberg Doing dependent types wrong without going wrong Stephanie Weirich,
More informationl e t print_name r = p r i n t _ e n d l i n e ( Name : ^ r. name)
Chapter 8 Row polymorphism Consider the following code: type name_home = {name : s t r i n g ; home : s t r i n g } type name_mobile = {name : s t r i n g ; mobile : s t r i n g } l e t jane = {name =
More informationObject-Oriented Design
Object-Oriented Design Lecture 14: Design Workflow Department of Computer Engineering Sharif University of Technology 1 UP iterations and workflow Workflows Requirements Analysis Phases Inception Elaboration
More informationThesis Proposal: Effective Type Theory for Modularity
Thesis Proposal: Effective Type Theory for Modularity Derek Dreyer November 21, 2002 School of Computer Science Carnegie Mellon University Pittsburgh, PA 15213 Thesis Committee Robert Harper (co-chair)
More informationOCaml Data CMSC 330: Organization of Programming Languages. User Defined Types. Variation: Shapes in Java
OCaml Data : Organization of Programming Languages OCaml 4 Data Types & Modules So far, we ve seen the following kinds of data Basic types (int, float, char, string) Lists Ø One kind of data structure
More informationAgenda. CS301 Session 11. Common type constructors. Things we could add to Impcore. Discussion: midterm exam - take-home or inclass?
Agenda CS301 Session 11 Discussion: midterm exam - take-home or inclass? Interlude: common type constructors Type soundness 1 2 Things we could add to Impcore Common type constructors Array is a type constructor,
More informationVariables. Substitution
Variables Elements of Programming Languages Lecture 4: Variables, binding and substitution James Cheney University of Edinburgh October 6, 2015 A variable is a symbol that can stand for another expression.
More informationModules Matter Most. Robert Harper Carnegie Mellon University. MacQueen Fest Chicago May 2012
Modules Matter Most Robert Harper Carnegie Mellon University MacQueen Fest Chicago May 2012 Thanks... to the organizers for organizing this meeting.... to Dave for being an inspiration to and influence
More informationDependent types and program equivalence. Stephanie Weirich, University of Pennsylvania with Limin Jia, Jianzhou Zhao, and Vilhelm Sjöberg
Dependent types and program equivalence Stephanie Weirich, University of Pennsylvania with Limin Jia, Jianzhou Zhao, and Vilhelm Sjöberg What are dependent types? Types that depend on values of other types
More informationFlang typechecker Due: February 27, 2015
CMSC 22610 Winter 2015 Implementation of Computer Languages I Flang typechecker Due: February 27, 2015 Project 3 February 9, 2015 1 Introduction The third project is to implement a type checker for Flang,
More informationTracing Ambiguity in GADT Type Inference
Tracing Ambiguity in GADT Type Inference ML Workshop 2012, Copenhagen Jacques Garrigue & Didier Rémy Nagoya University / INRIA Garrigue & Rémy Tracing ambiguity 1 Generalized Algebraic Datatypes Algebraic
More informationPattern Matching and Abstract Data Types
Pattern Matching and Abstract Data Types Tom Murphy VII 3 Dec 2002 0-0 Outline Problem Setup Views ( Views: A Way For Pattern Matching To Cohabit With Data Abstraction, Wadler, 1986) Active Patterns (
More informationModular Type Classes
Modular Type Classes Derek Dreyer Toyota Technological Institute at Chicago dreyer@tti-c.org Robert Harper Carnegie Mellon University rwh@cs.cmu.edu Manuel M.T. Chakravarty University of New South Wales
More informationCSCE 314 Programming Languages. Type System
CSCE 314 Programming Languages Type System Dr. Hyunyoung Lee 1 Names Names refer to different kinds of entities in programs, such as variables, functions, classes, templates, modules,.... Names can be
More informationCOS 320. Compiling Techniques
Topic 5: Types COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 Types: potential benefits (I) 2 For programmers: help to eliminate common programming mistakes, particularly
More informationGeneric polymorphism on steroids
Generic polymorphism on steroids or How to Solve the Expression Problem with Polymorphic Variants Claudio Sacerdoti Coen Dipartimento di Informatica Scienza e Ingegneria
More informationINF 212/CS 253 Type Systems. Instructors: Harry Xu Crista Lopes
INF 212/CS 253 Type Systems Instructors: Harry Xu Crista Lopes What is a Data Type? A type is a collection of computational entities that share some common property Programming languages are designed to
More informationAdding a Module System to Java
Adding a Module System to Java Rok Strniša Computer Laboratory, University of Cambridge Email: Rok.Strnisa@cl.cam.ac.uk URL: http://www.cl.cam.ac.uk/~rs456/ May 8, 2008 @ The British Computer Society Joint
More informationNews. CSE 130: Programming Languages. Environments & Closures. Functions are first-class values. Recap: Functions as first-class values
CSE 130: Programming Languages Environments & Closures News PA 3 due THIS Friday (5/1) Midterm NEXT Friday (5/8) Ranjit Jhala UC San Diego Recap: Functions as first-class values Arguments, return values,
More informationModular Programming. Prof. Clarkson Fall Today s music: "Giorgio By Moroder" by Daft Punk
Modular Programming Prof. Clarkson Fall 2017 Today s music: "Giorgio By Moroder" by Daft Punk Moog modular synthesizer Based in Trumansburg, NY, 1953-1971 Game changing! picked up by the Beatles, the Rolling
More informationCS558 Programming Languages
CS558 Programming Languages Fall 2016 Lecture 3a Andrew Tolmach Portland State University 1994-2016 Formal Semantics Goal: rigorous and unambiguous definition in terms of a wellunderstood formalism (e.g.
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 - 43 Dynamic Binding (Polymorphism): Part III Welcome to Module
More informationERC 4th Workshop KAIST. Sukyoung Ryu KAIST. August 26, 2010
ERC 4th Workshop Sukyoung Ryu August 26, 2010 : Members Coq Mechanization of Basic Core Fortress for Type Soundness Adding Pattern Matching to Existing Object- Oriented Languages FortressCheck: Automatic
More informationCS558 Programming Languages
CS558 Programming Languages Winter 2017 Lecture 4a Andrew Tolmach Portland State University 1994-2017 Semantics and Erroneous Programs Important part of language specification is distinguishing valid from
More informationLambda Calculus and Type Inference
Lambda Calculus and Type Inference Björn Lisper Dept. of Computer Science and Engineering Mälardalen University bjorn.lisper@mdh.se http://www.idt.mdh.se/ blr/ August 17, 2007 Lambda Calculus and Type
More informationExpansion statements. Version history. Introduction. Basic usage
Expansion statements Version history Document: P1306R0 Revises: P0589R0 Date: 08 10 2018 Audience: EWG Authors: Andrew Sutton (asutton@uakron.edu) Sam Goodrick (sgoodrick@lock3software.com) Daveed Vandevoorde
More informationTyped Scheme: Scheme with Static Types
Typed Scheme: Scheme with Static Types Version 4.1.1 Sam Tobin-Hochstadt October 5, 2008 Typed Scheme is a Scheme-like language, with a type system that supports common Scheme programming idioms. Explicit
More informationOutline. What is semantics? Denotational semantics. Semantics of naming. What is semantics? 2 / 21
Semantics 1 / 21 Outline What is semantics? Denotational semantics Semantics of naming What is semantics? 2 / 21 What is the meaning of a program? Recall: aspects of a language syntax: the structure of
More informationGADTs meet Subtyping
GADTs meet Subtyping Gabriel Scherer, Didier Rémy Gallium INRIA 2014 Gabriel Scherer, Didier Rémy (Gallium INRIA) GADTs meet Subtyping 2014 1 / 21 A reminder on GADTs GADTs are algebraic data types that
More informationWhere is ML type inference headed?
1 Constraint solving meets local shape inference September 2005 2 Types are good A type is a concise description of the behavior of a program fragment. Typechecking provides safety or security guarantees.
More informationVariables and Bindings
Net: Variables Variables and Bindings Q: How to use variables in ML? Q: How to assign to a variable? # let = 2+2;; val : int = 4 let = e;; Bind the value of epression e to the variable Variables and Bindings
More informationOnce Upon a Polymorphic Type
Once Upon a Polymorphic Type Keith Wansbrough Computer Laboratory University of Cambridge kw217@cl.cam.ac.uk http://www.cl.cam.ac.uk/users/kw217/ Simon Peyton Jones Microsoft Research Cambridge 20 January,
More informationA Separate Compilation Extension to Standard ML (Revised and Expanded)
A Separate Compilation Extension to Standard ML (Revised and Expanded) David Swasey Tom Murphy VII Karl Crary Robert Harper September 17, 2006 CMU-CS-06-104R School of Computer Science Carnegie Mellon
More informationPart VI. Imperative Functional Programming
Part VI Imperative Functional Programming Chapter 14 Mutable Storage MinML is said to be a pure language because the execution model consists entirely of evaluating an expression for its value. ML is
More information3.4 Data-Centric workflow
3.4 Data-Centric workflow One of the most important activities in a S-DWH environment is represented by data integration of different and heterogeneous sources. The process of extract, transform, and load
More informationCS Computable Functions. Reading: Chapter 2
CS 242 2012 Computable Functions Reading: Chapter 2 Foundations: Partial,Total Functions Value of an expression may be undefined Undefined operation, e.g., division by zero 3/0 has no value implementation
More informationλ calculus is inconsistent
Content Rough timeline COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Gerwin Klein, June Andronick, Toby Murray λ Intro & motivation, getting started [1] Foundations & Principles
More informationGoal. CS152: Programming Languages. Lecture 15 Parametric Polymorphism. What the Library Likes. What The Client Likes. Start simpler.
Goal Understand what this interface means and why it matters: CS152: Programming Languages Lecture 15 Parametric Polymorphism Dan Grossman Spring 2011 type a mylist; val mt_list : a mylist val cons : a
More informationLife in a Post-Functional World
Life in a Post-Functional World Definitions Functional Programming Definitions Functional Programming Programming with functions! Definitions Functional Programming Programming with functions! Functions
More informationMeta-programming with Names and Necessity p.1
Meta-programming with Names and Necessity Aleksandar Nanevski Carnegie Mellon University ICFP, Pittsburgh, 05 October 2002 Meta-programming with Names and Necessity p.1 Meta-programming Manipulation of
More informationCMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics
Recall Architecture of Compilers, Interpreters CMSC 330: Organization of Programming Languages Source Scanner Parser Static Analyzer Operational Semantics Intermediate Representation Front End Back End
More information(Refer Slide Time: 4:00)
Principles of Programming Languages Dr. S. Arun Kumar Department of Computer Science & Engineering Indian Institute of Technology, Delhi Lecture - 38 Meanings Let us look at abstracts namely functional
More informationCOMP 181. Agenda. Midterm topics. Today: type checking. Purpose of types. Type errors. Type checking
Agenda COMP 181 Type checking October 21, 2009 Next week OOPSLA: Object-oriented Programming Systems Languages and Applications One of the top PL conferences Monday (Oct 26 th ) In-class midterm Review
More informationMulti-paradigm Declarative Languages
Michael Hanus (CAU Kiel) Multi-paradigm Declarative Languages ICLP 2007 1 Multi-paradigm Declarative Languages Michael Hanus Christian-Albrechts-University of Kiel Programming Languages and Compiler Construction
More informationTypes. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus
Types Type checking What is a type? The notion varies from language to language Consensus A set of values A set of operations on those values Classes are one instantiation of the modern notion of type
More informationExtended Static Checking for Haskell (ESC/Haskell)
Extended Static Checking for Haskell (ESC/Haskell) Dana N. Xu University of Cambridge advised by Simon Peyton Jones Microsoft Research, Cambridge Program Errors Give Headache! Module UserPgm where f ::
More informationSome instance messages and methods
Some instance messages and methods x ^x y ^y movedx: dx Dy: dy x
More informationLR Parsing LALR Parser Generators
LR Parsing LALR Parser Generators Outline Review of bottom-up parsing Computing the parsing DFA Using parser generators 2 Bottom-up Parsing (Review) A bottom-up parser rewrites the input string to the
More informationOverview. Elements of Programming Languages. Advanced constructs. Motivating inner class example
Overview Elements of Programming Languages Lecture 11: Object-oriented functional programming James Cheney University of Edinburgh October 30, 2017 We ve now covered: basics of functional programming (with
More informationContractive Signatures with Recursive Types, Type Parameters, and Abstract Types
Contractive Signatures with Recursive Types, Type Parameters, and Abstract Types Hyeonseung Im 1, Keiko Nakata 2, and Sungwoo Park 3 1 LRI - Université Paris-Sud 11, Orsay, France 2 Institute of Cybernetics
More informationProgramming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC http://courses.engr.illinois.edu/cs421 Based in part on slides by Mattox Beckman, as updated by Vikram Adve and Gul Agha 10/3/17
More informationTwo approaches to writing interfaces
Two approaches to writing interfaces Interface projected from implementation: No separate interface Compiler extracts from implementation (CLU, Java class, Haskell) When code changes, must extract again
More informationCOMP 4161 NICTA Advanced Course. Advanced Topics in Software Verification. Toby Murray, June Andronick, Gerwin Klein
COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Toby Murray, June Andronick, Gerwin Klein λ 1 Last time... λ calculus syntax free variables, substitution β reduction α and η conversion
More informationModular Module Systems: a survey
Modular Module Systems: a survey Christopher League LIU Brooklyn Northeast Scala Symposium 9 March 2012 Miran Lipovača, Learn You a Haskell for Great Good! http://learnyouahaskell.com/ (By-NC-SA) What
More informationCSE-321: Assignment 8 (100 points)
CSE-321: Assignment 8 (100 points) gla@postech.ac.kr Welcome to the final assignment of CSE-321! In this assignment, you will implement a type reconstruction algorithm (the algorithm W discussed in class)
More informationSemantics of programming languages
Semantics of programming languages Informatics 2A: Lecture 27 John Longley School of Informatics University of Edinburgh jrl@inf.ed.ac.uk 21 November, 2011 1 / 19 1 2 3 4 2 / 19 Semantics for programming
More informationWhidbey Enhancements to C# Jeff Vaughan MSBuild Team July 21, 2004
Whidbey Enhancements to C# Jeff Vaughan MSBuild Team July 21, 2004 Outline Practical Partial types Static classes Extern and the namespace alias qualifier Cool (and practical too) Generics Nullable Types
More informationOverview. Declarative Languages D7012E. Overloading. Overloading Polymorphism Subtyping
Overview Declarative Languages D7012E Lecture 4: The Haskell type system Fredrik Bengtsson / Johan Nordlander Overloading & polymorphism Type classes instances of type classes derived type classes Type
More informationCompilers and computer architecture: Semantic analysis
1 / 1 Compilers and computer architecture: Semantic analysis Martin Berger Alex Jeffery October 2018 Recall the function of compilers 2 / 1 3 / 1 Recall the structure of compilers Source program Lexical
More informationMMT Objects. Florian Rabe. Computer Science, Jacobs University, Bremen, Germany
MMT Objects Florian Rabe Computer Science, Jacobs University, Bremen, Germany Abstract Mmt is a mathematical knowledge representation language, whose object layer is strongly inspired by OpenMath. In fact,
More informationOne of a number of approaches to a mathematical challenge at the time (1930): Constructibility
λ Calculus Church s λ Calculus: Brief History One of a number of approaches to a mathematical challenge at the time (1930): Constructibility (What does it mean for an object, e.g. a natural number, to
More informationType-indexed functions in Generic Haskell
Type-indexed functions in Generic Haskell Johan Jeuring September 15, 2004 Introduction Today I will talk about: a Types of polymorphism. b Type-indexed functions. c Dependencies. Read about b, and c in
More informationFeatherweight Scala. Week 14
Featherweight Scala Week 14 1 Today Previously: Featherweight Java Today: Featherweight Scala Live research, unlike what you have seen so far. Focus today on path-dependent types Plan: 1. Rationale 2.
More informationOBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe
OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++
More informationAdvances in Programming Languages
T O Y H Advances in Programming Languages APL8: Multiparameter Type Classes, Constructor Classes Ian Stark School of Informatics The University of Edinburgh Thursday 4 February Semester 2 Week 4 E H U
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 informationGADTs. Wouter Swierstra. Advanced functional programming - Lecture 7. Faculty of Science Information and Computing Sciences
GADTs Advanced functional programming - Lecture 7 Wouter Swierstra 1 Today s lecture Generalized algebraic data types (GADTs) 2 A datatype data Tree a = Leaf Node (Tree a) a (Tree a) This definition introduces:
More informationCSE341: Programming Languages Lecture 7 First-Class Functions. Dan Grossman Winter 2013
CSE341: Programming Languages Lecture 7 First-Class Functions Dan Grossman Winter 2013 What is functional programming? Functional programming can mean a few different things: 1. Avoiding mutation in most/all
More informationCSE 307: Principles of Programming Languages
CSE 307: Principles of Programming Languages Variables and Constants R. Sekar 1 / 22 Topics 2 / 22 Variables and Constants Variables are stored in memory, whereas constants need not be. Value of variables
More informationPolymorphism and Type Inference
Polymorphism and Type Inference Volker Stolz stolz@ifi.uio.no INF 3110-2008 Department of Informatics University of Oslo Initially by Gerardo Schneider. Based on John C. Mitchell s slides (Stanford U.)
More informationCSE341, Fall 2011, Lecture 12 Summary
CSE341, Fall 2011, Lecture 12 Summary Standard Disclaimer: This lecture summary is not necessarily a complete substitute for atting class, reading the associated code, etc. It is dened to be a useful resource
More informationJOURNAL OF OBJECT TECHNOLOGY
JOURNAL OF OBJECT TECHNOLOGY Online at http://www.jot.fm. Published by ETH Zurich, Chair of Software Engineering JOT, 2005 Vol. 4, No. 5, July - August 2005 The Theory of Classification Part 19: The Proliferation
More information4 Bindings and Scope. Bindings and environments. Scope, block structure, and visibility. Declarations. Blocks. 2004, D.A. Watt, University of Glasgow
4 Bindings and Scope Bindings and environments. Scope, block structure, and visibility. Declarations. Blocks. 2004, D.A. Watt, University of Glasgow 1 Bindings and environments PL expressions and commands
More informationCS11 Introduction to C++ Fall Lecture 7
CS11 Introduction to C++ Fall 2012-2013 Lecture 7 Computer Strategy Game n Want to write a turn-based strategy game for the computer n Need different kinds of units for the game Different capabilities,
More informationFirst-class modules: hidden power and tantalizing promises
First-class modules: hidden power and tantalizing promises to GADTs and beyond Jeremy Yallop Applicative Ltd Oleg Kiselyov ML 2010 ACM SIGPLAN Workshop on ML September 26, 2010 Honestly there was no collusion
More informationSNU Programming Language Theory
SNU 4541.574 Programming Language Theory Polymorphism Polymorphism We encountered the concept of polymorphism very briefly last time. Let s look at it now in a bit more detail. # let rec last l = match
More informationProgramming Language Features. CMSC 330: Organization of Programming Languages. Turing Completeness. Turing Machine.
CMSC 330: Organization of Programming Languages Lambda Calculus Programming Language Features Many features exist simply for convenience Multi-argument functions foo ( a, b, c ) Ø Use currying or tuples
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Lambda Calculus CMSC 330 1 Programming Language Features Many features exist simply for convenience Multi-argument functions foo ( a, b, c ) Ø Use currying
More informationLecture 21: Red-Black Trees
15-150 Lecture 21: Red-Black Trees Lecture by Dan Licata April 3, 2012 Last time, we talked about the signature for dictionaries: signature ORDERED = sig type t val compare : t * t -> order signature DICT
More informationQualified Types for MLF
Qualified Types for MLF Daan Leijen Andres Löh Institute of Information and Computing Sciences, Utrecht University PO Box 80089, 3508 TB Utrecht, The Netherlands {daan,andres}@csuunl Abstract MLF is a
More information