Embark on an informative and fun journey through everything you need to know to understand how the Applicative instance for functions makes for a terse palindrome checker function definition in point-free style. ]]>

Embark on an informative and fun journey through everything you need to know to understand how the Applicative instance for functions makes for a terse palindrome checker function definition in point-free style. ]]>

(download for flawless slides) * Explore a terser definition of the Option Monad that uses a Scala 3 enum as an Algebraic Data Type. * In the process, have a tiny bit of fun with Scala 3 enums. * Get a refresher on the Functor and Monad laws. * See how easy it is to use Scala 3 extension methods, e.g. to add convenience methods and infix operators. The diagrams for function composition and Kleisli composition were made using https://q.uiver.app/ by https://twitter.com/varkora. Source code: https://github.com/philipschwarz/scala-3-enum-for-terser-option-monad-algebraic-data-type Errata: slide 14 is an unwanted leftover - it is the same as slide 15 minus a diagram. on slide 19, the colons in the extension method declarations are not needed]]>

(download for flawless slides) * Explore a terser definition of the Option Monad that uses a Scala 3 enum as an Algebraic Data Type. * In the process, have a tiny bit of fun with Scala 3 enums. * Get a refresher on the Functor and Monad laws. * See how easy it is to use Scala 3 extension methods, e.g. to add convenience methods and infix operators. The diagrams for function composition and Kleisli composition were made using https://q.uiver.app/ by https://twitter.com/varkora. Source code: https://github.com/philipschwarz/scala-3-enum-for-terser-option-monad-algebraic-data-type Errata: slide 14 is an unwanted leftover - it is the same as slide 15 minus a diagram. on slide 19, the colons in the extension method declarations are not needed]]>

(download for best quality slides) Gain a deeper understanding of why right folds over very large and infinite lists are sometimes possible in Haskell. See how lazy evaluation and function strictness affect left and right folds in Haskell. Learn when an ordinary left fold results in a space leak and how to avoid it using a strict left fold. This version eliminates some minor imperfections and corrects the following two errors: slide 15: "as sharing is required" should be "as sharing is not required" slide 43: 푠푓표푙푑푙 (⊕) 푎 should be 푠푓표푙푑푙 (⊕) 푒 ]]>

(download for best quality slides) Gain a deeper understanding of why right folds over very large and infinite lists are sometimes possible in Haskell. See how lazy evaluation and function strictness affect left and right folds in Haskell. Learn when an ordinary left fold results in a space leak and how to avoid it using a strict left fold. This version eliminates some minor imperfections and corrects the following two errors: slide 15: "as sharing is required" should be "as sharing is not required" slide 43: 푠푓표푙푑푙 (⊕) 푎 should be 푠푓표푙푑푙 (⊕) 푒 ]]>

This slide deck can work both as an aide mémoire (memory jogger), or as a first (not completely trivial) example of using left folds, left scans and iteration, to implement mathematical induction. This is just an updated version of the original slide deck which makes minor improvements and minor corrections in almost half of the slides. (for best quality images, either download or view here: https://philipschwarz.dev/fpilluminated/?page_id=455) You can see the Scala code here: https://github.com/philipschwarz/fp-fold-scan-iterate-triad-a-first-example-scala]]>

This slide deck can work both as an aide mémoire (memory jogger), or as a first (not completely trivial) example of using left folds, left scans and iteration, to implement mathematical induction. This is just an updated version of the original slide deck which makes minor improvements and minor corrections in almost half of the slides. (for best quality images, either download or view here: https://philipschwarz.dev/fpilluminated/?page_id=455) You can see the Scala code here: https://github.com/philipschwarz/fp-fold-scan-iterate-triad-a-first-example-scala]]>

(download for flawless image quality) Can a left fold ever work over an infinite list? What about a right fold? Find out. Learn about the other two functions used by functional programmers to implement mathematical induction: iterating and scanning. Learn about the limitations of the accumulator technique and about tupling, a technique that is the dual of the accumulator trick.]]>

