SlideShare uma empresa Scribd logo
1 de 35
Baixar para ler offline
Tangible Value
                               in Haskell




Friday, January 25, 2008                    1
Conal Elliott

           • http://www.youtube.com/watch?v=faJ8N0giqzw
           • http://conal.net/papers/Eros/
           • http://journal.conal.net/#
                   [[separating IO from logic -- example]]

           • http://conal-elliott.blogspot.com/search/label/TV

Friday, January 25, 2008                                         2
Eros
Friday, January 25, 2008          3
Friday, January 25, 2008   4
applications:                 libraries:

     1.               user-friendly 1.   programmer-friendly
     2.               usable        2.   composable
     3.               concrete      3.   abstract
     4.               visual        4.   syntactic


Friday, January 25, 2008                                       5
UNIX philosophy

           • Write         programs that do one thing and do it well

           • Write         programs to work together

           • Write       programs to handle text streams, because that
                   is a universal interface
                                                       Doug McIlroy


Friday, January 25, 2008                                                 6
godfat   ~/p/l/l/l/proc> ls | sort | cat -n
                                1   bind.rb
                                2   chain.rb
                                3   compose.rb
                                4   curry.rb




Friday, January 25, 2008                                                 7
TV
Friday, January 25, 2008        8
Friday, January 25, 2008   9
module Grading where

import Data.List (sort)
import Data.Map (Map,empty,keys,insertWith,findWithDefault)
import Text.Printf

import Interface.TV
import Interface.TV.OFun() -- work around GHC bug.   ticket #1145




Friday, January 25, 2008                                            10
grades = do
    src <- readFile "tasks"
    let pairs = map (split.words) (lines src)
        grades = foldr insert empty pairs
    mapM_ (draw grades) (sort (keys grades))
  where
    insert (s, g) = insertWith (++) s [g]
    split [name,mark] = (name, read mark)
    draw g s = printf "%st%stAverage: %fn" s (show marks) avg
      where
        marks = findWithDefault (error "No such student") s g
        avg   = sum marks / fromIntegral (length marks) :: Double



Friday, January 25, 2008                                        11
Friday, January 25, 2008
                           I/O   12
gradingStr src = concatMap (draw grades) (sort (keys grades))
  where
    pairs = map (split.words) (lines src)
    grades = foldr insert empty pairs

              insert (s, g) = insertWith (++) s [g]
              split [name,mark] = (name, read mark)
              draw g s = printf "%st%stAverage: %fn" s (show marks) avg
                where
                  marks = findWithDefault (error "No such student") s g
                  avg   = sum marks / fromIntegral (length marks) :: Double




Friday, January 25, 2008                                                  13
type GradingStr = String -> String
gradingStr :: GradingStr

grades_2 = readFile "tasks" >>= return . gradingStr >>= putStr




Friday, January 25, 2008                                         14
in
Friday, January 25, 2008
                           TV   15
type GradingStr = String -> String
gradingStr :: GradingStr

grades_2 = readFile "tasks" >>= return . gradingStr >>= putStr


gradingStrOut = oLambda (fileIn "tasks") stringOut
gradingStrT :: TV KIO GradingStr
gradingStrT = tv gradingStrOut gradingStr

grades_3 = runTV gradingStrT




Friday, January 25, 2008                                         16
Eros
Friday, January 25, 2008          17
(1)
Friday, January 25, 2008         18
Friday, January 25, 2008   19
Friday, January 25, 2008   20
Friday, January 25, 2008   21
Friday, January 25, 2008   22
Friday, January 25, 2008   23
(2)
Friday, January 25, 2008         24
Friday, January 25, 2008   25
Friday, January 25, 2008   26
Friday, January 25, 2008   27
Friday, January 25, 2008   28
first :: (a -> a') -> ((a, b) -> (a',b ))
                           second :: (b -> b') -> ((a, b) -> (a ,b'))
                           result :: (b -> b') -> ((a->b) -> (a->b'))

                           first f =  (a, b) -> (f a,   b)
                           second g =  (a, b) -> ( a, g b)
                           result g =  f -> g . f




