600.429 FUNCTIONAL PROGRAMING AT WORK - HASKELL AND DOMAIN SPECIFIC LANGUAGES Dr. John Peterson Western State Colorado University.

Slides:



Advertisements
Similar presentations
Functional Image Synthesis. Pan An image synthesis “language” Images are functions Continuous and infinite Embedded in a functional host language Reusable.
Advertisements

8. Introduction to Denotational Semantics. © O. Nierstrasz PS — Denotational Semantics 8.2 Roadmap Overview:  Syntax and Semantics  Semantics of Expressions.
DSLs: The Good, the Bad, and the Ugly Kathleen Fisher AT&T Labs Research.
Presented by: Thabet Kacem Spring Outline Contributions Introduction Proposed Approach Related Work Reconception of ADLs XTEAM Tool Chain Discussion.
1/18 CS 693/793 Lecture 09 Special Topics in Domain Specific Languages CS 693/793-1C Spring 2004 Mo, We, Fr 10:10 – 11:00 CH 430.
13. Summary, Trends, Research. © O. Nierstrasz PS — Summary, Trends, Research Summary, Trends, Research...  Summary: functional, logic and object-oriented.
1 Semantic Processing. 2 Contents Introduction Introduction A Simple Compiler A Simple Compiler Scanning – Theory and Practice Scanning – Theory and Practice.
Reference Book: Modern Compiler Design by Grune, Bal, Jacobs and Langendoen Wiley 2000.
The Structure of the GNAT Compiler. A target-independent Ada95 front-end for GCC Ada components C components SyntaxSemExpandgigiGCC AST Annotated AST.
12. Summary, Trends, Research. © O. Nierstrasz PS — Summary, Trends, Research Roadmap  Summary: —Trends in programming paradigms  Research:...
On the Correctness of Model Transformations Gabor Karsai ISIS/Vanderbilt University.
Tim Sheard Oregon Graduate Institute Lecture 11: A Reduction Semantics for MetaML CS510 Section FSC Winter 2005 Winter 2005.
1 Dan Quinlan, Markus Schordan, Qing Yi Center for Applied Scientific Computing Lawrence Livermore National Laboratory Semantic-Driven Parallelization.
Chapter 2 A Simple Compiler
How domain specific are Domain Specific Languages? Greg Michaelson School of Mathematical & Computer Sciences Heriot-Watt University.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Lecture 2 Phases of Compiler. Preprocessors, Compilers, Assemblers, and Linkers Preprocessor Compiler Assembler Linker Skeletal Source Program Source.
ANTLR.
INF5110: Mandatory Exercise 2 Eyvind W. Axelsen @eyvindwa Slides are partly based on.
Sumant Tambe, et. al LEESA DSPD 2008 An Embedded Declarative Language for Hierarchical Object Structure Traversal Sumant Tambe* Aniruddha Gokhale Vanderbilt.
C++ Code Analysis: an Open Architecture for the Verification of Coding Rules Paolo Tonella ITC-irst, Centro per la Ricerca Scientifica e Tecnologica
Sumant Tambe, et. al LEESA DSPD 2008 An Embedded Declarative Language for Hierarchical Object Structure Traversal Sumant Tambe* Aniruddha Gokhale Vanderbilt.
Comp 311 Principles of Programming Languages Lecture 1 Course Overview and Culture Corky Cartwright August 25, 2008.
COP4020 Programming Languages
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
1 History of compiler development 1953 IBM develops the 701 EDPM (Electronic Data Processing Machine), the first general purpose computer, built as a “defense.
{ Graphite Grigory Arashkovich, Anuj Khanna, Anirban Gangopadhyay, Michael D’Egidio, Laura Willson.
CSC 338: Compiler design and implementation
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 2.
SaveUML System design. System overview Possible...
A Little Language for Surveys: Constructing an Internal DSL in Ruby H. Conrad Cunningham Computer and Information Science University of Mississippi.
1.  10% Assignments/ class participation  10% Pop Quizzes  05% Attendance  25% Mid Term  50% Final Term 2.
INRIA - LaBRICharles Consel Jan-06 1 Domain-Specific Software Engineering Charles Consel Phoenix Research Group LaBRI /INRIA-Futurs January 2006.
High Integrity Ada in a UML and C world Peter Amey, Neil White Presented by Liping Cai.
1. 2 Preface In the time since the 1986 edition of this book, the world of compiler design has changed significantly 3.
Introduction to Compilers. Related Area Programming languages Machine architecture Language theory Algorithms Data structures Operating systems Software.
Semantics for DSL Group Members: Ritu Arora, Diyang Chu, Zekai Demirezen, Jeff Gray, Jacob Gulotta, Luis Pedro, Arturo Sanchez, Greg Sullivan,Ximing Yu.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
Chapter 1 Introduction Study Goals: Master: the phases of a compiler Understand: what is a compiler Know: interpreter,compiler structure.
Compilers: Overview/1 1 Compiler Structures Objective – –what are the main features (structures) in a compiler? , Semester 1,
Weaving a Debugging Aspect into Domain-Specific Language Grammars SAC ’05 PSC Track Santa Fe, New Mexico USA March 17, 2005 Hui Wu, Jeff Gray, Marjan Mernik,
Chapter 1: Introduction 1 Compiler Designs and Constructions Chapter 1: Introduction Objectives: Course Objectives Introduction Dr. Mohsen Chitsaz.
A compiler is a computer program that translate written code (source code) into another computer language Associated with high level languages A well.
What am I? while b != 0 if a > b a := a − b else b := b − a return a AST == Abstract Syntax Tree.
Advanced Software Development Karl Lieberherr CSG 260 Fall Semester
C H A P T E R T W O Linking Syntax And Semantics Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
CSCE 314 Programming Languages
Interpreters and Higher-Order Functions CSE 413 Autumn 2008 Credit: CSE341 notes by Dan Grossman.
CSC 4181 Compiler Construction
CISC105 – General Computer Science Class 4 – 06/14/2006.
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
ICS312 Introduction to Compilers Set 23. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
Reading Exercise 0 Discussion. Imperative vs Declarative A.Prolog, SQL, Perl B.ML, Lisp, SQL C.C, Java,Smalltalk D.C#, Haskell, Spreadsheets E.C++, Eiffel,
Programming Languages Concepts Chapter 1: Programming Languages Concepts Lecture # 4.
Concepts of Programming Languages Lecturer: Dr. Emad Nabil Lecture # 2.
Open Source Compiler Construction (for the JVM)
Advanced Computer Systems
PRINCIPLES OF COMPILER DESIGN
Overview of Compilation The Compiler Front End
History of compiler development
Introduction to Compiler Construction
Compiler Construction
Syntax-Directed Translation
Types and Type Checking (What is it good for?)
A programming language
MDT OCL 1.3 Mini-deck June 10, 2009.
Introduction to Compiler Construction
Parsing with IRONY Roman Ivantsov, MCSD
Compiler Structures 1. Overview Objective
Presentation transcript:

FUNCTIONAL PROGRAMING AT WORK - HASKELL AND DOMAIN SPECIFIC LANGUAGES Dr. John Peterson Western State Colorado University

Homework 4 It’s up – we’ll discuss it soon! I even added it to Blackboard :-) Don’t delay in installing Euterpea – there seem to be Mac issues. You can work on the assignment even if it’s not installed. There will be a turn-in later this week to kick off the DSL implementation project. Come talk to me about projects. Talk to other students about teaming up.