(download for flawless image quality) Can a left fold ever work over an infinite list? What about a right fold? Find out. Learn about the other two functions used by functional programmers to implement mathematical induction: iterating and scanning. Learn about the limitations of the accumulator technique and about tupling, a technique that is the dual of the accumulator trick.]]>

(download for best quality slides) Gain a deeper understanding of why right folds over very large and infinite lists are sometimes possible in Haskell. See how lazy evaluation and function strictness affect left and right folds in Haskell. Learn when an ordinary left fold results in a space leak and how to avoid it using a strict left fold. Errata: slide 15: "as sharing is required" should be "as sharing is not required" slide 43: 𝑠𝑓𝑜𝑙𝑑𝑙 (⊕) 𝑎 should be 𝑠𝑓𝑜𝑙𝑑𝑙 (⊕) 𝑒 ]]>

(download for best quality slides) Gain a deeper understanding of why right folds over very large and infinite lists are sometimes possible in Haskell. See how lazy evaluation and function strictness affect left and right folds in Haskell. Learn when an ordinary left fold results in a space leak and how to avoid it using a strict left fold. Errata: slide 15: "as sharing is required" should be "as sharing is not required" slide 43: 𝑠𝑓𝑜𝑙𝑑𝑙 (⊕) 𝑎 should be 𝑠𝑓𝑜𝑙𝑑𝑙 (⊕) 𝑒 ]]>

This slide deck can work both as an aide mémoire (memory jogger), or as a first (not completely trivial) example of using left folds, left scans and iteration, to implement mathematical induction. Errata: on almost half of the slides there is some minor typo or imperfection or in some cases a minor error and in one case, an omission. See a later version for corrections and some improvements. (for best quality images, either download or view here: https://philipschwarz.dev/fpilluminated/?page_id=455) Scala code for latest version: https://github.com/philipschwarz/fp-fold-scan-iterate-triad-a-first-example-scala ]]>

This slide deck can work both as an aide mémoire (memory jogger), or as a first (not completely trivial) example of using left folds, left scans and iteration, to implement mathematical induction. Errata: on almost half of the slides there is some minor typo or imperfection or in some cases a minor error and in one case, an omission. See a later version for corrections and some improvements. (for best quality images, either download or view here: https://philipschwarz.dev/fpilluminated/?page_id=455) Scala code for latest version: https://github.com/philipschwarz/fp-fold-scan-iterate-triad-a-first-example-scala ]]>

(download for flawless image quality) Can a left fold ever work over an infinite list? What about a right fold? Find out. Learn about the other two functions used by functional programmers to implement mathematical induction: iterating and scanning. Learn about the limitations of the accumulator technique and about tupling, a technique that is the dual of the accumulator trick.]]>

(download for flawless image quality) Can a left fold ever work over an infinite list? What about a right fold? Find out. Learn about the other two functions used by functional programmers to implement mathematical induction: iterating and scanning. Learn about the limitations of the accumulator technique and about tupling, a technique that is the dual of the accumulator trick.]]>

In the functional programming paradigm, the programmer does not need to write any loops or use array indices. Instead, functional programers deal with iterative calculations by translating mathematical induction directly into code, so that they can reason about sequences as mathematical values. The implement mathematical induction by folding, scanning and iterating. This slide deck simply corrects a typo in the original (a missing 'h' in a couple of occurrences of 'mathematical')]]>

In the functional programming paradigm, the programmer does not need to write any loops or use array indices. Instead, functional programers deal with iterative calculations by translating mathematical induction directly into code, so that they can reason about sequences as mathematical values. The implement mathematical induction by folding, scanning and iterating. This slide deck simply corrects a typo in the original (a missing 'h' in a couple of occurrences of 'mathematical')]]>

In the functional programming paradigm, the programmer does not need to write any loops or use array indices. Instead, functional programers deal with iterative calculations by translating mathematical induction directly into code, so that they can reason about sequences as mathematical values. The implement mathematical induction by folding, scanning and iterating. Ouch - a couple of occurrences of 'mathematical' are misspelled (missing h) :-(]]>

