SlideShare a Scribd company logo
1 of 28
Download to read offline
Welcome



woensdag 27 januari 2010
Haskell
                            Chris Eidhof




woensdag 27 januari 2010
Three things


                    • Strong types
                    • Purity
                    • Larger example


woensdag 27 januari 2010
Strong Types

                    • As programmers, we do a lot of testing:
                    • * Unit Testing
                    • * Debugging
                    • * Specification

woensdag 27 januari 2010
Strong Types


                    • Can we automate testing?



woensdag 27 januari 2010
List
                             Type-parameter
                                                   Constructor



                    •      data [a] = [] | a : [a]


              Type
                                     Constructor


woensdag 27 januari 2010
List Example


                             Example: List.hs




woensdag 27 januari 2010
Functions
                           Give me a list of a And I’ll return a
                                                  list of a

  •      reverse :: [a] -> [a]

  •      reverse []                      = []

  •      reverse (x:xs) = reverse xs ++ [x]

                Pattern Matching
                                    Example: Reverse.hs
woensdag 27 januari 2010
Purity



             •             State = Evil


woensdag 27 januari 2010
Purity

             •               Same Input
             •         ntial
                Refere cy
               Transp aren
                                 =
             •             Same output

woensdag 27 januari 2010
Purity

                    • No side effects:
                    • * Variables
                    • * I/O
                    • * launchMissiles()

woensdag 27 januari 2010
Example


                    •      sort :: [Int] -> [Int]


                     How do we know sort doesn’t launch missiles?




woensdag 27 januari 2010
Doing I/O


                    •      putStr :: String -> IO ()


                            The IO type shows us it’s not pure



woensdag 27 januari 2010
Laziness


                    •      if (x < 10 && x > 5)



                    •      Example: Lazy.hs




woensdag 27 januari 2010
Quickcheck


                    • Automatic testing of pure code.

                               Example: Reverse.hs


woensdag 27 januari 2010
Software
                           Transactional
                              Memory

                    • Composable transactions
                    • No deadlocks!


woensdag 27 januari 2010
Fusion



•   myFunction = map square . map toInt

•                          = map (square . toInt)


woensdag 27 januari 2010
Parallel code


                    •      map    :: (a -> b) -> [a] -> [b]

                    •      parMap :: (a -> b) -> [a] -> [b]




woensdag 27 januari 2010
Effects
                            Useful
                                         Most            Nirvana
                                       languages




                                                       Haskell

                           Useless
                                     Dangerous               Safe

                              Simon Peyton-Jones, Caging The Effects Monster
woensdag 27 januari 2010
Arc Challenge
                    •      Write a program that causes the url said (e.g. http://
                           localhost:port/said) to produce a page with an input field and
                           a submit button. When the submit button is pressed, that
                           should produce a second page with a single link saying "click
                           here." When that is clicked it should lead to a third page that
                           says "you said: ..." where ... is whatever the user typed in the
                           original input field. The third page must only show what the
                           user actually typed. I.e. the value entered in the input field
                           must not be passed in the url, or it would be possible to
                           change the behavior of the final page by editing the url.




woensdag 27 januari 2010
Arc Challenge
                    • Solution in Arc:
                    •      (defop said req

                             (aform [onlink "click here"
                               (pr "you said: " (arg _ "foo"))]
                               (input "foo")
                               (submit)))

                    •


woensdag 27 januari 2010
Arc Challenge


       arc = do name <- input
               link "click here"
               display $ "you said:" ++ name




                           See gist: http://gist.github.com/260052
woensdag 27 januari 2010
Arc Challenge (2)
                              input uses type-inference!

             arc2 = do  name  <- input
                        (x,y) <- input
                        link "click here"
                        display (add x y)
                        display ("you said:" ++ name)




woensdag 27 januari 2010
Read more
• Real World Haskell - http://book.realworldhaskell.org/
• Haskell.org - http://haskell.org
• Haskell Café - http://haskell.org/haskellwiki/Mailing_lists
• Planet Haskell - http://planet.haskell.org/
• Haskell reddit - http://haskell.reddit.com
•
woensdag 27 januari 2010
Getting Started

                    • 1. Install the Haskell Platform
                    • http://hackage.haskell.org/platform/
                    • 2. Haskell in 10 minutes
                    • http://haskell.org/haskellwiki/
                           Learn_Haskell_in_10_minutes



woensdag 27 januari 2010
Keep in touch


                    • http://github.com/chriseidhof
                    • @chriseidhof


woensdag 27 januari 2010
One more thing...




woensdag 27 januari 2010
Have fun



woensdag 27 januari 2010

More Related Content

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Hackersnl

  • 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 • * Specification woensdag 27 januari 2010
  • 5. Strong Types • Can we automate testing? woensdag 27 januari 2010
  • 6. List Type-parameter Constructor • data [a] = [] | a : [a] Type Constructor woensdag 27 januari 2010
  • 7. List Example Example: List.hs woensdag 27 januari 2010
  • 8. Functions Give me a list of a And I’ll return a list of a • reverse :: [a] -> [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 cy Transp aren = • Same output woensdag 27 januari 2010
  • 11. Purity • No side effects: • * Variables • * I/O • * launchMissiles() woensdag 27 januari 2010
  • 12. Example • sort :: [Int] -> [Int] How do we know sort doesn’t launch missiles? woensdag 27 januari 2010
  • 13. Doing I/O • putStr :: String -> IO () The IO type shows us it’s not pure woensdag 27 januari 2010
  • 14. Laziness • if (x < 10 && x > 5) • Example: Lazy.hs woensdag 27 januari 2010
  • 15. Quickcheck • Automatic testing of pure code. Example: Reverse.hs woensdag 27 januari 2010
  • 16. Software Transactional Memory • Composable transactions • No deadlocks! woensdag 27 januari 2010
  • 17. Fusion • myFunction = map square . map toInt • = map (square . toInt) woensdag 27 januari 2010
  • 18. Parallel code • map  :: (a -> b) -> [a] -> [b] • parMap :: (a -> b) -> [a] -> [b] woensdag 27 januari 2010
  • 19. Effects Useful Most Nirvana languages Haskell Useless Dangerous Safe Simon 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 field and a submit button. When the submit button is pressed, that should produce a second page with a single link saying "click here." When that is clicked it should lead to a third page that says "you said: ..." where ... is whatever the user typed in the original input field. The third page must only show what the user actually typed. I.e. the value entered in the input field must not be passed in the url, or it would be possible to change the behavior of the final 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 Challenge arc = do name <- input           link "click here"           display $ "you said:" ++ name See gist: http://gist.github.com/260052 woensdag 27 januari 2010
  • 23. Arc Challenge (2) input uses type-inference! arc2 = do  name  <- input            (x,y) <- input            link "click here"            display (add x y)            display ("you said:" ++ name) woensdag 27 januari 2010
  • 24. Read more • Real World Haskell - http://book.realworldhaskell.org/ • Haskell.org - http://haskell.org • Haskell Café - http://haskell.org/haskellwiki/Mailing_lists • Planet Haskell - http://planet.haskell.org/ • Haskell reddit - http://haskell.reddit.com • woensdag 27 januari 2010
  • 25. Getting Started • 1. Install the Haskell Platform • http://hackage.haskell.org/platform/ • 2. Haskell in 10 minutes • http://haskell.org/haskellwiki/ Learn_Haskell_in_10_minutes woensdag 27 januari 2010
  • 26. Keep in touch • http://github.com/chriseidhof • @chriseidhof woensdag 27 januari 2010
  • 27. One more thing... woensdag 27 januari 2010
  • 28. Have fun woensdag 27 januari 2010