Created
July 2, 2022 06:44
-
-
Save monadplus/3eb530a9972c79dbbe6cbc9f2aaed7b0 to your computer and use it in GitHub Desktop.
Point-Free or Die: Tacit Programming in Haskell and Beyond
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {- Point-Free or Die: Tacit Programming in Haskell and Beyond | |
| https://www.youtube.com/watch?v=seVSlKazsNk | |
| g . f = (.) g f x | |
| = \x -> g (f x) | |
| = \x -> g $ f x | |
| = \x -> g . f $ x | |
| = g . f | |
| aggregate f = sum . map f | |
| aggregate f = (.) sum (map f) | |
| aggregate f = (.) sum $ map f | |
| aggregate f = (.) sum . map $ f | |
| aggregate = \f -> (.) sum . map $ f | |
| aggregate = (.) sum . map | |
| aggregate = (sum .) . map | |
| (sum .) . map | |
| \f g -> (f .) . g | |
| -- Eta abstraction | |
| \f g -> (f .) . g | |
| \f g x -> (f .) . g $ x | |
| \f g x -> (f .) $ g x | |
| \f g x -> (f .) (g x) | |
| \f g x -> f . (g x) | |
| \f g x y -> f $ (g x) y | |
| \f g x y -> f (g x y) | |
| -- New combinator: blackbird | |
| f ... g = (f .) . g | |
| - \x y -> f (g x y) | |
| -- Mastermind game | |
| exactMatches = length . filter id ... zipWith (==) | |
| colorMatches ps qs = sum $ zipWith min (countColors ps) (countColors qs) | |
| colorMatches ps qs = sum $ (zipWith min `on` countColors) ps qs | |
| colorMatches = sum ... zipWith min `on` countColors | |
| -} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment