SlideShare une entreprise Scribd logo
1  sur  48
Télécharger pour lire hors ligne
Using Haskell Type Signatures as a
   Functional Design Notation


            Michael Feathers
               Groupon
Using Haskell Type Signatures as a
   Functional Design Notation
           (just because)

            Michael Feathers
               Groupon
Functdesign sl
a
[a]
map :: (a -> b) -> [a] -> [b]
map :: (a -> b) -> [a] -> [b]
    map (+2) [1,2,3]
region 7 9 “expertsexchange”
region 7 9 “expertsexchange”
region :: Int -> Int -> String -> String
regionFrom7 9 “expertsexchange”
regionFrom7 :: Int -> Int -> String -> String
Hoping
Line Break algorithm
String -> String
String -> [String] -> [[String]] -> [String] -> String
String -> [String] -> [[String]] -> [String] -> String

breakTextIntoWords
String -> [String] -> [[String]] -> [String] -> String

breakTextIntoWords
            breakWordsIntoLines
String -> [String] -> [[String]] -> [String] -> String

breakTextIntoWords
            breakWordsIntoLines

                        joinWordsInBrokenLines
String -> [String] -> [[String]] -> [String] -> String

breakTextIntoWords
            breakWordsIntoLines

                        joinWordsInBrokenLines
                                              joinBrokenLines
String -> [String] -> [[String]] -> [String] -> String
String -> [String] -> [[String]] -> [String] -> String



String -> [String] -> (Int -> [[String]]) -> [[String]] ->
                    [String] -> String
String -> [String] -> [[String]] -> [String] -> String



String -> [String] -> (Int -> [[String]]) -> [[String]] ->
                    [String] -> String
String -> [String] -> [[String]] -> [String] -> String



String -> [String] -> (Int -> [[String]]) -> [[String]] ->
                    [String] -> String



Abuse!
A Design Device
(via Scott Ambler)
(via Scott Ambler)
Functdesign sl
Functdesign sl
Functdesign sl
Functdesign sl
Functdesign sl
Functdesign sl
Functdesign sl
String -> [String] -> [[String]] -> [String] -> String

     words
String -> [String] -> [[String]] -> [String] -> String

     words
String -> [String] -> [[String]] -> [String] -> String

     words
              brokenLines
String -> [String] -> [[String]] -> [String] -> String

     words
              brokenLines
                            wordJoinedLines
String -> [String] -> [[String]] -> [String] -> String

     words
              brokenLines
                            wordJoinedLines
                                           joinedLines
Functdesign sl
Functdesign sl
Favors combinator style
Favors combinator style
       [String] -> Int
Favors combinator style
              [String] -> Int
[String] -> [Int] -> [Int] -> [Int] -> Int
           (repeated types in endomorphic chain)
Affordances
Separate bins for your head and
         your notation
 String -> [String] -> (Int -> [[String]]) -> [[String]] ->
                     [String] -> String
Concentrates on Data
Concentrates on Data

      ..in naming
Favors combinator style
Staying in the same shape is the easiest way to get from here to there
Thank you

Contenu connexe

Tendances

Elixir pattern matching and recursion
Elixir pattern matching and recursionElixir pattern matching and recursion
Elixir pattern matching and recursionBob Firestone
 
Addition and subtraction of polynomial functions
Addition and subtraction of polynomial functionsAddition and subtraction of polynomial functions
Addition and subtraction of polynomial functionsMartinGeraldine
 
Ejercicios combinados
Ejercicios combinadosEjercicios combinados
Ejercicios combinadosCinty Fuchs
 
PyMCがあれば,ベイズ推定でもう泣いたりなんかしない
PyMCがあれば,ベイズ推定でもう泣いたりなんかしないPyMCがあれば,ベイズ推定でもう泣いたりなんかしない
PyMCがあれば,ベイズ推定でもう泣いたりなんかしないToshihiro Kamishima
 
Good Ideas in Programming Languages
Good Ideas in Programming LanguagesGood Ideas in Programming Languages
Good Ideas in Programming LanguagesDmitri Nesteruk
 
Sum and difference of two squares
Sum and difference of two squaresSum and difference of two squares
Sum and difference of two squaresMartinGeraldine
 