Friday, January 25, 2008                                                29
sf :: (b->b') -> (a,(b ,c))
                                         -> (a,(b',c))

                           sf = second.first

                           frsrf :: (c->c') -> (a->(f,b->(c ,g)),e)
                                            -> (a->(f,b->(c',g)),e)

                           frsrf = first.result.second.result.first

                           funFirst ::
                             (d -> (c->a)) -> ((d,b) -> (c->(a,b)))



Friday, January 25, 2008                                              30
(3)
Friday, January 25, 2008         31
Friday, January 25, 2008   32
type TV a = (Out a, a)

                           type Out a   = ...
                           put     ::   Put a -> Out a
                           opair   ::   Out a -> Out b -> Out (a, b)
                           olambda ::   In a -> Out b -> Out (a->b)

                           type In a = ...
                           get   :: Get a -> In a
                           ipair :: In a -> In b -> In (a,b)




Friday, January 25, 2008                                               33
Eros

                           • TypeCompose   • TV
                           • DeepArrow     • GuiTV
                           • DataDriven    • wxHaskell
                           • Phooey        • wxWidgets

Friday, January 25, 2008                                 34
To explore

           • Tangible polymorphism?
           • Direct structural tweaks
           • Symmetric In/Out (ilambda)
           • “GUIs are types” as GUI design   guide

           • TVs as composable MVC

Friday, January 25, 2008                              35

Mais conteúdo relacionado

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
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
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
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
 
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
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 

Destaque

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)
 

Destaque (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...
 

2008-01-25 Tangible Value

  • 1. Tangible Value in Haskell Friday, January 25, 2008 1
  • 2. Conal Elliott • http://www.youtube.com/watch?v=faJ8N0giqzw • http://conal.net/papers/Eros/ • http://journal.conal.net/# [[separating IO from logic -- example]] • http://conal-elliott.blogspot.com/search/label/TV Friday, January 25, 2008 2
  • 5. applications: libraries: 1. user-friendly 1. programmer-friendly 2. usable 2. composable 3. concrete 3. abstract 4. visual 4. syntactic Friday, January 25, 2008 5
  • 6. UNIX philosophy • Write programs that do one thing and do it well • Write programs to work together • Write programs to handle text streams, because that is a universal interface Doug McIlroy Friday, January 25, 2008 6
  • 7. godfat ~/p/l/l/l/proc> ls | sort | cat -n 1 bind.rb 2 chain.rb 3 compose.rb 4 curry.rb Friday, January 25, 2008 7
  • 10. module Grading where import Data.List (sort) import Data.Map (Map,empty,keys,insertWith,findWithDefault) import Text.Printf import Interface.TV import Interface.TV.OFun() -- work around GHC bug. ticket #1145 Friday, January 25, 2008 10
  • 11. grades = do src <- readFile "tasks" let pairs = map (split.words) (lines src) grades = foldr insert empty pairs mapM_ (draw grades) (sort (keys grades)) where insert (s, g) = insertWith (++) s [g] split [name,mark] = (name, read mark) draw g s = printf "%st%stAverage: %fn" s (show marks) avg where marks = findWithDefault (error "No such student") s g avg = sum marks / fromIntegral (length marks) :: Double Friday, January 25, 2008 11
  • 12. Friday, January 25, 2008 I/O 12
  • 13. gradingStr src = concatMap (draw grades) (sort (keys grades)) where pairs = map (split.words) (lines src) grades = foldr insert empty pairs insert (s, g) = insertWith (++) s [g] split [name,mark] = (name, read mark) draw g s = printf "%st%stAverage: %fn" s (show marks) avg where marks = findWithDefault (error "No such student") s g avg = sum marks / fromIntegral (length marks) :: Double Friday, January 25, 2008 13
  • 14. type GradingStr = String -> String gradingStr :: GradingStr grades_2 = readFile "tasks" >>= return . gradingStr >>= putStr Friday, January 25, 2008 14
  • 16. type GradingStr = String -> String gradingStr :: GradingStr grades_2 = readFile "tasks" >>= return . gradingStr >>= putStr gradingStrOut = oLambda (fileIn "tasks") stringOut gradingStrT :: TV KIO GradingStr gradingStrT = tv gradingStrOut gradingStr grades_3 = runTV gradingStrT Friday, January 25, 2008 16
  • 29. first :: (a -> a') -> ((a, b) -> (a',b )) second :: (b -> b') -> ((a, b) -> (a ,b')) result :: (b -> b') -> ((a->b) -> (a->b')) first f = (a, b) -> (f a, b) second g = (a, b) -> ( a, g b) result g = f -> g . f Friday, January 25, 2008 29
  • 30. sf :: (b->b') -> (a,(b ,c)) -> (a,(b',c)) sf = second.first frsrf :: (c->c') -> (a->(f,b->(c ,g)),e) -> (a->(f,b->(c',g)),e) frsrf = first.result.second.result.first funFirst :: (d -> (c->a)) -> ((d,b) -> (c->(a,b))) Friday, January 25, 2008 30
  • 33. type TV a = (Out a, a) type Out a = ... put :: Put a -> Out a opair :: Out a -> Out b -> Out (a, b) olambda :: In a -> Out b -> Out (a->b) type In a = ... get :: Get a -> In a ipair :: In a -> In b -> In (a,b) Friday, January 25, 2008 33
  • 34. Eros • TypeCompose • TV • DeepArrow • GuiTV • DataDriven • wxHaskell • Phooey • wxWidgets Friday, January 25, 2008 34
  • 35. To explore • Tangible polymorphism? • Direct structural tweaks • Symmetric In/Out (ilambda) • “GUIs are types” as GUI design guide • TVs as composable MVC Friday, January 25, 2008 35