SlideShare a Scribd company logo
1 of 17
Teaching Haskell To Juggle

         Phil Freeman
Agenda
•   Theory
•   Finding valid patterns and their states
•   Why Haskell?
•   If there’s time:
    – Animating siteswaps with HOpenGL
    – Type level siteswaps
Siteswap Notation
• Encodes timing of throws
• Ignores hand positions
• E.g.
  – 3-ball cascade ‘3,3,3,3,…’
  – 3-ball shower ‘5,1,5,1,…’
  – 4-ball fountain ‘4,4,4,4,…’
Siteswap Notation
• Hands alternate
  – Even numbers indicate throws to the same hand
  – Odd numbers indicate throws to the other hand
• Current ball will be thrown again after N-1
  beats
• Period = length (* 2)
• Number of props = average value
• 0 is a pause with an empty hand
Space Time Diagrams
• Tracks the orbit of each balls between the
  hands
• Axes represent
  – Time
  – Ball position
• Time axis is divided into beats
Space Time Diagrams
                            LH

333

                            RH
                            LH

15

                            RH

                            LH

423

                            RH
State Diagrams
•   Tracks when balls in the air will land
•   An × indicates a ball scheduled to land
•   A - indicates a free hand
•   E.g.
    – 3-ball cascade: ×××--
    – 3-ball shower: ×-×-× → ××-×- → ×-×-×
    – 4-ball fountain: ××××-
State Diagrams
• To “throw” a 0, shift the pattern to the left:
  – -×××- →0 ×××--
• To throw to height N, shift and insert an × at
  the Nth place:
  – ×××-- →5 ××--×
• State diagrams and heights form the vertices
  and edges of a directed graph.
• Valid siteswaps are cycles in this graph.
State Diagrams


 ×××--                 ××-×-



 -×××-                 ×-××-




E.g. 3 props, maximum height 4
Translation
             Siteswap       Space Time      State Diagram
Period       Length (* 2)   Tiling Period   Cycle Length (* 2)
# of Props   Average        # of Orbits     # of ×’s
Height       Value          Horizontal      Max node label
                            Distance        length
Why Haskell?
• Type safety
• Side effects are isolated
• Succinct
  – Pattern matching
  – Polymorphism
  – Higher order functions
Code Break
•   Finding Valid Siteswaps
•   throw, throwMany, foldM
•   graph, generateGraph
•   E.g. all patterns decorating a 3-cascade
•   E.g. over combinator
HOpenGL
• Provides a high-level interface to the OpenGL
  bindings.
• Computations take place in IO
• E.g. preservingMatrix :: IO a -> IO a
• Use powerful existing tools, e.g. mapM
Code Break
• Animating Siteswaps
• IORef
• E.g. insert
Type Level Siteswaps
• Idea: Can we use the type system to identify
  valid siteswaps?
• E.g. Can we improve on the type of (++) for
  concatenating patterns?
• Use singleton types, type classes and fundeps
  to encode the state graph in the type system.
Code Break
• Type Level Siteswaps
Questions?

More Related Content

Similar to Teaching haskell to juggle

Graphing lines pp
Graphing lines ppGraphing lines pp
Graphing lines ppmasljr
 
Data_Visualization.pdf
Data_Visualization.pdfData_Visualization.pdf
Data_Visualization.pdfNRSHEKAR
 
Finding the slope of a line edmodo
Finding the slope of a line edmodoFinding the slope of a line edmodo
Finding the slope of a line edmodoshumwayc
 
Calculus notes ch 6
Calculus notes ch 6Calculus notes ch 6
Calculus notes ch 6debukks6
 
2.4 Writing Equations of Lines
2.4 Writing Equations of Lines2.4 Writing Equations of Lines
2.4 Writing Equations of Lineshisema01
 
1. Permutation and Combination.pdfjskkshssh
1. Permutation and Combination.pdfjskkshssh1. Permutation and Combination.pdfjskkshssh
1. Permutation and Combination.pdfjskkshsshJayveeRouge
 

Similar to Teaching haskell to juggle (11)

MATLAB PLOT.pdf
MATLAB PLOT.pdfMATLAB PLOT.pdf
MATLAB PLOT.pdf
 