List comprehensions
List comprehensionsList comprehensions
List comprehensionsJordi Gómez
 
Multiplying and-dividingfor web
Multiplying and-dividingfor webMultiplying and-dividingfor web
Multiplying and-dividingfor webMs. Jones
 
The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196Mahmoud Samir Fayed
 

Tendances (14)

Multiplying monomial
Multiplying monomialMultiplying monomial
Multiplying monomial
 
Elixir pattern matching and recursion
Elixir pattern matching and recursionElixir pattern matching and recursion
Elixir pattern matching and recursion
 
Data Structures Operations
Data Structures OperationsData Structures Operations
Data Structures Operations
 
Addition and subtraction of polynomial functions
Addition and subtraction of polynomial functionsAddition and subtraction of polynomial functions
Addition and subtraction of polynomial functions
 
Sol3
Sol3Sol3
Sol3
 
Ejercicios combinados
Ejercicios combinadosEjercicios combinados
Ejercicios combinados
 
PyMCがあれば,ベイズ推定でもう泣いたりなんかしない
PyMCがあれば,ベイズ推定でもう泣いたりなんかしないPyMCがあれば,ベイズ推定でもう泣いたりなんかしない
PyMCがあれば,ベイズ推定でもう泣いたりなんかしない
 
Good Ideas in Programming Languages
Good Ideas in Programming LanguagesGood Ideas in Programming Languages
Good Ideas in Programming Languages
 
Sum and difference of two squares
Sum and difference of two squaresSum and difference of two squares
Sum and difference of two squares
 
List comprehensions
List comprehensionsList comprehensions
List comprehensions
 
Foil method
Foil methodFoil method
Foil method
 
Multiplying and-dividingfor web
Multiplying and-dividingfor webMultiplying and-dividingfor web
Multiplying and-dividingfor web
 
Foil method
Foil methodFoil method
Foil method
 
The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196
 

Similaire à Functdesign sl

Numbers obfuscation in Python
Numbers obfuscation in PythonNumbers obfuscation in Python
Numbers obfuscation in Pythondelimitry
 
L13 string handling(string class)
L13 string handling(string class)L13 string handling(string class)
L13 string handling(string class)teach4uin
 
An overview of Python 2.7
An overview of Python 2.7An overview of Python 2.7
An overview of Python 2.7decoupled
 
Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!Paige Bailey
 
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲Mohammad Reza Kamalifard
 
An Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using HaskellAn Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using HaskellMichel Rijnders
 
Pythonlearn-08-Lists.pptx
Pythonlearn-08-Lists.pptxPythonlearn-08-Lists.pptx
Pythonlearn-08-Lists.pptxMihirDatir
 

Similaire à Functdesign sl (14)

Numbers obfuscation in Python
Numbers obfuscation in PythonNumbers obfuscation in Python
Numbers obfuscation in Python
 
Lecture 10.pdf
Lecture 10.pdfLecture 10.pdf
Lecture 10.pdf
 
Grokking regex
Grokking regexGrokking regex
Grokking regex
 
L13 string handling(string class)
L13 string handling(string class)L13 string handling(string class)
L13 string handling(string class)
 
An overview of Python 2.7
An overview of Python 2.7An overview of Python 2.7
An overview of Python 2.7
 
A tour of Python
A tour of PythonA tour of Python
A tour of Python
 
Numpy Talk at SIAM
Numpy Talk at SIAMNumpy Talk at SIAM
Numpy Talk at SIAM
 
Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!
 
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
 
An Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using HaskellAn Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using Haskell
 
Python String Revisited.pptx
Python String Revisited.pptxPython String Revisited.pptx
Python String Revisited.pptx
 
Arrays & Strings.pptx
Arrays & Strings.pptxArrays & Strings.pptx
Arrays & Strings.pptx
 
Python strings
Python stringsPython strings
Python strings
 
Pythonlearn-08-Lists.pptx
Pythonlearn-08-Lists.pptxPythonlearn-08-Lists.pptx
Pythonlearn-08-Lists.pptx
 

Dernier

5 Moments of Everyday Self-Loathing That Perfectly Describe Your Life
5 Moments of Everyday Self-Loathing That Perfectly Describe Your Life5 Moments of Everyday Self-Loathing That Perfectly Describe Your Life
5 Moments of Everyday Self-Loathing That Perfectly Describe Your LifeSalty Vixen Stories & More
 
