slicing and functional programming
play

Slicing and Functional Programming Simon Thompson University of - PowerPoint PPT Presentation

Slicing and Functional Programming Simon Thompson University of Kent Haskell and Erlang Pure language Impure language but has monads but single assignment Strongly typed Weakly typed Lazy evaluation


  1. Slicing and Functional Programming Simon Thompson University of Kent

  2. Haskell and Erlang • Pure language … • Impure language … • … but has monads • … but single assignment • Strongly typed • Weakly typed • Lazy evaluation • Strict evaluation • Sequential core • Concurrent

  3. Concurrency in Erlang -module(echo). -export([go/0, loop/0]). go() -> loop() -> Pid = spawn(echo, loop, []), receive Pid ! {self(), hello}, {From, Msg} -> receive From ! {self(), Msg}, {Pid, Msg} -> loop(); io:format("~w~n",[Msg]) stop -> end, true Pid ! stop. end.

  4. Laziness in Haskell if True t f = t • Arguments are only if False t f = f evaluated when needed. if (2>3) ⊥ 4 ↝ 4 • Arguments are only sft (a:b:xs) = a+b evaluated to the extent ones = 1:ones that is needed for sft ones ↝ 2 evaluation to proceed.

  5. Slicing parseMessage :: MessageList -> (Message, MessageList) parseMessage [] = ([], []) parseMessage xs = (takeWhile (/= ’&’) (tail ys), dropWhile (/= ’&’) (tail ys) ) where ys = dropWhile (/= ’&’) xs parseMsgL :: MessageList -> Message parseMsgL [] = [] parseMsgL xs = takeWhile (/= ’&’) (tail (dropWhile (/= ’&’) xs))

  6. Clone detection • Search for common generalisation. • What about insertion, deletion or permutation of statements? • Can slicing help?

  7. Ideas • Slicing for debugging functional programs. • Slicing components of complex structures. • … and others … ?

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend