Summarized using AI

Keynote: Red Fantasy Land

Brandon Weaver • November 15, 2024 • Chicago, IL • Keynote

Red Fantasy Land: A Journey Through Functional Programming in Ruby

Overview

In this engaging keynote titled "Red Fantasy Land," Brandon Weaver takes the audience on a whimsical journey through the world of Ruby programming, focusing on functional programming concepts intertwined with a narrative featuring colorful lemurs and a fictional setting. The story serves as an innovative approach to illustrate complex programming ideas, making them more accessible and relatable.

Key Points Discussed

  • Introduction to Functional Programming Concepts

    • Weaver introduces characters from a fantastical world, using them to explore functional programming concepts such as functions, maps, and reduces in an engaging way.
    • The narrative includes the characters Indigo and the eer cat, exploring forbidden knowledge in a library, setting the stage for the subsequent exploration of programming concepts.
  • Understanding Functions in Ruby

    • The talk explains basic functions in Ruby, categorizing them into lambdas and procs.
    • Functional composition is introduced as a method to glue smaller functions together to achieve larger programming tasks.
  • Key Functional Concepts Explored

    • Map: Demonstrates how map can transform elements in an array or a collection using block functions.
    • Reduce: Discusses how reduce can condense collections into a single value through accumulation.
    • Contextual Understanding: Emphasizes that empty values and results’ context can significantly affect programming outcomes.
  • Advanced Functional Programming Techniques

    • Introduces the concept of mappable and reducible things in programming and draws parallels between functions in Ruby and theoretical concepts like monads.
    • Explores practical applications and specific programming constructs that illustrate these concepts, particularly in a Ruby context.
  • Conclusion and Community Message

    • Brandon emphasizes the importance of community in programming, encouraging the defense of integrity within programming communities.
    • He concludes with a call to embrace unconventional learning paths and a reminder that Ruby, like any language, evolves with its practitioners.

Throughout the talk, Weaver effectively combines storytelling with technical instruction, creating a memorable learning experience that promotes deeper understanding of functional programming principles in Ruby.

Keynote: Red Fantasy Land
Brandon Weaver • November 15, 2024 • Chicago, IL • Keynote

RubyConf 2024

