SlideShare una empresa de Scribd logo
1 de 35
Descargar para leer sin conexión
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

Más contenido relacionado

Último

Último (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
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...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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 Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

Destacado

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)
 

Destacado (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