Download presentation
Presentation is loading. Please wait.
Published byAnissa Black Modified over 9 years ago
1
600.429 FUNCTIONAL PROGRAMING AT WORK - HASKELL AND DOMAIN SPECIFIC LANGUAGES Dr. John Peterson Western State Colorado University
2
Project Pitch Let’s talk! I’ll set up wiki accounts tonight Good things: A well defined scope that allows an incremental approach Pre-existing infrastructure A compositional point of view (building-block pieces + combining functions) Novel semantic foundation (reactive programming, for example)
3
Quiz 4 Advantages / disadvantages of Haskell embedding Euterpea expressions that are the same in Euterpea but not Haskell. Why does this matter? What is the semantic model of Euterpea? What does a parser know that a grammar doesn’t?
4
Homework 5 http://wiki.western.edu/mcis/index.php/429/W eek_5
5
HW5 Project Organization Phase 1: a parsec parser that converts strings to tokens Create a data type for lexemes Drop whitespace Group characters for variables / numbers Represent indentation at the start of a line Don’t worry about error reporting Test before proceeding!
6
HW5 Phase 2 Deal with layout (indentation): Map a list of tokens that includes indentation to a list that drops indentation and replaces it with a new token, End Probably don’t need to use parsec Need to know all outer indentation levels (list of int will work)
7
Phase 2 Strategy Line indented more than current level Line indented at current level Line indented less than current level How do we recognize a new level? Assume all blocks have at least one statement Ignore blank lines in lexer
8
Phase 3 Strategy Use “End” to mark line end and block end Should look like grammar Use “try” for backtracking. Where do we need to worry about backtracking?
9
Questions?
10
Haskell Modules Modules – group a set of names in a file. Strictly a renaming construct – deals with visibility only. Use modules to encapsulate functionality – like ast.hs You can do selective export (export lists) or import (import lists) Hierarchical namespace uses “.”
11
Applicative and Functor http://hackage.haskell.org/packages/archive/ba se/latest/doc/html/Data-Functor.html#v:-60-- 36--62- http://hackage.haskell.org/packages/archive/ba se/latest/doc/html/Control-Applicative.html#v:- 42--62- What do these infix operators do for parsers?
12
Inside parsec See http://hackage.haskell.org/package/parsechttp://hackage.haskell.org/package/parsec Let’s look at “Char”, “Combinator”, and “Prim” How can we make combinators similar to those in Char with an arbitrary token stream type?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.