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
 

Similar to Teaching haskell to juggle (10)

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
 

Recently uploaded

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
 
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].pdfOverkill Security
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
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
 
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.pptxRustici Software
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
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
 
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
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
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
 
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 FresherRemote DBA Services
 

Recently uploaded (20)

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
 
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
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
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
 
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
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
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
 
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
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
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
 
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
 

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