A Type Driven Approach to    Functional Design        Michael Feathers           Groupon
A Type Driven Approach to    Functional Design       (just because)        Michael Feathers           Groupon
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] -> StringbreakTextIntoWords
String -> [String] -> [[String]] -> [String] -> StringbreakTextIntoWords            breakWordsIntoLines
String -> [String] -> [[String]] -> [String] -> StringbreakTextIntoWords            breakWordsIntoLines                   ...
String -> [String] -> [[String]] -> [String] -> StringbreakTextIntoWords            breakWordsIntoLines                   ...
String -> [String] -> [[String]] -> [String] -> String
String -> [String] -> [[String]] -> [String] -> StringString -> [String] -> (Int -> [[String]]) -> [[String]] ->          ...
String -> [String] -> [[String]] -> [String] -> StringString -> [String] -> (Int -> [[String]]) -> [[String]] ->          ...
String -> [String] -> [[String]] -> [String] -> StringString -> [String] -> (Int -> [[String]]) -> [[String]] ->          ...
A Design Device
(via Scott Ambler)
(via Scott Ambler)
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                            wordJ...
String -> [String] -> [[String]] -> [String] -> String     words              brokenLines                            wordJ...
Favors combinator style
Favors combinator style       [String] -> Int
Favors combinator style              [String] -> Int[String] -> [Int] -> [Int] -> [Int] -> Int           (repeated types i...
Affordances
Separate bins for your head and         your notation String -> [String] -> (Int -> [[String]]) -> [[String]] ->          ...
Concentrates on Data
Concentrates on Data      ..in naming
Favors combinator styleStaying in the same shape is the easiest way to get from here to there
Thank you
A Type Driven Approach to Functional Design
A Type Driven Approach to Functional Design
A Type Driven Approach to Functional Design
A Type Driven Approach to Functional Design
A Type Driven Approach to Functional Design
A Type Driven Approach to Functional Design
A Type Driven Approach to Functional Design
A Type Driven Approach to Functional Design
A Type Driven Approach to Functional Design
A Type Driven Approach to Functional Design
Upcoming SlideShare
Loading in …5
×

A Type Driven Approach to Functional Design

1,548 views

Published on

Presentation at Strange Loop 2012 re using Haskell type signatures as a design notation.

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,548
On SlideShare
0
From Embeds
0
Number of Embeds
41
Actions
Shares
0
Downloads
18
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • A Type Driven Approach to Functional Design

    1. 1. A Type Driven Approach to Functional Design Michael Feathers Groupon
    2. 2. A Type Driven Approach to Functional Design (just because) Michael Feathers Groupon
    3. 3. a
    4. 4. [a]
    5. 5. map :: (a -> b) -> [a] -> [b]
    6. 6. map :: (a -> b) -> [a] -> [b] map (+2) [1,2,3]
    7. 7. region 7 9 “expertsexchange”
    8. 8. region 7 9 “expertsexchange”region :: Int -> Int -> String -> String
    9. 9. regionFrom7 9 “expertsexchange”regionFrom7 :: Int -> Int -> String -> String
    10. 10. Hoping
    11. 11. Line Break algorithm
    12. 12. String -> String
    13. 13. String -> [String] -> [[String]] -> [String] -> String
    14. 14. String -> [String] -> [[String]] -> [String] -> StringbreakTextIntoWords
    15. 15. String -> [String] -> [[String]] -> [String] -> StringbreakTextIntoWords breakWordsIntoLines
    16. 16. String -> [String] -> [[String]] -> [String] -> StringbreakTextIntoWords breakWordsIntoLines joinWordsInBrokenLines
    17. 17. String -> [String] -> [[String]] -> [String] -> StringbreakTextIntoWords breakWordsIntoLines joinWordsInBrokenLines joinBrokenLines
    18. 18. String -> [String] -> [[String]] -> [String] -> String
    19. 19. String -> [String] -> [[String]] -> [String] -> StringString -> [String] -> (Int -> [[String]]) -> [[String]] -> [String] -> String
    20. 20. String -> [String] -> [[String]] -> [String] -> StringString -> [String] -> (Int -> [[String]]) -> [[String]] -> [String] -> String
    21. 21. String -> [String] -> [[String]] -> [String] -> StringString -> [String] -> (Int -> [[String]]) -> [[String]] -> [String] -> StringAbuse!
    22. 22. A Design Device
    23. 23. (via Scott Ambler)
    24. 24. (via Scott Ambler)
    25. 25. String -> [String] -> [[String]] -> [String] -> String words
    26. 26. String -> [String] -> [[String]] -> [String] -> String words
    27. 27. String -> [String] -> [[String]] -> [String] -> String words brokenLines
    28. 28. String -> [String] -> [[String]] -> [String] -> String words brokenLines wordJoinedLines
    29. 29. String -> [String] -> [[String]] -> [String] -> String words brokenLines wordJoinedLines joinedLines
    30. 30. Favors combinator style
    31. 31. Favors combinator style [String] -> Int
    32. 32. Favors combinator style [String] -> Int[String] -> [Int] -> [Int] -> [Int] -> Int (repeated types in endomorphic chain)
    33. 33. Affordances
    34. 34. Separate bins for your head and your notation String -> [String] -> (Int -> [[String]]) -> [[String]] -> [String] -> String
    35. 35. Concentrates on Data
    36. 36. Concentrates on Data ..in naming
    37. 37. Favors combinator styleStaying in the same shape is the easiest way to get from here to there
    38. 38. Thank you

    ×