CPM: A Declarative Package Manager with Semantic Versioning

Similar documents
Combining Static and Dynamic Contract Checking for Curry

Multi-paradigm Declarative Languages

Declarative Programming with Function Patterns

CPM User s Manual. Institut für Informatik, CAU Kiel, Germany. January 17, Introduction 2. 4 Package Basics 4

Overlapping Rules and Logic Variables in Functional Logic Programs

Functional Logic Programming Language Curry

Declaring Numbers. Bernd Braßel, Frank Huch and Sebastian Fischer. Department of Computer Science, University of Kiel, Germany

Extended Static Checking for Haskell (ESC/Haskell)

Functional Logic Design Patterns

Declarative Multi-paradigm Programming

Concolic Testing of Functional Logic Programs

Multi-paradigm Declarative Languages

Static Contract Checking for Haskell

Haskell: From Basic to Advanced. Part 2 Type Classes, Laziness, IO, Modules

Haskell Introduction Lists Other Structures Data Structures. Haskell Introduction. Mark Snyder

Functional Logic Programming: From Theory to Curry

Default Rules for Curry

Haske k ll An introduction to Functional functional programming using Haskell Purely Lazy Example: QuickSort in Java Example: QuickSort in Haskell

A Package Manager for Curry

An introduction introduction to functional functional programming programming using usin Haskell

Functional Logic Programming. Kristjan Vedel

QuickCheck, SmallCheck & Reach: Automated Testing in Haskell. Tom Shackell

CSCE 314 TAMU Fall CSCE 314: Programming Languages Dr. Flemming Andersen. Haskell Functions

Declarative Programming with Function Patterns

Functional Programming in Haskell Part 2 : Abstract dataypes and infinite structures

Adding Constraint Handling Rules to Curry Extended Abstract

Reasoning about programs. Chapter 9 of Thompson

Property-Based Testing for Coq. Cătălin Hrițcu

CSCE 314 TAMU Fall CSCE 314: Programming Languages Dr. Flemming Andersen. Haskell Basics

Lambda Calculus and Type Inference

Lecture 8: Summary of Haskell course + Type Level Programming

CS-XXX: Graduate Programming Languages. Lecture 9 Simply Typed Lambda Calculus. Dan Grossman 2012

PROGRAMMING IN HASKELL. CS Chapter 6 - Recursive Functions

Vector Clocks in Coq

High-Level Server Side Web Scripting in

The Worker/Wrapper Transformation

A Modular and Generic Analysis Server System for Functional Logic Programs

Implementing Equational Constraints in a Functional Language

n n Try tutorial on front page to get started! n spring13/ n Stack Overflow!

Lecture 19: Functions, Types and Data Structures in Haskell

CITS3211 FUNCTIONAL PROGRAMMING

CSCI-GA Final Exam

Declarative Multi-Paradigm Programming in

Source-Based Trace Exploration Work in Progress

Repetition Structures

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.

Fall 2018 Lecture N

Shell CSCE 314 TAMU. Functions continued

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

CSC312 Principles of Programming Languages : Functional Programming Language. Copyright 2006 The McGraw-Hill Companies, Inc.

Shell CSCE 314 TAMU. Haskell Functions

Introduction to Haskell

Introduction to the Lambda Calculus

Functional Programming. Overview. Topics. Recall λ-terms. Examples

ESC/Java2 Use and Features

Chapter 5. Pure PROLOG. Foundations of Logic Programming

Exercise 1 ( = 24 points)

Programming Languages Fall 2013

Functional Programming

CS 11 Haskell track: lecture 1

ESC/Java2 Use and Features

Adding Plural Arguments to Curry Programs

Transforming Functional Logic Programs into Monadic Functional Programs

Functional Programming and Haskell

3. Functional Programming. Oscar Nierstrasz

D7020E. The dynamic evolution of a system Robust and Energy-Efficient Real-Time Systems. blocked Lecture 2: Components & the Timber language.

D7020E. Robust and Energy-Efficient Real-Time Systems D7020E. Lecture 2: Components & the Timber language

Combining Proofs and Programs in a Dependently Typed Language. Certification of High-level and Low-level Programs

Lambda Calculus and Type Inference

The design of a programming language for provably correct programs: success and failure

Functional Logic Programming

Lecture 5: Lazy Evaluation and Infinite Data Structures