The Hardest Part About Picking A Show To Watch (Comics)
The Hardest Part About Picking A Show To Watch (Comics)The Hardest Part About Picking A Show To Watch (Comics)
The Hardest Part About Picking A Show To Watch (Comics)Salty Vixen Stories & More
 
Holi:: "The Festival of Colors in India"
Holi:: "The Festival of Colors in India"Holi:: "The Festival of Colors in India"
Holi:: "The Festival of Colors in India"IdolsArts
 
Inside Look: Brooke Monk's Exclusive OnlyFans Content Production
Inside Look: Brooke Monk's Exclusive OnlyFans Content ProductionInside Look: Brooke Monk's Exclusive OnlyFans Content Production
Inside Look: Brooke Monk's Exclusive OnlyFans Content Productionget joys
 
Young adult book quiz by SJU quizzers.ppt
Young adult book quiz by SJU quizzers.pptYoung adult book quiz by SJU quizzers.ppt
Young adult book quiz by SJU quizzers.pptSJU Quizzers
 
Taylor Swift quiz( with answers) by SJU quizzers
Taylor Swift quiz( with answers) by SJU quizzersTaylor Swift quiz( with answers) by SJU quizzers
Taylor Swift quiz( with answers) by SJU quizzersSJU Quizzers
 
"Quest for Knowledge: An Exciting Journey Through 40 Brain-Bending Questions ...
"Quest for Knowledge: An Exciting Journey Through 40 Brain-Bending Questions ..."Quest for Knowledge: An Exciting Journey Through 40 Brain-Bending Questions ...
"Quest for Knowledge: An Exciting Journey Through 40 Brain-Bending Questions ...RAGHURAMYC
 
How the fever night scores above your mundane nightlife occurrence
How the fever night scores above your mundane nightlife occurrenceHow the fever night scores above your mundane nightlife occurrence
How the fever night scores above your mundane nightlife occurrenceJFI Production
 

Dernier (8)

5 Moments of Everyday Self-Loathing That Perfectly Describe Your Life
5 Moments of Everyday Self-Loathing That Perfectly Describe Your Life5 Moments of Everyday Self-Loathing That Perfectly Describe Your Life
5 Moments of Everyday Self-Loathing That Perfectly Describe Your Life
 
The Hardest Part About Picking A Show To Watch (Comics)
The Hardest Part About Picking A Show To Watch (Comics)The Hardest Part About Picking A Show To Watch (Comics)
The Hardest Part About Picking A Show To Watch (Comics)
 
Holi:: "The Festival of Colors in India"
Holi:: "The Festival of Colors in India"Holi:: "The Festival of Colors in India"
Holi:: "The Festival of Colors in India"
 
Inside Look: Brooke Monk's Exclusive OnlyFans Content Production
Inside Look: Brooke Monk's Exclusive OnlyFans Content ProductionInside Look: Brooke Monk's Exclusive OnlyFans Content Production
Inside Look: Brooke Monk's Exclusive OnlyFans Content Production
 
Young adult book quiz by SJU quizzers.ppt
Young adult book quiz by SJU quizzers.pptYoung adult book quiz by SJU quizzers.ppt
Young adult book quiz by SJU quizzers.ppt
 
Taylor Swift quiz( with answers) by SJU quizzers
Taylor Swift quiz( with answers) by SJU quizzersTaylor Swift quiz( with answers) by SJU quizzers
Taylor Swift quiz( with answers) by SJU quizzers
 
"Quest for Knowledge: An Exciting Journey Through 40 Brain-Bending Questions ...
"Quest for Knowledge: An Exciting Journey Through 40 Brain-Bending Questions ..."Quest for Knowledge: An Exciting Journey Through 40 Brain-Bending Questions ...
"Quest for Knowledge: An Exciting Journey Through 40 Brain-Bending Questions ...
 
How the fever night scores above your mundane nightlife occurrence
How the fever night scores above your mundane nightlife occurrenceHow the fever night scores above your mundane nightlife occurrence
How the fever night scores above your mundane nightlife occurrence
 

Functdesign sl

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n