In the functional programming paradigm, the programmer does not need to write any loops or use array indices. Instead, functional programers deal with iterative calculations by translating mathematical induction directly into code, so that they can reason about sequences as mathematical values. The implement mathematical induction by folding, scanning and iterating. Ouch - a couple of occurrences of 'mathematical' are misspelled (missing h) :-(]]>

single slide - folding a list right and left using cons and nil results in the identity and reverse functions - DOWNLOAD for original quality This version corrects the name of the base case value in fold left from z to e, to be consistent with its name elsewhere in the slide. It also drops the superfluous parentheses around the lambdas in the top right corner of the slide. ]]>

single slide - folding a list right and left using cons and nil results in the identity and reverse functions - DOWNLOAD for original quality This version corrects the name of the base case value in fold left from z to e, to be consistent with its name elsewhere in the slide. It also drops the superfluous parentheses around the lambdas in the top right corner of the slide. ]]>

single slide - folding a list right and left using cons and nil results in the identity and reverse functions - DOWNLOAD for original quality]]>

single slide - folding a list right and left using cons and nil results in the identity and reverse functions - DOWNLOAD for original quality]]>

(download for flawless quality) Develop the correct intuitions of what fold left and fold right actually do, and how different these two functions are. Learn other important concepts about folding, thus reinforcing and expanding on the material seen in parts 1 and 2. Includes a brief introduction to (or refresher of) asymptotic analysis and 훩-notation. Part 3 - through the work of Tony Morris and Richard Bird. This new version simply corrects a typo on slide 2 and makes some clarifications/corrections on slide 40. ]]>

(download for flawless quality) Develop the correct intuitions of what fold left and fold right actually do, and how different these two functions are. Learn other important concepts about folding, thus reinforcing and expanding on the material seen in parts 1 and 2. Includes a brief introduction to (or refresher of) asymptotic analysis and 훩-notation. Part 3 - through the work of Tony Morris and Richard Bird. This new version simply corrects a typo on slide 2 and makes some clarifications/corrections on slide 40. ]]>

(download for flawless quality) Develop the correct intuitions of what fold left and fold right actually do, and how different these two functions are Learn other important concepts about folding, thus reinforcing and expanding on the material seen in parts 1 and 2 Includes a brief introduction to (or refresher of) asymptotic analysis and 𝛩-notation Part 3 - through the work of Tony Morris and Richard Bird]]>

(download for flawless quality) Develop the correct intuitions of what fold left and fold right actually do, and how different these two functions are Learn other important concepts about folding, thus reinforcing and expanding on the material seen in parts 1 and 2 Includes a brief introduction to (or refresher of) asymptotic analysis and 𝛩-notation Part 3 - through the work of Tony Morris and Richard Bird]]>

(download for perfect quality) See aggregation functions defined inductively and implemented using recursion. Learn how in many cases, tail-recursion and the accumulator trick can be used to avoid stack-overflow errors. Watch as general aggregation is implemented and see duality theorems capturing the relationship between left folds and right folds. Through the work of Sergei Winitzki and Richard Bird. This version corrects the following issues: slide 32: = reverse --> reverse = Slide 33: 100_000 -> 1_000_000 It also adds slides 36, 37 and 38]]>

(download for perfect quality) See aggregation functions defined inductively and implemented using recursion. Learn how in many cases, tail-recursion and the accumulator trick can be used to avoid stack-overflow errors. Watch as general aggregation is implemented and see duality theorems capturing the relationship between left folds and right folds. Through the work of Sergei Winitzki and Richard Bird. This version corrects the following issues: slide 32: = reverse --> reverse = Slide 33: 100_000 -> 1_000_000 It also adds slides 36, 37 and 38]]>

If you liked Part 1 of the 'Folding Unfolded' slide deck series [1], then how about a code kata to cement your understanding of folding? Doing the kata, or even just perusing through the problems and solutions in the kata’s source code, will increase your chances of fully grokking and retaining the concept of folding. [1] https://www.slideshare.net/pjschwarz/folding-unfolded-polyglot-fp-for-fun-and-profit-haskell-and-scala]]>