GADTs. GADTs in Haskell

CITS3211 FUNCTIONAL PROGRAMMING. 7. Lazy evaluation and infinite lists

IA014: Advanced Functional Programming

Curry without Success

Programming Up-to-Congruence, Again. WG 2.8 Estes Park

An introduction to functional programming. July 23, 2010

Haskell through HUGS THE BASICS

CS 457/557: Functional Languages

COMP4161: Advanced Topics in Software Verification. fun. Gerwin Klein, June Andronick, Ramana Kumar S2/2016. data61.csiro.au

Type checking by theorem proving in IDRIS

COMP80 Lambda Calculus Programming Languages Slides Courtesy of Prof. Sam Guyer Tufts University Computer Science History Big ideas Examples:

Background Type Classes (1B) Young Won Lim 6/28/18

CSc 372 Comparative Programming Languages

5. Introduction to the Lambda Calculus. Oscar Nierstrasz

Systematic Generation of Glass-Box Test Cases for Functional Logic Programs

CSc 372. Comparative Programming Languages. 8 : Haskell Function Examples. Department of Computer Science University of Arizona

Haskell Overview II (2A) Young Won Lim 8/9/16

Specification, Verification, and Interactive Proof

Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science

CS 440: Programming Languages and Translators, Spring 2019 Mon

The Worker/Wrapper Transformation