Graphing lines pp
Graphing lines ppGraphing lines pp
Graphing lines pp
 
Data_Visualization.pdf
Data_Visualization.pdfData_Visualization.pdf
Data_Visualization.pdf
 
Lecture24
Lecture24Lecture24
Lecture24
 
Finding the slope of a line edmodo
Finding the slope of a line edmodoFinding the slope of a line edmodo
Finding the slope of a line edmodo
 
CARTESIAN PLANE.pptx
CARTESIAN PLANE.pptxCARTESIAN PLANE.pptx
CARTESIAN PLANE.pptx
 
Permutation and combination
Permutation and combinationPermutation and combination
Permutation and combination
 
Sudoku
SudokuSudoku
Sudoku
 
Calculus notes ch 6
Calculus notes ch 6Calculus notes ch 6
Calculus notes ch 6
 
2.4 Writing Equations of Lines
2.4 Writing Equations of Lines2.4 Writing Equations of Lines
2.4 Writing Equations of Lines
 
1. Permutation and Combination.pdfjskkshssh
1. Permutation and Combination.pdfjskkshssh1. Permutation and Combination.pdfjskkshssh
1. Permutation and Combination.pdfjskkshssh
 

Recently uploaded

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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...Miguel Araújo
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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)wesley chun
 
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 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
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 Processorsdebabhi2
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 

Recently uploaded (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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)
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

Teaching haskell to juggle

  • 1. Teaching Haskell To Juggle Phil Freeman
  • 2. Agenda • Theory • Finding valid patterns and their states • Why Haskell? • If there’s time: – Animating siteswaps with HOpenGL – Type level siteswaps
  • 3. Siteswap Notation • Encodes timing of throws • Ignores hand positions • E.g. – 3-ball cascade ‘3,3,3,3,…’ – 3-ball shower ‘5,1,5,1,…’ – 4-ball fountain ‘4,4,4,4,…’
  • 4. Siteswap Notation • Hands alternate – Even numbers indicate throws to the same hand – Odd numbers indicate throws to the other hand • Current ball will be thrown again after N-1 beats • Period = length (* 2) • Number of props = average value • 0 is a pause with an empty hand
  • 5. Space Time Diagrams • Tracks the orbit of each balls between the hands • Axes represent – Time – Ball position • Time axis is divided into beats
  • 6. Space Time Diagrams LH 333 RH LH 15 RH LH 423 RH
  • 7. State Diagrams • Tracks when balls in the air will land • An × indicates a ball scheduled to land • A - indicates a free hand • E.g. – 3-ball cascade: ×××-- – 3-ball shower: ×-×-× → ××-×- → ×-×-× – 4-ball fountain: ××××-
  • 8. State Diagrams • To “throw” a 0, shift the pattern to the left: – -×××- →0 ×××-- • To throw to height N, shift and insert an × at the Nth place: – ×××-- →5 ××--× • State diagrams and heights form the vertices and edges of a directed graph. • Valid siteswaps are cycles in this graph.
  • 9. State Diagrams ×××-- ××-×- -×××- ×-××- E.g. 3 props, maximum height 4
  • 10. Translation Siteswap Space Time State Diagram Period Length (* 2) Tiling Period Cycle Length (* 2) # of Props Average # of Orbits # of ×’s Height Value Horizontal Max node label Distance length
  • 11. Why Haskell? • Type safety • Side effects are isolated • Succinct – Pattern matching – Polymorphism – Higher order functions
  • 12. Code Break • Finding Valid Siteswaps • throw, throwMany, foldM • graph, generateGraph • E.g. all patterns decorating a 3-cascade • E.g. over combinator
  • 13. HOpenGL • Provides a high-level interface to the OpenGL bindings. • Computations take place in IO • E.g. preservingMatrix :: IO a -> IO a • Use powerful existing tools, e.g. mapM
  • 14. Code Break • Animating Siteswaps • IORef • E.g. insert
  • 15. Type Level Siteswaps • Idea: Can we use the type system to identify valid siteswaps? • E.g. Can we improve on the type of (++) for concatenating patterns? • Use singleton types, type classes and fundeps to encode the state graph in the type system.
  • 16. Code Break • Type Level Siteswaps