If you liked Part 1 of the 'Folding Unfolded' slide deck series [1], then how about a code kata to cement your understanding of folding? Doing the kata, or even just perusing through the problems and solutions in the kata’s source code, will increase your chances of fully grokking and retaining the concept of folding. [1] https://www.slideshare.net/pjschwarz/folding-unfolded-polyglot-fp-for-fun-and-profit-haskell-and-scala]]>

(download for perfect quality) - See how recursive functions and structural induction relate to recursive datatypes. Follow along as the fold abstraction is introduced and explained. Watch as folding is used to simplify the definition of recursive functions over recursive datatypes Part 1 - through the work of Richard Bird and Graham Hutton. This version corrects the following issues: slide 7, 11 fib(0) is 0,rather than 1 slide 23: was supposed to be followed by 2-3 slides recapitulating definitions of factorial and fibonacci with and without foldr, plus translation to scala slide 36: concat not invoked in concat example slides 48 and 49: unwanted 'm' in definition of sum throughout: a couple of typographical errors throughout: several aesthetic imperfections (wrong font, wrong font colour)]]>

(download for perfect quality) - See how recursive functions and structural induction relate to recursive datatypes. Follow along as the fold abstraction is introduced and explained. Watch as folding is used to simplify the definition of recursive functions over recursive datatypes Part 1 - through the work of Richard Bird and Graham Hutton. This version corrects the following issues: slide 7, 11 fib(0) is 0,rather than 1 slide 23: was supposed to be followed by 2-3 slides recapitulating definitions of factorial and fibonacci with and without foldr, plus translation to scala slide 36: concat not invoked in concat example slides 48 and 49: unwanted 'm' in definition of sum throughout: a couple of typographical errors throughout: several aesthetic imperfections (wrong font, wrong font colour)]]>

(download for perfect quality) See aggregation functions defined inductively and implemented using recursion. Learn how in many cases, tail-recursion and the accumulator trick can be used to avoid stack-overflow errors. Watch as general aggregation is implemented and see duality theorems capturing the relationship between left folds and right folds. Through the work of Sergei Winitzki and Richard Bird. ]]>

(download for perfect quality) See aggregation functions defined inductively and implemented using recursion. Learn how in many cases, tail-recursion and the accumulator trick can be used to avoid stack-overflow errors. Watch as general aggregation is implemented and see duality theorems capturing the relationship between left folds and right folds. Through the work of Sergei Winitzki and Richard Bird. ]]>

(download for perfect quality) - See how recursive functions and structural induction relate to recursive datatypes. Follow along as the fold abstraction is introduced and explained. Watch as folding is used to simplify the definition of recursive functions over recursive datatypes Part 1 - through the work of Richard Bird and Graham Hutton. Errata: slide 7, 11 fib(0) is 0,rather than 1 slide 23: was supposed to be followed by 2-3 slides recapitulating definitions of factorial and fibonacci with and without foldr, plus translation to scala slide 36: concat not invoked in concat example slides 48 and 49: unwanted 'm' in definition of sum throughout: a couple of typographical errors throughout: several aesthetic imperfections (wrong font, wrong font colour) ]]>

(download for perfect quality) - See how recursive functions and structural induction relate to recursive datatypes. Follow along as the fold abstraction is introduced and explained. Watch as folding is used to simplify the definition of recursive functions over recursive datatypes Part 1 - through the work of Richard Bird and Graham Hutton. Errata: slide 7, 11 fib(0) is 0,rather than 1 slide 23: was supposed to be followed by 2-3 slides recapitulating definitions of factorial and fibonacci with and without foldr, plus translation to scala slide 36: concat not invoked in concat example slides 48 and 49: unwanted 'm' in definition of sum throughout: a couple of typographical errors throughout: several aesthetic imperfections (wrong font, wrong font colour) ]]>

Download for much higher quality version of the slides. Start with expression ma flatMap f and keep refactoring it by applying each of ⑧ rewrite rules in turn, until you get back to ma flatMap f. ]]>

Download for much higher quality version of the slides. Start with expression ma flatMap f and keep refactoring it by applying each of ⑧ rewrite rules in turn, until you get back to ma flatMap f. ]]>

]]>

]]>

]]>

]]>