Semantic Versioning for.net libraries and NuGet packages (C#/F#) MF#K November

CSCE 314 Programming Languages

Haskell Overview III (3A) Young Won Lim 10/4/16

Talen en Compilers. Jurriaan Hage , period 2. November 13, Department of Information and Computing Sciences Utrecht University

Basic Foundations of Isabelle/HOL

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011

Transcription:

Michael Hanus (CAU Kiel) CPM: A Declarative Package Manager with Semantic Versioning CICLOPS 2017 1 CPM: A Declarative Package Manager with Semantic Versioning Michael Hanus University of Kiel Programming Languages and Compiler Construction CICLOPS 2017 Joint work with Jonas Oberschweiber

Contemporary software systems are complex! Michael Hanus (CAU Kiel) CPM: A Declarative Package Manager with Semantic Versioning CICLOPS 2017 2 Software packages as building blocks several modules with well-defined APIs evolve over time (efficiency improvements, new functionality) versioning with version numbers (1.4.3) Package dependencies Package A depends on: package B version 1.2.5 < 2.0.0 package C version 2.3.7 < 4.0.0 Semantic versioning: <major>.<minor>.<patch> Version numbers describe semantic properties: alternative implementation increase <patch> extend API increase <minor> change API increase <major>

Semantic Versioning (www.semver.org) Michael Hanus (CAU Kiel) CPM: A Declarative Package Manager with Semantic Versioning CICLOPS 2017 3 Advantages describe necessary dependencies choose appropriate packages ( package manager) upgrade to newer versions without code breaks Requirements Packages with identical <major> must be semantically compatible Semantic compatibility important to support automatic upgrading not checked in contemporary package managers Our proposal: check it automatically with property-based test tools

Property-based Testing Michael Hanus (CAU Kiel) CPM: A Declarative Package Manager with Semantic Versioning CICLOPS 2017 4 Properties tests parameterized over some arguments no side effects repeatable tests generate input values: random (QuickCheck, PrologCheck, PropEr) systematic enumeration (SmallCheck, GAST) systematic (non-deterministic) guessing (EasyCheck, CurryCheck) Here: Curry (Haskell syntax, logic features) + CurryCheck [LOPSTR 16] List concatenation is associative [] ++ ys = ys (x:xs) ++ ys = x : (xs ++ ys) concisassociative xs ys zs = (xs++ys) ++zs < > xs++(ys++zs)

Property-based Testing with CurryCheck Michael Hanus (CAU Kiel) CPM: A Declarative Package Manager with Semantic Versioning CICLOPS 2017 5 Non-deterministic list insertion ins :: a [a] [a] ins x ys = x : ys ins x (y:ys) = y : ins x ys > ins0[1,2] [0,1,2]? [1,0,2]? [1,2,0] Property: insertion increments list length inslength x xs = length (ins x xs) < > length xs + 1 Set-based interpretation relevant: e 1 < > e 2 : e 1 and e 2 have identical sets of results

Semantic Versioning Checking Idea: f defined in module M of some package in versions v 1 and v 2 : 1 create renamed modules M v 1 and M v 2 2 create new comparison module: import qualified M v 1 import qualified M v 2 check_m_f x = M_v 1.f x < > M_v 2.f x 3 run CurryCheck on this module Problems: f defined on (package) local data types generate bijective type mapping, use it in check M f f might not terminate: use termination analysis no check or specific check for productive operations Michael Hanus (CAU Kiel) CPM: A Declarative Package Manager with Semantic Versioning CICLOPS 2017 6

Productive Operations Lazy languages supports infinite data structures: ints :: Int [Int] ints2 :: Int [Int] ints n = n : ints (n+1) ints2 n = n : ints2 (n+2) ints 0 0 : 1 : 2 :... ints2 0 0 : 2 : 4 :... -- Equivalence testing: checkints x = ints x < > ints2 x no counter example... Non-terminating but productive operations f productive no infinite reduction without producing root-constructors ints, ints2: productive loop n = loop (n+1) -- not productive Michael Hanus (CAU Kiel) CPM: A Declarative Package Manager with Semantic Versioning CICLOPS 2017 7

Checking Productive Operations Michael Hanus (CAU Kiel) CPM: A Declarative Package Manager with Semantic Versioning CICLOPS 2017 8 Limit the size of values data Nat = Z S Nat -- Peano numbers limlist :: Nat [Int] [Int] limlist Z _ = [] limlist (S n) [] = [] limlist (S n) (x:xs) = x : limlist n xs Checking with size limits limcheckints n x = limlist n (ints x) < > limlist n (ints2 x) CurryCheck finds counter-example: n=(s (S Z)) x=1 Proposition [ICLP 17]: Limited equivalence checking is sound and complete (for total operations) for equivalence checking.

CPM: Curry Package Manager tool to distribute and install Curry software packages central package index (currently: > 50 packages, > 400 modules) package: Curry modules + package specification: metadata in JSON format standard fields: version number, author, name, synopsis,... dependency constraints: "B" : ">= 2.0.0, < 3.0.0 > 4.1.0" depends on package B with major version 2 or in a version greater than 4.1.0 Some CPM commands cpm update download newest version of package index cpm search search in package index cpm install installs a package (resolve all dependency constraints) with local copies of all required packages cpm upgrade re-install with newer package versions cpm test run CurryCheck on all source modules Michael Hanus (CAU Kiel) CPM: A Declarative Package Manager with Semantic Versioning CICLOPS 2017 9

CPM: Semantic Versioning Checking cpm diff 1.2.4 check current package version against 1.2.4 Implementation of semantic versioning checking rename modules with version numbers generate comparison module analyze each operation defined in two package versions: terminating: use standard equivalence check non-terminating but productive: use equivalence checks with limits generate limit operations for each data type otherwise: no check, warning program analysis implemented with CASS [PEPM 14] Curry prelude: 126 operations Analysis result: 112 terminating, 11 productive, 3 non-terminating Michael Hanus (CAU Kiel) CPM: A Declarative Package Manager with Semantic Versioning CICLOPS 2017 10

CPM: Semantic Versioning Checking Michael Hanus (CAU Kiel) CPM: A Declarative Package Manager with Semantic Versioning CICLOPS 2017 11 User annotations to override analysis results: Annotate terminating operations {-# TERMINATE -#} mccarthy n = if n<=100 then mccarthy (mccarthy (n+11)) else n-10 Annotate productive operations {-# PRODUCTIVE -#} primes = sieve (ints 2) where sieve (p:xs) = p : sieve (filter (λx mod x p > 0) xs) Annotate unchecked operations {-# NOCOMPARE -#} f... =... code with bug fixes...

Conclusions Michael Hanus (CAU Kiel) CPM: A Declarative Package Manager with Semantic Versioning CICLOPS 2017 12 CPM: Curry Package Manager first package manager with semantic versioning checker (Elm package manager: purely syntactic API comparison) termination important for automatic tool program analysis productivity: check also non-terminating operations (data generators) supports specification-based software development package n.0.0 contains specification [PADL 12] newer package versions: better implementations approach applicable to all kinds of declarative languages functional (QuickCheck), logic (PrologCheck), functional-logic (CurryCheck),... Future work: better termination analysis avoid testing: check structural equivalence of source code use theorem provers to proof equivalence