Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "600.429 FUNCTIONAL PROGRAMING AT WORK - HASKELL AND DOMAIN SPECIFIC LANGUAGES Dr. John Peterson Western State Colorado University."— Presentation transcript:

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

2 Project Pitches Let’s Go!

3 Expression Parsing Parsec Library: data Assoc = AssocNone | AssocLeft | AssocRight data Operator tok st a = Infix (GenParser tok st (a -> a -> a)) Assoc | Prefix (GenParser tok st (a -> a)) | Postfix (GenParser tok st (a -> a)) type OperatorTable tok st a = [[Operator tok st a]]

4 Homework 6 Questions? No homework this week – I’ll give you extra time on the current one. I expect you to start with background research, coding, or other project-related activities.

5 FRP, Behaviors, and Events Event a Denotes an event stream. Each occurrence delivers value of type a keyboard :: Event Char Behavior a Denotes a continuously available value of type a mouse :: Behavior Point2

6 Classic FRP Operations lift0 :: a -> Behavior a lift1 :: (a -> b) -> Behavior a -> Behavior b hold :: a -> Event a -> Behavior a when :: Behavior Bool -> Event () snap :: Event a -> Behavior b -> Event b (-=>) :: Event b -> a -> Event a tags :: Event b -> [a] -> Event a (.|.) :: Event a -> Event a -> Event a switch :: Behavior a -> Event (Behavior a) -> Behavior a integral :: Behavior Double -> Behavior Double clock :: Double -> Event Double once :: Event a -> Event a

7 Laws of FRP Single value: signals have only one value at each time step Evaluation order independence: the update order at each time step is non-observable Purity: Identical signals initialized at the same time have the same value Convergence: continuous signals should converge to an “ideal value” as time steps decrease Immediacy: computations should not be delayed to a later time step

8 Dark Corners Event clashes in.|. The.|. operator can’t handle simultaneous events Running behaviors Impossible to observe a previously initialized behavior Dynamic interfaces Fixed set of GUI objects to interact with Dynamic collections We needed new primitives to implement “space invaders” Time leaks Stateful signals not yet demanded

9 Examples in Python Taken from the Western Computer Camp

10 Examples http://haskell.cs.yale.edu/wp- content/uploads/2011/02/icra99.pdf http://haskell.cs.yale.edu/wp- content/uploads/2011/02/icra99.pdf


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

Similar presentations


Ads by Google