00:00:16.119 um you're not here to listen to me vampo you're here to see some
00:00:29.039 the years and excited to see this next version for those of you who haven't had
00:00:35.520 an opportunity to see Brandon speak again I'm just a really a really big fan of the people that we bring up on stage
00:00:41.800 and hopefully we'll see you up here in the future but now it's Brandon so Brandon is a senior staff engineer at
00:00:48.440 one medical he's an artist term programmer who teaches Ruby with a series of colorful cartoon lemur going
00:00:55.320 on storybook Adventures these socks have featured everything from conducting Symphony orchestras on cell phones to the deepest
00:01:02.920 and darkest corners of the Ruby programming language this time he's
00:01:08.280 brought something special to share and he looks forward to sharing it all with you so without further Ado everyone
00:01:25.560 Weaver so let's go ahead and get started you see I have a magic little book here and
00:01:33.119 this magic little book has a Nifty little trick is that as soon as I turn this
00:01:38.799 we're going to see the slid start turning over here as well so hello hello so glad you can make it today grab a
00:01:44.759 seat because we're about to get started but first who am I well simply put my name is Brandon I love Ruby and I'm here
00:01:51.880 to share that with you today and right now I'm over at Amazon's One Medal delivering provider efficiency and
00:01:58.159 trying to take care of folks and today I brought something special a story I've wanted to tell for quite a
00:02:04.320 while but it was very hard to fit into a typical talk a story I deeply enjoyed writing and I hope that you will enjoy
00:02:10.679 it as well but before that a quick note each major section of
00:02:16.640 the talk whether it's a story segment or code segment along with the Lemurs that we speak in each section you're going to
00:02:22.239 see a little popup if it's code segment there will be a QR code on that main slide and all subsequent code slides in
00:02:28.040 that section will point to the same file with examples if you miss one don't worry we are going to post it in a slack
00:02:34.160 Channel called red and fantasy land and you can also find them after the talk with that said though shall we go
00:02:42.040 ahead and get started deep in the
00:02:49.680 library we find ourselves in the Grand City Library of the master Violet an infinite well of information and wisdom
00:02:55.440 in the world of lemur why the library well you see there's a particular particularly naughty lemur you might see
00:03:01.879 down there named Indigo who's been repeatedly banned from library along with his friend the eer cats it had been
00:03:08.360 six years since they last had the chance to teach functional programming by golly it was time to do it again and if
00:03:14.400 they're going to teach functional programming well they need something special this time they couldn't be out
00:03:19.560 Dum by the Lord Crimson or any of the other lemur and to do that they needed to go deep deep into the furthest
00:03:25.680 reaches the library where all the real fun books were hidden where light beun to fade in the magic round the swell
00:03:31.080 crackling in the air like stars in the sky now what was the best sign that something was truly fun well of course
00:03:37.040 the more chains and locks and spells and Wards the better if viot had gone through that much trouble and care to
00:03:42.480 keep them away then that's exactly the book they want so kind her to make it easy to pick wasn't it very
00:03:48.720 considerate and in this forbidden cve there was one book which stood out marked with the sacred Lambda symbol and
00:03:55.439 under the protection of lemur of a foreign land very far away from Ruby one sealed with ancient Magics and
00:04:01.959 binding spells locked tightly in Chains and on this cover we can faintly make out the text
00:04:08.439 Wonderworld upon opening the book a Blue Fog emerges the air in the room stirs and all lanterns extinguish there are
00:04:14.799 deep Magics here secret design patterns for lands of functional programming very different than what we might know from
00:04:20.079 objectoriented languages there are the functions mappable and reducible types and something else Beyond even them that
00:04:26.160 combined everything a name which must not be spoken loud because because who
00:04:32.280 cares rules rules rules who in the world reads All These Warnings anyway but the rest of this book Indigo cackles to
00:04:38.880 himself delighted discarding all the warning notes and warning spells as he exclaims the rest of this book is
00:04:45.759 perfect but they hear a noise a soft dump of slippers and light coming around the corner the master Library Violet was
00:04:53.039 awake she enters the deeper Parts Library Lantern in hand trying to figure out what in the world is going on why so many alarms have triggered there she
00:04:59.400 finds Indigo and the aser cat with a particularly dangerous book what exactly
00:05:05.320 are you Violet was cut off it'ser eer time to make an exit let's go let's go whispered Indigo bioid yells out after
00:05:12.240 him Indigo eer don't you dare we cannot have another eval incident especially not another mess with meta programming
00:05:18.440 so the eer cat smiled mischievously with a snap of its paw the two began to make their miraculous getaway baiting into
00:05:27.039 dust Violet side and goes to look at the place where the book once was seals undone and multiple
00:05:34.440 months of binding spell is broken the one book which must never be open the one subject which must never be taught
00:05:40.759 that will render its reader incapable of ever teaching it again a subject no wise lemur would ever dare touch lest they be
00:05:47.840 banished to the far lands all that remained was a scribbled note with a smiley face and a quickly drawn
00:05:55.880 thanks so Violet takes a moment collecting herself as the Shadows behind
00:06:00.919 her begin to stir and CES behind her several figures with hoods drawn over their faces the owners of the book come
00:06:08.280 from the distant functional lands they point to the missing book and the head lemur simply says it must be found for
00:06:15.919 there are some things the Lemur of this land are not ready for and something which must not be Unleashed upon its
00:06:21.880 Pages once before the Lord Crimson visited our lands to learn from it but even he was not foolish enough to teach
00:06:28.440 it here the words must not be spoken but agrees to this and answers
00:06:36.360 yes we can only hope that it's retrieved before that thing is let loose upon the world an ancient creature from time and
00:06:43.360 material graning its wisdom and terrifying its potential who cannot be comprehended by the
00:06:48.400 normaler the only question of course was where Indigo might unleash such a force and what if anything could be done to
00:06:54.160 stop him and the eer cat they could only hope no one would be caught up in such a catastrophe completely
00:07:04.160 unaware a new adventure speaking of unaware we find
00:07:10.919 our friend red lemur studying in a tiny Forest Grotto he was just finishing up his book searching for his next Enlightenment but he always found
00:07:16.759 himself returning to the classics he sigh and looked up to see saffron the
00:07:23.160 great Taylor sprinting right through with bolts of silk over his shoulder as he dashed by he heard him repeating something about tea parties and needed
00:07:29.319 to be early a piece of paper slipped out of his bundle and landed in front of red early early early why was he so obsessed
00:07:35.280 with being early and what was this about a tea party red was confused sat down his book and began to chase after
00:07:40.400 saffron wait wait where are you going why are you in such a hurry asked red so
00:07:45.759 many outfits to make so many costumes to make I need to be there early before the party starts anything through VV VIPs of
00:07:52.280 the tailor shop yel saffron he blew on by what tea party asked red check your
00:07:58.680 invitation sister you be invited as a guest of honor said saffron red stopped and took a look at the
00:08:05.080 invitation and side to himself and saw what appeared to be a scroll of crayon with arrows pointing
00:08:11.280 what looks like a staircase and when he looked up saffron was gone nowhere to be seen and in front of him was a giant
00:08:17.240 tree with a hole in it Center and a suspiciously well-designed sign that red fantasy land was it a trap probably did
00:08:25.639 Red particularly care probably not because there's far more fun in exploring and pushing the limits of what
00:08:31.879 we know than sitting still and accepting things as they are and he wasn't going to miss out on what this adventure was
00:08:37.000 for the world so he found himself climbing through a Labyrinth of stairs right side left side upside downside
00:08:42.360 which way was even up he found himself more and more lost but the same time approaching something until he found
00:08:48.320 himself at a Gateway a Gateway on the Press of a brand new Strange
00:08:56.880 Land The Forest of functions
00:09:07.120 upon exiting the strange Labyrinth he finds himself in a forest unlike anything he's seen before and in that Forest he can see a fire in the distance
00:09:13.640 and a few familiar voices the master lavender and Crimson were sitting by a fire drinking
00:09:20.600 tea was told Indigo was up to something again you think we should stop it he heard lavender saying why it seems
00:09:27.399 interesting so far who knows what else him in that cat came up with said Crimson it appears we have a guest shall
00:09:33.440 we serve him some tea said lavender just uh not a party we shouldn't interrupt those for later I emerged from the
00:09:39.680 forest confused and asked what in the world is going on in this place where are we the two looked at each other and
00:09:45.320 began to laugh and then Crimson answered it appears our friend Indigo and the eat are having their fun and they've been so
00:09:51.160 kind as to involve us in their little plans to get you ready and also to sply
00:09:56.320 tea for the little party responded lavender red confused to this to start
00:10:01.920 out with what is a function well Lambda a proc
00:10:07.279 right strictly speaking yes but what are they used for the problem in Ruby is that we see
00:10:14.279 it is almost a foreign parts of language but in my adventures in lands of function lemur I found something else
00:10:20.000 entirely what do you mean by that I mean that with only functions if
00:10:26.160 you're so inclined you could build entire programs by gluing them together should we take a look real quick let's
00:10:33.040 go ahead and start out with some basic functions so in Ruby there are a few
00:10:39.200 types of functions but generally they're categorized into two types lambdas and procs this talk we'll be focusing on
00:10:44.519 lambdas when writing explicit functions but there's another case we'll beginning too shortly where procs are more
00:10:50.440 common now functional programming works by gluing together smaller functions to do larger tasks and Ruby provides us
00:10:56.200 with just the glue to do that in this case we have two functions one
00:11:01.600 which adds five and one which multiplies by three Ruby can glue these two functions together using something
00:11:06.920 called functional composition and the operator is that double angle bracket that you see down
00:11:12.399 there in this case we can glue together the idea of adding five and multiplying three to make a new function which is
00:11:18.160 add five then multiply three we can call that to verify and see that it does indeed work and you can also see in
00:11:23.920 parentheses what that is actually doing you might think this looks very foreign why in the world would we do this Ruby
00:11:30.279 well you might think it's foreign and you might think you don't really care about functions but you already use them
00:11:35.560 and they're everywhere in Ruby and they're called blocks now this probably looks very
00:11:41.200 familiar it is in fact a function perhaps by a different name but a block block function function they're all
00:11:46.720 functions and in the end you're already using them everywhere block functions are actually procs under the hood as
00:11:52.279 well showing us that the second type of function is indeed used in this case they allow us to select out only the
00:11:57.880 even numbers of lists now if we wanted to make our own method which takes in a block function like
00:12:03.440 select we could do something very much like this but we'll go ahead and step
00:12:10.079 through that as well in this case we start with a function and we care
00:12:15.360 whether or not that function returns truthy or falsy so we're going to call it there for each item of the array really we could name it whatever we want
00:12:22.800 but the question is what it's being used for in this case we use to find the values in an array which are even and if
00:12:29.760 that happens to be true we add that to a new array which is then going to be returned at the end of the
00:12:36.720 method now as to how that would work we'll step through that a little bit differently now let's take a look at
00:12:43.920 what happens in this method and how the values flow through select step by step
00:12:49.079 for our first value one we check if it's even it's not so it does not go into the new array for the second value to it is
00:12:55.720 indeed even so we add that to the new array and for the third value three it's not even either so we do not add that to
00:13:01.800 the array which gives us back our final new array of two but one thing to keep in mind with
00:13:08.680 Ruby is there are many many different ways to do something which way is Right which way
00:13:14.360 is wrong long hand shorthand select filter explicit implicit really it
00:13:20.399 depends doesn't it which answer is correct depends in the code base you're working and the people you're working with aim first and foremost to be
00:13:26.959 understood and readable rather than being clever beyond that there are many
00:13:32.240 lessons from many other languages some very different philosophies you might find in Ruby all are valuable certainly
00:13:37.639 but be careful not to become dogmatic and with all that said there
00:13:43.000 are others to meet and lessons to be learned ahead of you from Friends old and new Alik said Crimson so with that
00:13:49.040 red wandered on to the next area you think we should warn him about
00:13:54.480 the lavender was cut off nah it'll be more fun if they find out themselves answer
00:14:04.839 Crimson The mappable
00:14:13.480 Meadows so we find red entering the mappable Meadows a place filled with flowers and plants of all kinds in there
00:14:19.720 ahead he finds chartreuse his master from many years past that taught him the ways of a map but this is a different
00:14:25.160 place at a different time ah it's been What Now red six years my how time flies
00:14:30.800 and the young ones grow and so too does our understanding of what we think we already comprehend what do you mean Master last
00:14:38.199 time we spoke you taught me about map but wasn't implementing it with reduce all there was to learn what is
00:14:45.720 map well of course it's using a block function to transform every elemented list isn't
00:14:51.160 it yes that's true but there's far more to it let's take a look to start out with we'll take a look
00:14:58.560 at MTH consider this example we know that we
00:15:03.800 can double every element of list by applying a function that takes a parameter V and returns V * 2 but how do
00:15:10.240 we know it does that why do we know it does that how do we know that that block function is going to double every
00:15:15.680 element in list for an array it might look a little bit like this certainly but in doing so
00:15:21.759 we notice something very interesting is that we have an array in and we also have an array out that's because using
00:15:28.720 math in the context of Ruby's array returns a new array with every value transformed by that function but what if
00:15:35.319 it were a different type then the context would change what map does would change along with
00:15:41.040 it I'm not entirely sure what would happen in different contexts let's suppose that we Define
00:15:47.920 map for a string what might it look like now again the way we Define map
00:15:53.639 changes depending on the class and the context we're working with so in the case of a string perhaps map would make
00:16:00.360 a new string and then stepping through that we' take and iterate every
00:16:05.759 character of the current string and we would append to a new string by calling that function on each individual
00:16:12.040 character adding that to the new string and eventually we' return that from the end of the method which we would call
00:16:19.639 like this now it gives us something looks very similar to a map function for an
00:16:26.000 array but I think we can go a little bit further into explanation
00:16:34.279 perhaps we could Define map on string itself now certainly I would not
00:16:40.920 encourage this but we're discovering things today much like array deres map
00:16:46.240 from a numeral we can Define our own map directly in class now again I would not suggest doing this except as an example
00:16:52.680 the notable difference here is that we're getting characters directly from self which while not required to put
00:16:57.959 self in there does make it clear where it's coming from the other is that we're directly calling map on string
00:17:06.799 itself which gives us something a bit more ergonomic but I think we could go further even still we could Implement
00:17:14.199 map using map if we really wanted to so if we look at our original code
00:17:19.760 from before we could instead use map to
00:17:25.000 implement map now there's certainly no rule against it and it would sure not code a good deal too the two differences
00:17:30.280 here to look out for is now we're using map but we're also using join to add the characters back together to give us a
00:17:36.679 string in fact we could maybe even go further and we could condense our example using
00:17:44.720 shorthand now we can take our current code here which is using map and then we
00:17:49.960 can directly pass the function to it instead of trying to call it manually now that all said we should
00:17:56.960 probably not monkey patch core classes should we so what other options might we have
00:18:03.280 well modules might be a good start what if we wrap that in a module instead we can take our monkey patch
00:18:09.039 class and extract it into a new module and this will look very similar to what we already
00:18:15.080 have the problem with this is if we want to map more than once it quickly becomes unwieldy so we're going to have to find
00:18:21.960 another option What If instead we wrapped our string in a class of our own making
00:18:28.320 where we def the context and we Define the rules of how it
00:18:33.400 operates maybe we have a string characters class which has our own rules of how we decide to do map we could even
00:18:40.840 Define map on it directly but this map has a problem do you see what it might
00:18:48.679 be it returns back a string so what happens if you call a map on a string that's not been monkey
00:18:54.600 patched it means that code like this would air out and say string has no map
00:19:00.679 that's because we went outside of the context of the class which knew how to map in return a string is said so what
00:19:07.640 are we to do then well there's a Nifty little idea which is that we can bring
00:19:12.799 it back into the context of our string characters class by using a method we can call rap now that can be self.
00:19:18.640 class. new or it could be string characters. new but this is the more generic version It's a way to take a string and
00:19:25.320 put it back into the context of our string characters class and to use it we' add a wraparound our
00:19:31.240 implementation of map and then it would work just as we expected to but there's one thing to
00:19:37.039 keep in mind the value is still in the context of our string characters class we need
00:19:42.159 to get it back out having our own rules is great but our program probably doesn't want string characters it probably wants strings so how do we get
00:19:48.360 it back out well we can get it back out by calling value on
00:19:54.120 it so taking a look back at our implementation looks like we have something which be used elsewhere no
00:19:59.960 like w in the idea of a value what if we pulled that into our own inumerable like
00:20:05.159 module like let's let's say mapable to represent something which can be
00:20:10.320 mapped this is a basic example for making our own context but it serves a point by doing so our implementation of
00:20:16.600 string characters is shortened to this but what's more is it allows for us to
00:20:22.280 potentially make say a string words class now granted this is naive but it
00:20:27.520 serves a point or maybe even we have a string lines one the point is this behavior is very repeatable and by
00:20:33.919 establishing our own rules for map we can do a lot of things which might not make sense for direct classes like say
00:20:39.120 string or array we can even use this idea for something completely different like let's say take this single white
00:20:46.280 flower here could this also be mappable perhaps in the context of a
00:20:51.520 flower the color happens to be the value inside of it and if we take a look we
00:20:58.200 can see that mapping this context means to transform the color and return a new flower now the mistake a lot of people
00:21:03.840 make is that map can only be called on collections right no no not at all map can be called on anything anything is
00:21:09.760 technically transformable as long as it follows a few
00:21:16.400 rules to test that we could take colors like let's say the color is white and red here and we can create a new flower
00:21:22.960 where we makes 0% white with 100% red effectively painting this flower red
00:21:29.279 now there was once a song I'd heard from a movie long ago about painting flowers red but that's neither here nor
00:21:37.039 there but now that we have an idea of what it means for something to be mappable there are also a few rules we
00:21:42.960 must keep in mind ones you might already have noticed reason for earlier now there are three rules we need to keep in
00:21:49.039 mind for things which happen to be mappable the first rule is that doing nothing should unsurprisingly do nothing
00:21:56.640 what do I mean by that well let's start start out by defining equality for a mappable module for something is
00:22:02.480 mappable to be equal it should be the same type as well as have the same value inside of
00:22:07.960 it so let's take an example string like hey world and make an interesting little function here which does nothing it
00:22:14.200 takes in a parameter V and returns back V out the other ends and we'll also make
00:22:19.320 a new string characters instance and we'll call it a context here so afterwards we check if doing
00:22:26.240 nothing to that wrapper does in fact do nothing and we're g with the true and response that means that doing nothing
00:22:31.480 in the context of something which is mapable does well uh nothing now this might sound boring but
00:22:38.240 why do we care about this back to our module context and with string characters before we added WAP that
00:22:43.679 would have failed if it fails it means we're not returning the same type and we can think of it as a baseline test Ure a
00:22:48.760 mapable class works as expected rule two is if we call map twice with two different functions we
00:22:54.799 should get back the same result as if we compose the two and call map once instead dead now what do I mean by that
00:23:00.640 let's say we had two functions one which wrapped a character in Brackets and one which got the next successor character
00:23:06.159 afterwards to where a do successor would end up being B and let's take back our
00:23:13.039 example of hey world and our context here for an experiment in test that if
00:23:19.080 mapping twice to each function separately Returns the same as if we compos the two functions why do we care about this
00:23:26.200 because after all these are just functions our string character's class should not be doing anything unexpected to them like mutation or extra steps no
00:23:33.120 no no or more simply we do not wish to surprise people using it what you see is what you get and there should be no
00:23:38.799 surprises we may be able to Define our own rules but functions also have their own rules so should be very respectful
00:23:44.120 of that and we should be careful not to break them and do unexpected things though in some cases Ruby does
00:23:51.600 not exactly hold true with this such as hashes why exactly is that do you
00:23:57.880 suppose well in the case of Ruby's hash it doesn't behave this way because it
00:24:04.039 inherits map from inumerable and that means it's going to return an array instead we must be careful of this but
00:24:09.919 Ruby's hash also has a different method here which is two hash or 2 H which
00:24:16.320 behaves a lot more like what we might expect now does this mean we should change map on all hashes no no because
00:24:22.559 too much already relies on this behavior and changing it would be dangerous so you see red there's far
00:24:28.679 more to map than there appears to be an entire world of mapable things to discover out there in the wide world of Ruby we've only covered a small part of
00:24:35.120 their potential consider it a pattern to be used when you find things you're program with similar shapes that follow these
00:24:41.080 rules now this is all fascinating but where are we going with this why learn about context and values and mapping I'm
00:24:47.840 confused where you're going ah now that that's a lesson you'll be learning soon enough but it's not
00:24:53.399 mine to teach Journey on to the Tea Party where you find answerers to your questions there so with that red had
00:24:59.039 learned more about map and began walking to his next destination the reducible
00:25:13.600 residence as the colors transition from greens to Golds red finds himself on the path to the tailor shop on the edge of the forest a tailor shop that looked
00:25:20.039 almost exactly like the one from laville owned by saffron but how in the world they get here of all places so red went
00:25:26.520 to take a look and there at the end of the the path he sees a shop with various outfits and fabrics littered everywhere collecting smattering saffron had been
00:25:33.240 busy and just then red saw saffron bolt inside fabric flying everywhere behind him still droning about the Tea Party
00:25:39.640 what party and why was everything about being so early so red enters the shop and in find inside he finds saffron hly
00:25:46.279 finishing multiple outfits of all cuts and styles from fine party suits Imperial dresses and even a hat for a
00:25:51.760 cat so we had to ask what in the world are you doing here saffron preparing for the party of
00:25:58.720 course I'm a Lem of my word and I have a reputation for promptness to uphold Reds saffron stated proudly well I suppose it
00:26:05.039 be on my way then if you could just point me to the party up up up up up no you didn't think you came here for no
00:26:10.799 reason did you come now you're going to help me and to do that we're going to need to teach you about what it means to be reducible read Flinch but before he
00:26:17.640 can make for the door saffron was already starting into his lecture and what better way than to
00:26:23.240 start to answer the question of what does it mean to reduce of course we have a reduced
00:26:28.320 method in Ruby but it's not often used directly so let's take a little bit of a look at it and see what exactly it's doing here if you've never used reduce
00:26:35.679 this syntax is going to look very odd indeed what happens to the ray what's at zero there and what exactly is that
00:26:41.279 block function doing well let's step through it and see what exactly is doing we can take a look at the values of a
00:26:47.600 and v for each step of this reduce now granted this is condens for slide length but we'll give you some explanations in
00:26:53.960 the moment we start out with our base case of zero the first argument to reduce while we name it a here it stands
00:27:00.120 for accumulator and this is going to be accumulating values as we reduce into one thing and then we take one which is
00:27:05.960 our first value in the array as V and what we're doing is we're adding those together to get back a result of one so
00:27:12.399 what do we do with that result well we take it to the next iteration and now that's the new iterator the new
00:27:19.440 accumulator excuse me and we start again with that and then we add two to it
00:27:25.320 which gives us three which we then bring back again to be the next accumulator and then we
00:27:31.159 add three to that to get back six so what happens when we run out of numbers well that's our result right there it's
00:27:36.559 six and it's returned from reduce so taking a note from the top we are
00:27:42.240 effectively doing what we mentioned early which is adding 0 plus 1 plus 2 plus 3 or more accurately we're
00:27:49.640 combining in the leftward direction given that it's not surprising some other languages called Reduce by none
00:27:54.919 the name which is fold left but isn't that just the same as sum asked red exactly right but why there's
00:28:02.960 something very interesting here to explore so Ruby some method is far more common than reduced you're probably more
00:28:08.360 likely to see it so what exactly is that doing it simplifies a lot of what reduced can do I mean there's a single
00:28:14.480 call there you don't need to care about a block you don't need to care about a zero you don't need to care about anything else do you and after all it's
00:28:19.519 just the same as saying 1 plus 2 plus three right well you see there's an interesting property here which might look familiar what do you suppose might
00:28:26.679 happen if you uh summed nothing nothing what value do you think might it
00:28:33.320 get exactly right it turns out you get back zero that empty value that we happen to mention earlier which means
00:28:39.600 that what we're actually doing is something more like 0 plus 1 plus 2 plus 3 we're condensing it back down again 0
00:28:45.919 plus 1 plus 2 plus 3 but why does it work what magic is a foot here well that's where we are going to and I
00:28:52.159 apologize get into a smidgen of math not much though
00:28:59.440 so let's say that we took two numbers we can add them together and get back another number which is interesting is
00:29:05.200 that if you join two numbers together you get back another number but there's particularly interesting number in the
00:29:10.640 context here of if we add it to any number we get back that same number what might that number be in the context of
00:29:16.399 addition do you suppose exactly right in the context of
00:29:22.320 numbers in addition the empty value would be zero but let's say we change the context a little bit because what
00:29:27.440 matters here is not that we're dealing with numbers but the operation we use to join them together like let's say
00:29:33.000 instead of adding numbers we happen to uh multiply them instead by saying multiplying two and three gives us back
00:29:38.880 six if I happen to ask you what was empty in this context is it the same as
00:29:45.720 addition exactly right if we happen to do this I suppose not so that means
00:29:51.200 empty is very context dependent on what the type is as well as what way you use
00:29:56.960 to join them together so in the context of multiplication with numbers that means that we instead have
00:30:02.640 the value one to get products and we have things working again so we can add
00:30:07.840 numbers together great but does that all it can do who said anything about it only
00:30:13.120 applying to numbers there's certainly other types which are also
00:30:19.200 reducible we already know about a few ways which numbers reducible yes and we
00:30:24.240 can even shorthand that because we know how it works but red goes far beyond
00:30:29.559 that here are a few more examples of some basic types you might see and how they might reduce like string has an
00:30:34.919 empty string and plus or array has an empty array in Plus or hash has an empty hash and
00:30:40.559 merge active record has any scope in all all of these things happen to be
00:30:46.200 reducible and we can even get a few examples here to prove that's the case but there's one more type which is even
00:30:52.200 more interesting which is that functions are also reducible via composition gluing them
00:30:58.559 together with that interesting little function which does nothing just remember left word
00:31:04.360 composition goes backwards what you might think so if we do it in this direction we're going to get the first
00:31:10.360 last and last first which is going to give us this order but if we flip that around Ruby has two ways to compose
00:31:16.880 we're going to see that it actually changes the output so do be careful here of what you get as
00:31:22.679 results when adding numbers we get but the direction is going to look far more familiar to ring Elixir programmers by
00:31:29.279 using forward compos instead of the other way so if this is a pattern perhaps we
00:31:35.000 could look into generalizing it perhaps we want our own version of something which is reducible much like
00:31:40.240 mappable to do what we need is we need an empty value and a way to join two values and for our convenient sakes a
00:31:46.960 reduce method so this doesn't look too foreign right now is that we have an empty of zero a join which adds two
00:31:52.799 numbers together and reduce which reduces into that empty value and use a join there but if we flip this around to
00:32:00.039 multiplication we now notice that empty changes and join changes along with it because the context has changed we're
00:32:05.679 not talking about integer addition anymore now we can also make this into a
00:32:11.120 more General module and something like this and that we need to Define our own
00:32:16.960 version of empty which is why we have a not implemented error here because you do need to do that for yourself join we're going to assume that maybe they
00:32:22.760 have a plus class and be reasonable about it and reduce well most classes won't need to redefine this so they get
00:32:28.039 that for free so instead of using include we use extend well what's the difference we're extending this into the
00:32:34.840 class and the reason is because we're working on many things instead of just one thing in the context of adding
00:32:40.320 addition we don't need to overwrite join or reduce but we do need to Define what empty means in this context the same way
00:32:46.600 is we would need to redefine empty to be something different for product and join would be different because we're using
00:32:51.639 multiplication instead now as with mapable there are a few rules to observe here and something
00:32:57.240 that makes it red uble rule one is that we have a given
00:33:02.480 type like numbers in a way to combine two numbers that gives us back another number why is this important because we can't predictably keep combining things
00:33:08.600 if the types aren't the same the second rule is that as long as we retain the same order we can group
00:33:14.039 these conditions or joins together however the world we want and get back to the same result why does this matter
00:33:19.519 it means we can have intermediary results stored in variables or if we really wanted to we could parallelize it to thousands of computers using
00:33:25.880 something called map produce we just need to retain that same order now a particularly clever person might note
00:33:32.679 that for addition the order doesn't matter at all and you're correct but that is something beyond the scope of this talk the third rule is for something to
00:33:39.440 be reducible there should be an empty value of the same type that if you combine it with any other value you should get that value back why does this
00:33:46.200 matter well what do you do if you summon empty array it matters that we have a reasonable default to fall back on in
00:33:51.639 the sense of the context of what we're joining together can you imagine if inumerable didn't give us back an empty array if we had no elements back after
00:33:57.440 SEL it'd be chaos you'd be rescuing everywhere we might as well program Java at that
00:34:04.039 point so let's start with it's a little bit more complex class like move which we can represent movement on
00:34:11.040 a grid using data. Define think of this as just a quick initializer which has the properties X and Y attribute readers
00:34:17.280 and some other nice properties like equality we can create a new move just like any other class but we could also
00:34:23.399 shorthand that using square brackets here as well and given it extends
00:34:28.520 reducible that also means we have a reduced method for free that we can use here but the question is do the rules
00:34:34.280 still hold with that empty of 0 well checking on them we can see this
00:34:39.960 is true we can add two moves together and get back another move we can group them in any order in the same order and
00:34:45.839 get back the same result and there is an empty element which is not going to do anything or let's say we did something
00:34:51.879 even more interesting like let's say a clock did you know a clock happens to be reducible I know right
00:34:59.000 it always Loops back around from 12 to 1 so in this case the way we add things together is different in that we add the
00:35:05.079 times together but we modul 12 which means if you have 13 it goes back to one if you have 14 it goes back to two and
00:35:10.359 so on and so forth the rest probably looks similar to the Past example and you would be very
00:35:15.960 correct but does it hold and the answer is yes the rules do hold for this as
00:35:22.320 well so as you can see reduce is a very powerful idea and the idea of something being reducible could apply in a great many cases now this is all fascinating
00:35:30.160 but how in the world do you have an exact replica of your Taylor shop here isn't that horribly expensive asked
00:35:36.960 red I made Indigo and eat earn that VV VIP status that's how a few more Rush
00:35:43.040 orders like this and I'll have 20 shops that red side and left the shop
00:35:48.760 but no sooner than he left did the air crackle and indigo nesat emerged from
00:35:53.800 the closet in cloud of dust I'm afraid your aim needs some work there dearer but we got here all the
00:35:59.119 same so thank you friend now I need to ask saffron are we
00:36:04.160 ready anything for the VV VIP has come right this way sir and we'll be off and Away long before red finds his way to
00:36:10.440 the party I uh made sure to add a few small detours to your map ho you are
00:36:16.319 naughty I like you even more now and I hope you like these outfits as well saffron opened the closet IND good
00:36:23.319 eser stared wide eyed you sir are a master put it on a car
00:36:33.280 the Tea Party and now a special guest a convenient drink of
00:36:49.319 water we find ourselves in a forest but something feels wrong here we find red very lost trying to
00:36:56.520 follow the map and the sign but the forest belongs to a particularly mischievous cat named
00:37:02.280 eer where have I ended up surely I passed this tree many times already said red as he grumbles we see the eer cat
00:37:09.440 changing every single one of the signs whenever red stops paying attention always just out of sight and always gone
00:37:14.520 right before red turns to look so we see red turning and Fring wandering until at the edge of the forest we see a thumbs
00:37:20.160 up from Indigo and the eer cat smiling Somewhere In The Ether so red whipped around to see theer cat flipping a sign
00:37:26.720 buter wasn't least bit bothered by this casually flipping the line slowly and grinning from ear to ear tapping away at
00:37:33.240 the sign now hold on there you've been leading me around in circles for at least with wink the Asher cat
00:37:39.160 disappeared leaving the sign pointing towards the path to the end of the forest illuminated in strange glow well
00:37:45.319 we certainly could have started with that now then and with that red entered
00:37:50.920 so many lur old friends and new all colors and studies all celebrating over tea prepared by lavender and all turn to
00:37:56.319 greet him with cups raised High welcome to the Tea Party breed they said in unison as they turned the roll of drums behind them and as Indigo descended onto
00:38:03.240 the main table floating down from the sky with an umbrella and landing in a puff of smoke a merry young conference
00:38:08.839 to you dearest red a merry young conference indeed we've been expecting you young red and my have we waited for
00:38:14.640 this day come come right here right next to me so red walked over to Indigo I do
00:38:20.160 hope you've had fun so far and I assure you every bit of what you've learned so far is in fact very necessary for the
00:38:25.200 next lesson what what do you mean all those things are related for some reason I don't believe
00:38:30.800 you yes and no true enough but you'll know more as we dive in further should
00:38:36.520 we go ahead and get started let's start with the idea of something being
00:38:42.319 falsy let's say that we had this code if you wanted to cash it what might you
00:38:47.520 do your initial reaction might be something a little bit like this but
00:38:52.599 there's a slight problem here can you see what it might be
00:38:58.359 what happens if that API method returns false and even more what if that false is a legitimate results even worse what
00:39:05.880 if it was a terribly expensive call that took several minutes to operate as it turns out context is a
00:39:12.079 very useful thing and in this case we can use the context of Ready to Brew instance variables have not been set yet
00:39:17.520 on this class to determine whether or not we should call it API to get a value but this does break object shapes later
00:39:23.000 so do be careful without that context though we have a false value why wouldn't we try again now consider HTTP
00:39:30.599 responses for a moment which have a very interesting property to them let's say we had a response with some Json and
00:39:36.400 Response Code of 200 just looking at the body we might be able to guess whether something was successful but with the
00:39:43.000 status code we don't have to guess because it gives us additional context to make a decision based on what that
00:39:48.160 status code is should we process the data should we be handling a should we be redirecting should we be warning the
00:39:54.000 user they did something wrong well now we know but what if someone breaks those rules
00:40:00.440 what if someone does something naughty normally whenever we respond and get back to successful 200 we think it's
00:40:07.839 a good value we can parse it but that's also not a guarantee is it what if someone were to do something in cious
00:40:13.760 like say uh give you an error it blew up in here now that sounds silly you might
00:40:18.960 think who in the world would do this uh graphql will do this now granted and to be fair they do
00:40:25.760 this because the request of the server was successful I will grant them that but there's no guarantee all the content
00:40:31.319 inside the request at any layer or any depth happens to also be successful because things are
00:40:37.280 complicated now if we had no additional contexts no status Cotes or even unreliable ones how in the world we say whether something is successful or not
00:40:44.680 well for a few examples that's not a problem but say you had a hundred or even a thousand more then it becomes very difficult to manage every color you
00:40:50.839 code now needs to know what you mean by success or failure is it an empty response is it an inline status is a
00:40:57.520 custom error object is it empty string maybe a string error that you have to pattern match against maybe it's a number code you don't know and that
00:41:04.680 makes it a real quandry doesn't it so what do you mean by failure well maybe we mean that it's an
00:41:11.720 exception maybe it's a named exception maybe it's a custom class false value reasonably empty ones we also don't know
00:41:18.520 so what if we took all that and made our own idea of a result which could encapsulate a lot of these ideas for
00:41:25.079 us but unlike other rappers this one has two parts the first would be the idea of
00:41:30.599 success which has a value and a few bullying methods to tell us whether or not it was success so a successful thing
00:41:35.839 should of course be success and it's not a failure so that's going to return back false we could even make a class method
00:41:41.760 to make it easier to create too but there's also that second branch which is failure and that's not going to have a
00:41:47.520 value inside of it it's going to have an error is it successful no is it a failure yes and we can also make a
00:41:53.480 similar class method for it for a basic example we might have a method to get data which returns either success or
00:41:58.839 failure depending on that status code and it'll pass the response body directly into that we might use it a little bit like
00:42:06.359 this looks familiar doesn't it but we're not nearly done with that no no
00:42:11.640 no what if the idea of success happen to be mappable as well like let's say that we map on
00:42:18.839 something successful what might that look like do you figure well we could return another
00:42:24.760 success and use the function to transform the value in side of it but that gets even more interesting which is
00:42:31.119 what do you suppose happens if you map a failure you can't really transform an error can you it's an error it means
00:42:37.559 that the program is broken you shouldn't keep continuing so we don't we return back self which means anytime you call
00:42:43.599 map it just ignores it lets it go off ether never to be seen again we don't know where it
00:42:51.280 went so looking at our previous code we can now absorb that branch of if a result successful in to map right here
00:42:58.240 and use json.parse if it successful it's going to be parsed if not you're just going to have that error inside of there
00:43:05.559 this means we just absorb one part of our conditional into result type all with the power of mapable but what if we
00:43:11.680 wanted to absorb the other half what if we didn't care about the error at all maybe we could have a default kind of
00:43:16.760 like what fetch would do with hashes now in this case we have a method like value or which gives default value
00:43:23.040 what might it look like for Success well we already have a value so why would we return it to fault that wouldn't make any sense so we ignore
00:43:30.319 it but for failure much like map for Success they do the opposite so in this
00:43:35.920 case we do get back that default so how is this used we can take our previous code and
00:43:42.839 we can take that entire failure branch and we can move it into value or which is if this fails we get back in empty
00:43:48.599 hash now you might not always want to do this but you could if you wanted to no conditionals
00:43:55.359 needed now this is all fascinating but this this is my favorite part what if we
00:44:00.520 had something that was a success but whenever we Ed map on it it returned another
00:44:08.040 results like let's say that when you order te we want to ensure we are actually getting a good deal we're not
00:44:13.160 getting ripped off because we have a tea part we need to order a lot of tea we want to make sure that the quality of the tea is reasonable for the price we
00:44:19.760 get like let's say tea is rated on a scale of one to five and we consider $3 fair for each level quality or we
00:44:25.960 consider that to to expensive like in this case let's say we had a five out of five and a good $14
00:44:33.240 price from honeydew and daughters we call that a success with the 2.8 ratio but wait wait wait what what's that
00:44:39.319 response look like we have a success inside of a success that can't
00:44:45.960 be right I'm checking my notes real quick that can't be right huh but let's try that one more
00:44:52.319 time just just to be sure maybe we had an otherwise lovely tea from forest mango for $10 but a three out of five
00:44:57.440 quantities is just not justifiable for a tea party what happens then does this one
00:45:02.680 work a failure instead of a success no this won't do it all something here needs to be fixed that's not going to
00:45:09.839 work it looks like we have another method which Returns the result that we can't return from map now can we we need
00:45:16.480 to do something else say I wanted my teacup here and I want a t Bo into it
00:45:23.119 what would I do would I put the entire teapot inside of it that would be absurd you can't fit a teapot into a teacup why
00:45:29.440 would you try and put the entire thing in there exactly right it makes no sense does it so instead what if we happened
00:45:37.319 to pour the tea inside the cup instead we already know the tea is inside the pot so we can just as easily pour it
00:45:43.280 into a new container and the same idea can apply to our results as
00:45:51.000 well our poor method here is very much like map except maybe we don't want to wrap it in result for success so what do
00:45:57.280 you think it might look like well in this case we could call the
00:46:03.079 function directly in the value and not wrap it we can remove the wrapper but what's interesting about po here is that
00:46:09.400 you could do that with map as well and Implement map using Poe of all things
00:46:14.440 using our earlier concept wrap even more interesting is we're effectively joining two successes together which may sound
00:46:20.680 very early similar to reducible doesn't it in fact if we use map we know that we
00:46:27.440 get another method which will give us the results so if we try that out again
00:46:33.119 we'll find that we only have one layer of success and exactly what we'd expect inside of there but what about failure
00:46:39.079 it's not doing any wrapping for map because map doesn't really apply to it so uh do we just uh ignore it like the
00:46:45.720 other one actually yes that's exactly what we're going to do back into the ether with you to be gone and never seen
00:46:51.319 again and if we tried to use that we would find that it works exactly as we expect and we might have an AA Branch
00:46:57.800 out there which is going to tell us that foros mangoes oong tea is just too expensive for our party fascinating isn't it never thought
00:47:04.880 I learned a lesson from a teapot but I wonder what happens when we try an HTP request a teapot as well you know I've
00:47:10.839 never tried this before but what do you think might happen wait why who comes up with this
00:47:18.319 stuff what do you mean there's an RFC for it what's a hypertex coffee pot protocol this place gives me headaches
00:47:25.599 sometimes but that gives me an idea for a simpler example what if we made our own teapot
00:47:30.760 and made it pourable what does it mean to be pourable what does it mean for that thing to also be mappable or
00:47:36.319 reducible well it turns out a lot so let's start making our own idea of a portable interface and see how the teot
00:47:41.839 might implement it if we remember back to what mapable look like we're given this base how
00:47:47.800 might porable come from it well interestingly enough we can include
00:47:52.880 mapable and take a lot of that we can even Implement map by using wrap and pore on that method if we want now how
00:47:59.240 is this reducible you might ask well we'll get to that in a moment once we cover the rules but you might already be able to spot some of it so let's say we
00:48:05.400 have a teapot which is pourable if we use map on it on a teapot we get back a new teapot with the value
00:48:11.440 inside of it transpor which is the base of something being mappable wait wait wait pause time out teapots have te
00:48:17.119 inside of them not numbers that makes no sense well that's because it's my tea party if I want numbers in my teapots
00:48:23.240 I'll have numbers in my teapots if things made sense here we wouldn't call it f he land anyway moving on
00:48:31.520 now and if we have a method which returns another teapot we can use po to combine the two of them and return a new
00:48:37.119 teapot wait wait combine that sounds a lot like something which might happen to be reducible so you remember I said
00:48:42.920 something which is pable is both mapable and reducible well here's where you figure out exactly how it's reducible and what we're doing so using
00:48:49.400 rules the first rule is left identity but let's ignore that name let's call it join for now put simply it means we can
00:48:55.559 combine two poble things but how does it work if you pour a value into a function we get the same value as if we called it
00:49:02.359 two functions directly in other words we have a way to combine two things which are pourable in this case two
00:49:07.559 teapots well let's start out real quick and with method or a function which returns a new teapot after modifying the
00:49:12.839 value passed into it did that value come from another teapot or from a number we don't know we just diligently prepare a
00:49:18.319 new teapot all the same so we make a new teot and we pour it value directly into that method mind
00:49:25.040 we use method and function interchangeably here but you're more likely to use methods in lambas so do keep this distinction in mind in the
00:49:30.680 first case we pour the value of a teapot into the ad five method which would give us the value 10 inside of a new teapot
00:49:36.359 in the second case we'd have add five which gets the number five directly rather than pouring from another teapot
00:49:41.599 that also gives us back a new teapot with the value 10 inside of it which means this would be true two teapots both with 10 inside are indeed equal to
00:49:48.480 each other but why is that important well we want to be sure no funny business is happening if we pour the value out of a teapot if we wanted the
00:49:54.160 same value that was inside the teapot directly like five here it should be no different than if we poured five out of another
00:50:00.200 teapots what do I mean by funny business well maybe someone thinks they've invented more tea out of the thin air
00:50:06.000 how Preposterous can't be done I should know I've tried Asa has two these types of shenanigans will definitely fail our
00:50:12.040 rule the next rule is write identity though let's call it empty for now because it's very much like reducible
00:50:18.040 and the idea here is we start with a new teapot with the value five inside of it and we pour that value into a fresh new
00:50:24.839 teapot it should have the same value on the other side it should be equivalent
00:50:31.319 right now why is this important it means that we can take a teapot with nothing funny happening on the inside and verify
00:50:37.079 that if we pour into a fresh new teapot it should be clean and not do anything surprising to the lovely tea we just poured into it because that would be a
00:50:42.400 horrible shame no no no in that last role associativity which is the same
00:50:47.640 idea as grouping from earlier it could look similar to functional composition from mapable to it's fascinating how often these ideas overlap so let's say
00:50:54.400 we had two methods here one which multiply the value by two one which added five to the value and returned us new toots for both of them now if we
00:51:01.680 were to take the initial teot with value of five here and the result of directly pouring them into each other in sequence
00:51:07.160 it should be the same result as if we poured the original result into the multiply two method and then pour that
00:51:12.480 result and add five with the original po but we can see it's equivalent but it's
00:51:17.960 very hard to read isn't it I'm not sure I entirely follow that so look at it from this angle and it may make more
00:51:24.400 sense we choose to group these additions we get back the same Rule and we get back the same results but if it happens
00:51:29.920 to replace plus with poor instead we start seeing something very fun indeed why is this important very much because things that are reducible are very much
00:51:36.559 like this isn't it fascinating how all three of these ideas come together so see both mapable and reducible at the
00:51:42.040 same time I think we've discovered something fun here but red I am a naughty naughty lemur I've been lying to
00:51:48.240 you this entire time I feel I must come clean to you what this has all been about there's someone you should meet
00:51:53.680 first with that Indigo gesture to opening the forest with the horrifying red fog emerged eyes of flame glowing
00:51:58.880 bright so it approached waffling through Woods burbling as it came the jaws of bite the claws it catch I must run a red
00:52:04.319 would could meet his match except uh the fog dissipated in this place was a small green cat with dragon scales meowing
00:52:09.640 happily huh
00:52:17.160 oopsie it's my great honor to present you to my new best friend and Creator these lessons the monad
00:52:30.440 a little bit so map's idea is something to be mapped over while retaining its shape it's true however the name is
00:52:36.119 actually funter the idea you can map over a context that an array hash promise or a lot of things
00:52:41.359 really and sometimes you might see these other names where map can frequently be called f map R might be called unit
00:52:46.960 return not that return by the way or of it's very difficult to look at the documentation for those things reducible
00:52:53.440 was the idea that many things could be combined into one thing true name is monoid mono meaning one oid meaning the
00:52:59.680 manner of which we can combine many things to become one thing we might also see these other names for things such as
00:53:05.240 fold left or momcat or identity and mzero and porable oh porable is a fun
00:53:10.839 one that you might already know where I'm going by now its true name is monad and the idea that something can both
00:53:16.000 transform and combin at the same time what's funny is you already used several of them wait I haven't used hll you
00:53:21.799 might think oh no no you got very close inumerable with ar Rays yep active record pretty dang close Builder
00:53:27.520 patterns in general Bingo there you go and I'm certain certain people might take issues with my description here but
00:53:32.680 this is my tea party and we're only using the descriptions I want and naturally these ideas come with
00:53:38.079 their own names rap is commonly used for monads but maybe we see unit a return again not that type of return poor I
00:53:44.319 made that up completely that doesn't exist it real name is bind or flatmap which occasionally uses bind operator
00:53:49.480 you see in Haso what's more fascinating sometimes then is also variant a bind if it behaves itself wait so that's it I thought That
00:53:56.680 was supposed to be terrifying and impossible to explain is just a small cat that was Monster anticlimactic isn't it they are
00:54:03.599 so very cute though but didn't you gloss over a lot of detail in this entire talk
00:54:09.280 oh who cares it's close enough to make the point they're not all that terrifying this is my tea party and it's over now so no one can do a thing about
00:54:16.000 it after all monads are just monoids in the category of Indo funter a crackling could be heard in the
00:54:22.280 background as something broke because I still have time let this talking this mysterious Lem from earlier
00:54:27.880 not once let something go no no no especially if Indigo goes off and says something like
00:54:33.640 that mysterious lemurs so we see the purple fog emerge
00:54:39.680 the same group of mysterious lemur come forth summoned by those very words The Words which must never be uttered and a
00:54:45.119 whisper could be heard all around them monads monats monads andun are functors
00:54:50.559 in programming they skap applic of funter they explain the entire thing wrong stop trying to use it in Ruby
00:54:57.400 they said Indo breaks and a cold sweery knew exactly lemur were and exactly what they were here for they were lemur of
00:55:03.119 hll and they had come to oh Indo you should have let us know you want to learn more about monads we would gladly
00:55:09.559 teach you there's so much to learn so many rules to explore in the iish tower so much more to get into but but but but
00:55:16.280 and of course now that you've open the book without reading the terms and conditions you simply must come rabbits
00:55:23.520 Doos flowers jabis and oh no no no no no no no no no no no
00:55:30.799 this won't do it all Indigo begins reading the book looking for a loophole but the binding spell already triggered
00:55:36.039 it was too late anyone who's seen the monad walki and has said the words aloud must be taught the ways of the Ivory
00:55:42.799 Tower L they try and do something irresponsible like teaching others about it before they're ready right initiate
00:55:50.720 Apprentice Indigo outro so the Elder Master lemur
00:55:57.200 world all sitting happily at the Tea Party are you sure that was kind of us Crimson you know what lemur of hll are
00:56:02.799 like oh come on it' be a good experience they're eccentric sure but we Ruby lemur aren't much better for being fair no no
00:56:08.599 the point is that those two get to explore brand new world final sus to new adventures but I don't get it Violet's
00:56:14.280 normally so protective of her Library why is that book in particular unlocked with familiar crackle and pink
00:56:21.319 sparkle Violet appeared in indigo's chair chuckling with tea in hand it was about time for indigo to learn a few
00:56:27.240 lessons and who better to teach him now that's just me spirit and I'm the dark lord here Violet continues to sip her
00:56:33.440 tea smiling to herself who said it was my idea eser cat sat her lap and simply purred isn't that right eer so we find
00:56:41.000 red Ando initiating the Ivory Tower basan functional programming the home of all lemur pasal there they would learn topics like category Theory monads
00:56:47.400 applicatives and more re was certainly excited but he could hear Indigo complaining the entire time about never opening another cursed
00:56:53.680 book so we find the book safe locked away deep with within the library but in the world of lemur there are many more hidden books Secrets discovered
00:56:59.599 knowledge is considered forbidden just to plain strange learn we can still find them we look hard enough they may be be strange lessons that we have not learned
00:57:06.319 yet on how to program a ruby but many of those lessons have already escaped this Library pattern matching punctal
00:57:11.640 composition rors more what was once fantasy became reality what was once strange became normal so we Endeavor to
00:57:18.160 explore what is possible whether Ruby or another language entirely who knows we must always continue learning and
00:57:23.680 venture out even the most unexpected places what is considered forbidding today May
00:57:29.280 well become proper Ruby tomorrow Ruby grows and so to do we grow
00:57:34.920 with it so to wrap up you can find me on various social network sites right
00:57:44.960 here and if you want you can find all examples in the red and fantasy land Channel now as far as credits a talk
00:57:52.079 like this has a lot going into it so I had a lot of good fun with goard and others gouache I suppose excuse me and
00:57:59.359 getting a lot of inspiration of course this talk is very heavily inspired by aliceon Wonderland of which I have several references in there these
00:58:05.000 tutorials and people really help me bring these ideas live and of course technical reviewers I've had over the past few months who helped me overcode
00:58:11.680 content from the talk and had to suffer through all the horrible jokes I apologize I tested them on them
00:58:17.359 first but as always before we finish today talk this would not exist without community and Ruby is one of the most
00:58:23.359 wonderful communities I know from all those who have encouraged me set a kind word review my art watched early versions of the talk or even said a kind
00:58:29.599 word thank you but that Community is a very very fragile thing and once one
00:58:34.880 must seek to protect those who would do it harm intentionally or otherwise how the most vulnerable or treated and joked
00:58:40.480 about in our community speaks to the integrity and safety of that Community we must reject all forms of hatred
00:58:45.920 without reservation I know it's been hard lately but I hope that this little story cheered you up a bit and on your
00:58:52.720 Merry way to wherever you manag to come from with that that's all I have for today
Explore all talks recorded at RubyConf 2024
+64