Upcoming SlideShare
×

301
-1

Published on

Published in: Technology
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
301
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
2
0
Likes
0
Embeds 0
No embeds

No notes for slide

1. 1. Teaching Haskell To Juggle Phil Freeman
2. 2. Agenda• Theory• Finding valid patterns and their states• Why Haskell?• If there’s time: – Animating siteswaps with HOpenGL – Type level siteswaps
3. 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. 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. 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. 6. Space Time Diagrams LH333 RH LH15 RH LH423 RH
7. 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. 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. 9. State Diagrams ×××-- ××-×- -×××- ×-××-E.g. 3 props, maximum height 4
10. 10. Translation Siteswap Space Time State DiagramPeriod Length (* 2) Tiling Period Cycle Length (* 2)# of Props Average # of Orbits # of ×’sHeight Value Horizontal Max node label Distance length
11. 11. Why Haskell?• Type safety• Side effects are isolated• Succinct – Pattern matching – Polymorphism – Higher order functions
12. 12. Code Break• Finding Valid Siteswaps• throw, throwMany, foldM• graph, generateGraph• E.g. all patterns decorating a 3-cascade• E.g. over combinator
13. 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. 14. Code Break• Animating Siteswaps• IORef• E.g. insert
15. 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. 16. Code Break• Type Level Siteswaps
17. 17. Questions?
1. #### A particular slide catching your eye?

Clipping is a handy way to collect important slides you want to go back to later.