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

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 connectorsNanddeep Nachan
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
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 challengesrafiqahmad00786416
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
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...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
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 businesspanagenda
 
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...Zilliz
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
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...Martijn de Jong
 
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
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
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 TerraformAndrey Devyatkin
 
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 WorkerThousandEyes
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
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 REVIEWERMadyBayot
 

Recently uploaded (20)

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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
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
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
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...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
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...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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...
 
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, ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
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
 
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
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

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