HN NL - Haskell

Download HN NL - Haskell

Post on 12-May-2015

632 views

Category:

Technology

2 download

Embed Size (px)

TRANSCRIPT

<ul><li>1.Welcomewoensdag 27 januari 2010 </li></ul> <p>2. Haskell Chris Eidhof woensdag 27 januari 2010 3. Three things Strong types Purity Larger example woensdag 27 januari 2010 4. Strong Types As programmers, we do a lot of testing: * Unit Testing * Debugging * Specicationwoensdag 27 januari 2010 5. Strong Types Can we automate testing?woensdag 27 januari 2010 6. ListType-parameterConstructordata[a]=[]|a: [a] TypeConstructor woensdag 27 januari 2010 7. List ExampleExample: List.hs woensdag 27 januari 2010 8. FunctionsGive me a list of a And Ill return a list of areverse :: [a] -&gt; [a]reverse []= []reverse (x:xs) = reverse xs ++ [x]Pattern Matching Example: Reverse.hs woensdag 27 januari 2010 9. Purity State = Evil woensdag 27 januari 2010 10. Purity Same Input ntial Refere cyTransp aren= Same outputwoensdag 27 januari 2010 11. Purity No side effects: * Variables * I/O * launchMissiles()woensdag 27 januari 2010 12. Example sort::[Int]-&gt;[Int]How do we know sort doesnt launch missiles? woensdag 27 januari 2010 13. Doing I/O putStr::String-&gt;IO () The IO type shows us its not purewoensdag 27 januari 2010 14. Laziness if(x5)Example: Lazy.hs woensdag 27 januari 2010 15. Quickcheck Automatic testing of pure code. Example: Reverse.hs woensdag 27 januari 2010 16. SoftwareTransactional Memory Composable transactions No deadlocks! woensdag 27 januari 2010 17. Fusion myFunction=mapsquare.maptoInt=map(square.toInt) woensdag 27 januari 2010 18. Parallel code map ::(a -&gt; b)-&gt; [a] -&gt;[b]parMap::(a -&gt; b)-&gt; [a] -&gt;[b] woensdag 27 januari 2010 19. Effects UsefulMostNirvanalanguagesHaskell UselessDangerous SafeSimon Peyton-Jones, Caging The Effects Monster woensdag 27 januari 2010 20. Arc Challenge Write a program that causes the url said (e.g. http://localhost:port/said) to produce a page with an input eld anda submit button. When the submit button is pressed, thatshould produce a second page with a single link saying "clickhere." When that is clicked it should lead to a third page thatsays "you said: ..." where ... is whatever the user typed in theoriginal input eld. The third page must only show what theuser actually typed. I.e. the value entered in the input eldmust not be passed in the url, or it would be possible tochange the behavior of the nal page by editing the url. woensdag 27 januari 2010 21. Arc Challenge Solution in Arc: (defop said req (aform [onlink "click here"(pr "you said: " (arg _ "foo"))](input "foo")(submit))) woensdag 27 januari 2010 22. Arc Challengearc=do name</p>