Domain Specific Languages What is a DSL? How do we build them? How is a DSL different from an API? Why is Haskell a good vehicle for DSLs?

DSL Design Space Front end: how do we express programs in this language? Custom: write a parser / preprocessor Embedded: add vocabulary to an existing language. Use language extension constructs (special syntax, overloading, monads)

DSL Design Space How do we express the semantics of the language? Embedded: within the host language, often augmented by libraries Translated: generate code in a different language (usually source code)

DSL Correctness No correctness issues beyond those in the embedded part of the language. The type vocabulary is embedded in standard Haskell Custom type checking – the type system of the DSL requires a user-written type checker Extended types – the type system requires extensions to the Haskell type system

Haskell Evaluation and the DSL How does the lambda in Haskell relate to the DSL? It doesn’t – the language has a custom syntax and there is no Lambda in the language Integrated – the Haskell lambda calculus is part of the evaluation mechanism in the language Expanded – the language doesn’t have lambda in its semantics; the lambdas in the input are expanded away (lambda as “cpp”)

DSL Semantics How are semantic properties expressed or used? Embedded in Haskell semantics As rewrite rules – domain specific rewrites augment ordinary equational reasoning Custom – program semantics are not related to Haskell at all Custom Functional – as above, except that the underlying lambda calculus reasoning is valid

DSL Design Space Program Transformation None – the program is run “as written” Lambda calculus – transformations are possible in the “lambda” part of the language Tree rewrite – domain-specific rules are applied to the program in an AST (Abstract Syntax Tree) for optimization or code generation

Euterpea – A Music DSL See the reading for documentation. Note that this teaches Haskell as well as the music language. This language has two components: a note level and a sound level. We’ll work at the note level for now.

Overview Syntax: embedded in standard Haskell Code generation: programs are compiled to Midi files Semantics: the book discusses the difference between the Haskell level of the semantics and the music level but the implementation does not rely on these semantics Semantics: theses are “custom” - not related to Haskell Types: embedded in the Haskell type system Lambda: expanded away Transformation: programs are transformed to MIDI semantics during code generation

A Simple DSL Formula Start with domain-specific objects (musical notes) as data declarations Add domain-specific combinators (:+: and :=:) and transformations (transpose, instrument) Write utilities which make the language easier to use (note, rest) Add an interpretation function (play) which creates values in the underlying domain (midi files) – this makes use of transformations that are validated by domain-level semantics

Code Time Off to Haskell!