 Yeah, we're here to talk about cats And let me just before we get started. I'll say a little bit about myself My name is Michael O'Connor, but there's nobody Besides my mother left on the planet who actually calls me Michael. So everyone should call me stew If you want to know why you can ask me personally some other time I'm currently a software architect for division of Verizon called on cue We're based in San Jose. We have We're doing lots and lots of Scala. We have in the location where I work There are as triple digits of Scala developers So lots and lots of Scala and we're doing lots of functional programming. It's lots of Scala's ed that kind of stuff so I originally had signed up to talk about something else to talk about one of my Verizon projects but John then I know I talked to him about me You know, he talked to me about talking about cats and he was like, oh god Can we talk about cats when you talk about cats because he thought it would have a much more broader appeal to people and I said, you know It is true cats and the internet seem to go hand in hand. So We're gonna start off with you know We're gonna start off with a category that I think a lot of people are gonna be familiar with which is the domestic cats feline domesticus, maybe we'll get into some Medium-sized cats like ocelots and bobcats later, but no, okay. All right, this will be my only site gag But How many people here in the room? Let's say use Scala's ed Excellent and how many people have heard of cats how many people know exactly what cats is Okay, so I'm hoping that What we I really I've prepared some stuff to talk about But my plan was really to kind of to have this be an introduction to cats and to talk about what we're doing Why we're doing it how it relates to Scala's ed And all that stuff, but I Want you guys to stop me if you ever have questions I don't you know, I don't have I have a I have a Deck full of slides that I want to try to get through But I really just want it to be a a guidelines of things we can talk about if there's anything you want to Talk about a questions you have to ask, you know of me. Just stop me ask me questions. I'm happily to Pull up a rebel if we need to I'm happy to use this white board that seems to be black and So just You know it stopped me as we we go along the way so Cats is a another library which is trying to kind of occupy the same space as Scala's ed It's doing the things we're hoping that it's going to be a library We'd use at times when you might use Scala's ed so It's there to enable pure functional programming in Scala and So It's a project that was recently started. It's a couple months old now. I don't remember exactly when we started but it's was started initially by Eric Oshheim who is well known for being the one of the primary authors of the spire project and someone who Also now algebra and a few of you know lots of other great stuff in Scala a lot of people here I assume know who we're talking about When the project was started it was clear that like there was a lot of Excitement about it we Like I said, it's only been a couple months old and we already have I think 30 contributors to the project All right, who here who here has contributed cats already? All right, there's a there's a handful of us here already, which is great and You know also just you know to show how excited people were When you know we all kind of knew that something was coming with that We're gonna start some new functional programming library and you know, there were a bunch of people that had Toss some stuff out on github Mike Pilquist created his structures project, which was kind of being the same place I had some stuff. I was playing with I know I'm sure that other people did Eric was the first one to finally said all right. Here it is. It's called cats And Once he threw it up on github, you know within the first week we had already merged a hundred pull requests, which I think you know It shows like how excited people were for so for this new You know this new library to come around So some of the goals of the project is that we're We're trying to keep it small And you know small modular But but I think the one of the things that we're gonna try and use as an underlying goal Which is really important is we're gonna try and make it approachable and you know friendly newcomers so a lot of you were in the room for the previous two talks which were also about Scala's Ed and you know they feel like You know, I know Brandon and Colt both said okay Scala said if that thing that you were so scared of because it was like oh my god My head's gonna explode and you know and it this is a a common problem people have trying to come to these these These ideas that are in these libraries, you know and these problems come from them not being complicated But actually being very simple, but So what we we've been doing You know something I'm gonna go back to over and over again probably over the over the course of talk is that it's been Really fun to Take a library like this and Scala said, you know, it's on version 7 and it's come through, you know, many many sometimes very drastic iterations but It's been really fun to be able to create a new library And really get to rethink and revisit a lot of the decisions we made In the past and and think about okay, what right now? We don't have any users, right? You don't have to worry about like we can't change this because we do we're gonna break You know break code for a lot of people. It's like no no one no one's using this yet So, you know, we get to really revisit and rethink some of this stuff. And so when we rethink some of this stuff or we're trying to all the time say now, let me try and think of this from the perspective of a newcomer and try to Figure out how we can make this library so it doesn't have to be that you know so that a couple years from now you know Brandon isn't standing up and being like cats, you know that thing you're so scared of that you never wanted to use so You know, we're hoping that we can do that. You know, we're we're In the chat room and stuff for all the time talking about a lot of people are saying like okay so I was trying to teach my co-workers about you know disjunction, you know the the left slash right slash and you know talking about was that a problem for people? did people have Find that that that syntax off-putting or not and and trying to sometimes say You know, well, I really like that syntax and that syntax is natural for me we're trying to maybe make some compromises on what I like based on What someone who was newly coming to the the library might think? and so So, you know again another another way that we're going to try and make things more approachable is that I especially am trying to be a little bit hard-assed about saying If you're gonna, you know, if you're gonna put it into the library I want it to be documented and we're we're not you know, we don't have a hundred percent coverage I'd like to get a hundred percent coverage. I like to see everything that goes into the cats library be documented have examples and and the other thing that we're gonna do in order to You know like I have up there already is another thing we're gonna do to try and keep it more approachable is to try and keep it small So that we're not Including every possible thing from category theory that can be done just to do it We're trying to ask that things that are be brought into the library Have an obvious motivation. So it We're not looking for you to say, you know Theoretically I could use this thing in this way and category theory says that you know if I can't immediately say, you know How am I gonna use that thing? I want your I'm gonna ask you to say show me an example where this is actually useful so that It's not in there occupying more space than it's earning So while we're doing this And we're making these choices or maybe we're changing things to be more approachable we're trying really hard not to Compromise the principles. We're trying to make sure that everything is lawful and we'll talk more about laws later but we're trying to make sure that You know that we don't we don't compromise our Functional programming standards in order to make things more approachable. So we still want to keep everything pure We're gonna keep everything, you know purely functional and law abiding that having said We're totally willing to compromise on our credentials. I Mean I can I on our principles When it's earning it's keep and so we will make some we will we're gonna allow some things in that maybe you're lawless If they are earning their place that is they're saying that They're providing enough value that it's that we're gonna, you know, say, okay, maybe I can't reason about this totally but it's you know And because sometimes there are things that are just so useful that you you want to have them Okay, so more goals that we have is that It's been I don't know how annoying I am to Eric Osheim and Cody Allen another person who is a heavy contributor to cats. These are some of the most annual tent of Developers on the planet, which is great But I'm sure I'm driving I'm crazy because they all wanted to be you know I've had to change emacs setting to make sure my stars on my comments line up just right and that You know no trailing white space, you know everything and so they're very As soon as I just throw the pull requests in there I'm like here you go here's some stuff and they're like I'm stew your stars aren't lining up in here You know so these guys are you know, especially because we're starting from scratch and it's not like, you know Coach coming from here coach over there. We're like they're being great gatekeepers about like We're gonna write things all the same way and we're thinking about things like you know when we're passing in Implicit parameters where you can use like a context bound Which is shorthand for having an implicit parameter passed in you know When are we gonna do one versus one are we gonna do another and we're you know We're we're actually having long conversations about style Trying to make sure that Everything is written in a very clear coherent and very consistent way And we've tried as much as we can to leverage the tools we have Like you know style of style and stuff so and I'm terrible I you know throw a commitment in there and then failed Jenkins or not Jenkins Travis will tell me It's no good because it's twirling white space somewhere So another goal is that we are trying as much as possible to make everything serializable and Some of you probably Are not sure why we care about serializable and this is I'm talking about Java serializable Who knows why I know you know I'd Albert Spark exactly It's because you know anytime you're doing a spark and you have what you're writing code Which might be shipped off to some some slave they use Java serialization right now. I think you know and so But we're just trying to be very active about putting it everywhere We possibly can so that we you know because a lot of us who are using this stuff are ending up Writing code that's gonna end up in spark at some point Um Scala doc everywhere, I'm I'm trying to go through and make sure that every method we have Has scala doc attached on and this is somewhat of a difference from some of the attitudes that some people have in Scala Zed and this is not I'm you know, there's I think that they're both completely different And totally valid ways of thinking about it, but you will see some people in the Scala Zed community Who will say I don't need the documentation because the types of the documentation I think that's that's true to some extent and I think it's it would it you know When I started learning all this stuff I started learning all the stuff from Scala Zed and I did learn how to read the type signature and learn that the type signature really is Fantastic documentation between type signatures and laws you should know everything you need to know however That doesn't work for everybody and I think it's you know It's hard to say that adding the Scala doc everywhere is worse So I'm we're just gonna err on the side of you know try to document as much as possible So it that again that person who's coming along who might be a little bit intimidated might have a You know something to read that'll help a lot more than reading a bunch of one-letter type signature name, you know so So we are trying to scala doc everything the other goal is that we have is of course search engine optimization That's what we chose cats as a really horrible name All right, so We'll talk about Some of the type classes that are in there I'm gonna assume that most of you are in here are familiar with what these type classes are I wasn't planning on going into and talking about like what is a functor or what is a monad? But you know just just talk about what we've got If you're familiar with this stuff So we have kind of the ones we're hoping that we have all the ones that you use all the time So, you know functor is something that comes up all the time the applicative functor Monads come up all the time and so these you know, we're trying to make sure that all these things that that We're all using you know all the things that we actually use all the time for Scala's ed are the first things that we put in there Traverse of course That's the one that you will hear a bunch of us say that 50% of all questions that come into the pound Scala's ed channel the answer is traverse So it was one of the first ones going there some of them are missing however, and that's because some of them are we get from algebra? And the those the ones that we're getting right now are moan added semi group also equal And so what the algebra project is algebra project is another project started by Eric the same guy who started the cast project and It tries it's trying to be some common ground For different libraries who are going to share some of the same concepts So in there, they've got a mona a monoid and a semi group and the the the initial motivation It was started by him and it was started by some Some guys from Twitter so that there could be a common language for trading ideas between spire and Algebra, so that they said why don't we you know We all using these monoids. Why don't we agree? We'll put a very small lean Implementation of an definition of what is a monoid? What is a semi group and we could share those and then hopefully that it will Ease some work on developers at some point down the road who are trying to use both libraries In there, they also have a bunch of other type classes that we're not using yet So they have you know, they have things like Abelian monoid, you know monoids where we're not just associativity is guaranteed, but Communitivity is in stuff like that and we're not using those yet, but we I think at some point. We'll probably add those as well There are some things that we're missing and I and I you know I kind of alluded to this earlier There's some things that are in scholar's ed that we don't have but we don't have them And I think it's a good thing and some of these things are are these guys And then these are the things that when you look at the scholar's ed project and look at all the things There sometimes you look at them. You're like, okay, what is this thing? What is a con extension? And it's like it It's a thing. It's an interesting thing to learn about it I bet you there is no one in this room who has ever in their time of functional programming said, you know what? This is a right extension over identity, you know like who Yeah, okay, you don't count none You haven't done it in Scala how about that And and so, you know, we've decided that a lot of these things if they're not something that come up and things that we don't use We're just gonna leave them out for now because we think the library is better and more approachable if we just don't stick everything in That's category theory for category theory's sake And other things along the same line, you know adjunctions adjunctions if you read once you start reading category theory books You know, you'll see things like adjunctions are everywhere And if you take one thing away from category theory learn to recognize that adjunctions are everywhere That might be the case. They're nowhere in people's Scala projects So so we're not gonna have them for right now lenses is an interesting one lenses are a Super useful concept and Scala Z does have lenses and they are super useful and they're fun However, I think the the what's happened is what's come along as there's a monocle project And if you guys aren't familiar with it, you should check it out It's a really really great lens library And I think that what's happening is a lot of people who would be who are using Scala Z are not using the Scala Z lenses They're starting to move towards monocle And I think we're kind of it's one of those things where I think there's a lot of you know If you look at the lenses we have in Scala Z and you look at the lens They have in monocle is the lens of the monocle are far more mature and then you go look at something like Ed commits lens library for For Haskell and it's like okay There's a whole lot more we could be doing and I think that it's one of those instances We're gonna say I think that that development's gonna happen in the monocle space and we're gonna you know We're gonna stay away from it And which I think is probably where Scala Z is headed is that we might see in some future major rewrite of Scala Z That it no longer has lens So there there's a few things that we hopefully that's you guys can read that there's a few things that we've renamed Yes, absolutely I Think it is it's just one that you know it's one that is I I do see that that one is being useful It's just one that most of us just haven't become familiar about and there aren't it's one where you know If you look at a Scala Z source code There are no examples if you search around for people using representable functors in in Scala you won't find I bet I bet you won't find a single example other than okay So here's this thing I feel like I should try and use it so I'm trying to use it Just try and use it for a toy, but I wonder if you'll even find that was representable functors So it's a type of thing where if you were to come along and come up with a pull request for cats It says here's a representable functors I'll be like great show me some example code that makes that motivates me to say like this is something I want to have right so I mean there's certainly you know in like distributive functors or another ugly or one the Distributive type class, which is another one You know like another thing that works like traverse and applicative to like turn structures inside out another one Definitely useful and definitely even comes up It's just one that you don't find a lot of motivating examples to have yet So when they come along we're happy to include them It's just that if you know it's also you know very new library and You know the things that have made it in so far are like the ones, you know like Monad use that all the time and so we use this opportunity of Kind of starting scratch from scratch to rethink some of the names so some of the names that from Scala Z We translate We changed Some of these are well people might think they're good some people might think they're bad We some of these we toil over a lot But you know we so like the some of the bigger ones, you know plus became semi-group K plus was is a is like a Semi-group so if you're thinking if you're familiar with semi-groups whereas You know semi-group has is a type class Over fully specified types so types that are don't that are You know not Type constructors like list where you know list you might say here people say it's kind star arrow star Saying that it takes a concrete type and gives you back a concrete type It has one type whole And that's what the semi-group says I need a fully specified type give me an a another a I can add them I can add an int to an int I can add a list of ints to a list of its plus and plus empty are the the We might say the universal quantified versions of these these are Just like the semi-group where we have an append to add an a to an a but it is only works for types where they are type constructors so it's Things that have one type whole so a list we can add a list to a list or an option to an option and they have slightly different semantics So that it's kind Yeah And I'm not guaranteeing these won't change again, but that the K came from the fact that it's a higher-kinded semi-group. It's one And another one is that we took the I don't the the one on the right on the bottom the the disjunction that we Renamed an X or which is for an exclusive or and then we renamed the other one which people haven't seen as much which is pronounced these Which is an inclusive or so, you know if you guys are probably familiar with the exclusive or that says either everything's either a Right or a left The these which is the inclusive or is everything is a right or a left or both Oh my slug got broken so validation became validated was the other one So talking a little more about the data types we have we have the one and which cult talked about One and being a way of making a non-empty something So if you have a one end of list it's a non-empty list a one end of vectors a non-empty vector You can make non-empty sets. You can make non-empty streams. We don't have a non-empty list that stands alone from the one And we don't have a separate one a non-empty list structure right now that definitely could change The one of the motivations to having a non-empty list Which is separate from the one-end type classes. There are a lot of useful methods that you can put on to a non-empty list Which are specific to lists? Which don't necessarily fit on the one end, which is too generic. We've got I think I've managed to get more Methods on one end to make it more useful than one in Scala Zed, but it's clearly there's we could do better So we talked about XOR and IR which is exclusive or an inclusive or before and the XOR does have a monad transformer now as well The validated type class is just like validation like it just like validation just that we've named it renamed it From validation to validated and we renamed the constructors from success and failure to valid and invalid and people seem to like that We do have Clisly now Which is a reader T or a reader monad And that's about all we've got in there for data structures right now. I'm probably missing a couple. There's constant stuff But but we plan on adding more. This is you know, this is just as far as we've gotten so far There are soothed there are few that are missing that are that are notoriously missing like ones that we really really want And we're really gonna miss a writer, which is you know someone similar, you know similar to a reader It's the it's left adjunct to a reader or something right left doesn't matter An RwST is a handy jam all the reader the writer the state all together in one big monad transformer So those are things that I'm sure will be coming. It's just a matter of someone's no one's written down and banged out in Implementation and made the pull request yet The next two tasks in process are kind of big ones You know task is a is kind of maybe the current Scala is that implementation of an IO Monad is one way to thinking of it. It's it's a way of modeling a computation which may perform side effects may succeed may fail It's one that I personally use all over the place anytime. I'm rating code I'm doing anything that might side effect or you know, then I'm gonna wrap it in a task And so my code is littered with tasks and right now task is in the Scala Z library And so we don't have a task in rotation task in Scala Z depends on the Scala Z Scala Z future implementation and it's a really hairy implementation and it's one that's Got some bugs on it and it's and So I think that we're gonna see a rewrite of task I think there's one already in is no, there's not one in Scala Z yet, but Right I was just gonna ask you like I mean Well, it's so it's it's I don't know I don't care necessarily does it have to live in cats or to have to live a separate thing But I yeah, I don't know Could be it's just that you know when when the people so none of us, you know I know that Travis has fooled around with putting cats into a library And people have said okay, I ported my toy project from Scala Z to cats Most of us were developing cats aren't like going in my day job and being like okay guys It's cats now, you know and one of the reasons the thing that's gonna stop me from being able to do that is task Like I just need task to operate and and task is tied to Scala Z now like you know You know internally the it's a it's a disjunction and stuff like that and so That's that's been talked about there's a there's a big issue about in the Scala Z stream issues tracker right now about One of the things that Paul Chiasano said he might want to do is to pull task back into Scala Z stream So they have control over it like Daniel saying like we need to fix the bugs ourselves And you don't want to tie they don't want to tie Scala Z stream doesn't want to necessarily tie itself to the Scala Z release cycle Yeah, absolutely Yeah, and I think Paul has talked about even yet pulling it away from Scala Z and maybe renaming it and stuff like that And you know another thing that we and I think we're gonna see more of that like for instance Mike Pilquist also has the S codec project which is a fantastic project and if you're doing any kind of binary serialization You should check out as codec and it's streaming alternative. Yeah, it's it's just so pleasant to work with You know what we say a lot at work is like the highest The highest compliment you can give any libraries like it's a very reasonable library to work with Yeah, and so when this all came up in the whole I think Colts called it the switcheroo or something When the whole switcheroo came up Mike Pilquist did what I think we're gonna see some other libraries to do is to say I'm just gonna pull back. I'm gonna implement my own monad and I don't need much from Scala Z or cats I don't want to pick a winner So maybe we'll see that happen with process and task and those but my point is just that those are the kind of Things that need to happen before I can wholeheartedly switch to cats because I can't operate without task And I'm starting to right now process is the big hammer. I'm hitting all the nails with That's fucking fun And so another thing that we're missing is is tags tagged typed which are super handy and useful in Scala Z And that's just I've been meaning to port it over and it's how we've done it. Yeah Yeah, probably yeah And hopefully even better soon So some things are out of scope for cats we've decided and these are things that were added to these are data structures that were added to Scala Z along the way and their stuff. That's not they're super useful and well sometimes they're maybe you could You know, maybe some of these are questionably useful. I list for example is just a list It's just a re-implementation of lists. That's trying to be a little better It's the list that we wish was in the standard library the things that we like about it better are that You should entertain yourself sometime by looking up Rob Norris's tea pole cats diagram of all of the things that a list inherits from in the super type hierarchy and it's like a Huge page was like 30 things on it. You're like wow. I knew it was a lot, but that's 35 super classes. Yeah, so Another thing is that I list the I and I list comes from the fact that it's invariant and that's a Questionable thing, you know, there are reasons why it's nice to have a list that's that's covariant and there but it can cause some problems So one thing that list change I list changes is to make lists not invariant and then another thing that it does is it just gets rid of the stupid method that shouldn't be there like You know dot head you should only you should never if you're calling dot head you should you you know By convention you must anywhere you call dot head you must add a comment that says YOLO because You know Head option is the answer that you should be going so going down So there's also a maybe type in Scala Zed, which is just like option but again doesn't have the dot get method where you must put YOLO and And it's also invariant and then the next one down is I Had a co-worker who would that's that's Scala Zed's map and it's a it's a map the story as a tree But it's an immebable map structure very nice structure to work with Again doesn't have 35 supertypes and has a lot of the things that you said God. Why doesn't that map have that like? Why don't I have something? It's like Update and if it's not there at it if it is combine it with a semi-group That one lovingly referred to by a previous co-worker of mine as the dick arrow We're also missing finger tree and we have known Double-ended queue these kind of things are stuff We just decided this is not the business cats want to get into love to see some other library started up that says okay I want to do data structures right we just don't see that it's necessarily a strong relationship to to cats We had you know like I said before it's been fun to like kind of rethink some of the old ideas we had that you know Are just being able to think of you know new stuff that that we could try and we've had a couple that we've You know we've had a couple notable ones that we've tried and said you know that was a bad idea Let's forget it one thing it came up. We were come redoing disjunction We are coming up with our new exclusive or which went through about 25 different possible names for we could call it You know we could call it or we could call it either we could call it You know these things and then the the constructor names that could be the right and left it could be good and bad or good and evil You know And I think good and bad or good and evil are the ones that's galactic uses Is that right? It's good or bad or good and evil I don't remember and that's Bill Venner's library and he can't got in and started talking to us and made a really good case For trying to tell us that our exclusive or should be left biased, which was a really interesting discussion And so we actually considered Making it left bias so that it would be the the good values on the left and the errors on the right and that was one where My good friend Rob Norris over here sent me an instant message or an IRC's message saying hey Stu get over the Gats channel because I'm about to lay down in front of the bulldozer over this right bias And we ultimately decided that we really do need to stick with a right-based Exclusive or are just right biased in general another one that which which is yeah, go ahead Right Okay, yeah, I'll give you here's the here's the example that convinces me So Let's say When you when you talk about the monad instance, right? You're gonna write the monad instance on XOR of some maybe XOR where the errors are strings and And The the parameter we're leaving free is this one over here now. Let's talk about XOR T which is the monad transformer over some some monad and string is the error and Here is the thing I'm abstracting over and that like the Although we don't have this in Scala. We don't have type currying like we do in Haskell it does seem to Be easier to to to remember or think about where we have This parameter that were the one that were that were letting vary the one that we're keeping free is always the last one like this You know having having that thing stuck in the middle This this kind of this right yeah So I don't it just it just it just feels more natural than most of us I think and I you know so What's that? It is right So another one we we that I played around with and I actually have a working implementation of is using Trying to do some trickery some Maybe some nasty little things To try and have maybe just one some type It's an interesting idea. I don't think it's fully fleshed out, but something where you know we have these things like Validation which has a left value and a right value Success failure have you want to call it we haven't you know in either we have a disjunction we have you know All of these different things that have the exact same structure is that you know They're a product of two types And we talked about in the Scala Z talk how we have one of them which Operates monantically where you can only have one error and Things must be strictly sequenced and one that is works in an applicative manner where we can accumulate errors and we can you know one One computation doesn't depend on the result of another computation And so when you're using these things you might have to when you need one behavior versus the other switch from one type to another You know so another way you could do this perhaps is to have a Generic product of two things and then use tags or some other way or some nasty is instance of trick To be able to switch the behavior without necessarily causing another allocation But it's not one that we're really the idea to really didn't go anywhere All right any questions before we move on So one thing that we've tried to do is to modularize the the project a little more and this is something I'm not sure if it's this is one where there's gonna be some pushback on this But the idea is that we wanted to have a really tight small core so you could you know I think there's some people that had this this idea of like well I don't want to pull you that pull that whole huge scala Zed library into my pride I don't want that on my class path And I'm not sure that's that's a well-founded Idea, but we were trying to have just a really tiny core that had just the type classes that we needed to do Functional programming and try to not bring anything else into it and Then have we have the std the standard stuff, which is the type class instances for the standard library So for example in core is where you're gonna have something like Functor and in standards where you're gonna have something like list has a valid functor Or option has a valid functor So all the things you know all all of the type class instances for the stuff in the standard library would go there Then we have a separate project where we're just packaging the laws the laws which say things like Ammonoid has to be associative or Says that a functor when you map on the identity function, you don't change the original value So those kind of laws are stuck in there We'll talk about docs in a bit, but docs is the is a sub project where we're generating all the documentation for the project And that includes And that's you know, it's where that we generate the website from it's what generates the scala doc and stuff like that free We have a free monad implementation And we stuck it in a separate project called free and this is one the reason it's in its own project is I think that How many people here are like using the free monad and and are like writing interpreters for free algebras and doing that fun Stuff that runar likes to talk about if you're not you should try and do it It's a fun exercise and it's really worth it. We're starting to do it everywhere but you know this this idea of of using free in order to You know model your domain and then we're able to write interpreters that perform the the actual Nasty IO and stuff that it needs to do your actual business It's an idea that's really hot in the FP scala world right now And I think you know like scholars that stream where you know, you need we need want to iterate those things Separately from scala said we think that this Free because it's becoming so hot and we're having new ideas about it And there's lots of ways that things could be better as far as being more efficient when you're doing this Maybe not so efficient way of computation that we want to keep that so it can iterate a little bit separately But the last one on my list state that is an artifact of why maybe this modularization is not a good idea because What has happened is that we've you know, we've we had that we started with this this this idea of grandeur We'll make everything very modular and very small and and and just you know interdependencies between them But then we realize right away like we used to have a separate data project where we had things like and are exclusive or type and are You know all of the you know the that's where the Clisly lives and this and that but then we very quickly said all right. I actually need some of that stuff in core So now we had to pull that stuff into core and now we have a problem in core where? anyone who's done a lot of pure functional programming in and scala has realized eventually you probably need a trampoline because You know you can't do monadic computation for example in a stack safe way in scala without using something like trampolines And since the most you know common commonly We'll see and what is done in scala is that as a trampolines are are built on top of a free monad So because trampolines are based on free we don't get used in free is in its own project We don't get to use trampolines in core, which is a bit of an issue And now because state being that monadic computation that you can't do in a stack safe way needs a trampoline Now we have this extra state project, which we've only had since like Wednesday Which depend which is his own project only because it depends on free and in core Doesn't need to be that trampoline could be your monad you're operating over but Clisly is very useful without I'm sure Okay, so There are any questions. I'm gonna I was gonna run through really quickly one One one one very specific example. I thought was really interesting that came out of you know actually forget it I'm gonna skip that one So we're running longer on time than we thought All right, I want to I was gonna start to talk about some of the so Some of the other cool things that it happened Because we were starting this product project fresh is that we were able to make use of some of the some some cool new Technology and scala that which is making our lives a lot easier I just wanted to highlight some of them some of them are super fun and things that you should be checking out for your Own project the first one I threw some slides in just because Colt told me I had to in his talk Which is about kind projector So the idea behind kind of director It's a it's it's a it's a compiler plugin that's been around for a long time And I don't some reason just just now we got it into scala Zed like a couple months ago and we're using it in Cats it's the one that lets you get rid of if you look at The the second line there so so the idea here is the first line we want to write We want to use some monad for our exclusive or type. That's our disjunction But we can't do that because it's in the wrong shape monad wants you to be Defined for some type class that looks like this. It's got one hole, but XOR has two right It's got an error and a success type. So it's the wrong shape. So that does that first one doesn't work It doesn't compile You've probably seen if you played around with scala Zed very For a while you've seen the second one which is called a type lambda and the idea is it does some this is like Something if someone figured out you could do Not like a planned feature, but it's just it's defining if you look at it and you try to break this down It's really not that bad once you understand what's going on. It's like You're defining an anonymous structure It's got a single type alias in it and that type alias has the right shape Because we fixed this one So now we have this type alias will pull it out of there and that's the thing that we're doing So what we've done is we've just we've taken two holes when we filled one with string there You can get around this by defining your type alias Just defining a type alias here. I have a string error, which now string error is in the right shape. So this works Now why wouldn't you just do that all the time? You typically do but there are situations like the very last one where we need to refer to this is a scary type Signature that comes out of the cats library that we need and I don't want to tell you what it does but the thing I want you to The thing I want you to understand is the reason I can't do this trick to simplify Where I define a type alias and just use a type alias is that this type where I need the hole is defined in saw earlier in in the In the method definition so I don't have no place to define the type alias So I have to do it here So this used to be that big scary type lambda But now I get to where the whole thing and just just say What the kind projector plug and lets you do is just say stick the question mark where you want the hole to be and then we get to you know It Yeah Okay, another one since we're running short on time is discipline. That's what we use for our law checking I didn't talk much about laws. I thought what I'm going to talk about laws a lot It's a super nice plug-in that lets you write the law. So a lot of these things like functor There a lot of these concepts to come from category theory that becomes so useful because they're so general and what they let let us do is to You know manipulate our programs algebraically And what I mean by that is just think of you know think of when you have an algebra problem like 2x equals Ten like I can figure out what x is because I can manipulate this algebraically This is what we learned in algebra as I learned that since these things follow certain laws I can just apply things and say it like take the x over here put the two and put it over here and just you know Software x I want to be able to do the same thing with my code and see things like I have a map I have you know f a map f map g. I know I can change that into f a map G compose f And I can do that only because these things are following laws So for instance, I'm you know, I'm defining that law down here that says that f a map f then map g is the same as Mapping over just a composite function So we have some nice thing that discipline is a nice Library let's me just write my laws like that and then run scholar check to check that my list moan hat is actually Behaving correctly this one simulacrum is one that I'm super excited about It's another one from my quipil quest who I've mentioned several times What it tries to do is try to standardize how we deal with type classes and type class instances in order to eliminate a lot of boilerplate, so Here is how you might define a semi-group This is how it's defined in cats is that we just say that a semi-group just has a single method called combine Just takes two a's combine them to a single single a All we're going to do is we're going to add Just this annotations to say that By the way, semi-group is also a type class And then what simulacrum is going to do is generate all this code for us all this boilerplatey code And there's not much of interest here, which is another reason why you don't want to write it yourself But there's a couple things that it lets us do which are super handy. We want to do all the time for example In the first thing here what I'm doing is I've called semi-group int And that's calling an apply method that's been added by simulacrum Which lets me conjure up a semi-group for int if one is in implicit scope and then just call the method on And I don't have to write that apply method on some Object called semi-group that just comes for free just by putting that type class annotation Another is that I get this syntax like in and how I've gotten that it's just if you go back to my definition You see that I just put the op This thing is an operator, which I want you to have a type alias I'm sorry a and a method alias for to say you can call that with pipe plus pipe And that just all of a sudden works and that works by adding lots of implicit for you stuff that you don't have to Write yourself, but you get this handy syntax And so that's simulacrum moving fast because we're running out of time one huge thing that That I my favorite part of the entire cats project and if you look I'm someone who likes to do is pretty good at Making you think I know what I'm talking about But really all I do on these projects like Scala Zed and one of the top committers cats in the top committer All I'm doing is actually just writing documentation I don't actually run any of the code So I'm super excited about this stuff Art our documentation for cats is first of all, yeah, I think it's good. I do say so myself but it's it's compiler verified and that's done with a SPT plugin from Rob over there called tut and what it lets you do is it lets you write some Markdown in your readme's that have These code blocks that are labeled by tut they're referred to did you make up the term touch heads? They're called touch heads Okay, so what it lets me do is in my documentation in my markdown. I get to have a touch head that has some code Right, what happens is the tut actually runs a compile time and converts it into a repel session so what it actually does is fires up a repel and shoves your code into the repel and Replaces your markdown with now a Scala shed, which has the exact Running your your your documentation through a repel and when so what the result is is that if we change some code in cats in Our examples are written documentation aren't right anymore. It fails the build So we have to fix the documentation when we fix So