SF Scala, Adelbert Chang: Scalaz
Recording: SF Scala, Adelbert Chang: Scalaz
here in the back all right hello hello doing your that everybody I'm Alexa car from the organizers of Scala and this is our first time a dlink so Robert minus old Kevin this is awesome it's actually useful location right in the middle everything I've ever had to be here at the topic today is Scala's II just a few words out so happened so Alan presented that the first silicon valley scale symposium will the top of the city the graph so they're actually his area of research and and work and it goes all the with dressed but people were asking things on the scene before asking like I do have a doctors call the Z but instead of talking specifically ecology so I'll exciting how I can't give a talk ecology of course you know his the tubular graph talk was also new digital winner is back with you know Jeff's I don't he's still here we'll do a special made up of this right because there is really a lot of interested in scala z I we are happy to come along he I mean his comfort zone was amazing so I'm looking forward to this but before that Robert will send words I merveilleux a little bit commencements oh thanks Lexi just want to say hello and now welcome to everyone it's a great to see I'm in here Ernie about Halsey as when I introduce myself i'm robert scott i have run the platform engineering team here at inkling and i just want to tell you a little about and cleaning it kind of give you a few instruction on kind of where you are and that stuff with the new year so when we start anything four years ago we realized that we had to develop an entirely new processes for the publishing industry that's kind of a polite way of saying that publishers didn't really have a clue about what they were doing so we thought about this as engineers we realize that a lot of the process is that we use as engineers you can get by to development content so the TLDR you're going to kind of tuned out start checking email is that we take sourcing we treat content like source control and apply software processes to content introspective so just to give you kind of a quick walkthrough of how publishing traditionally works publishers work with vendors in yet to develop content to work on play out so they would actually take the vendors video would take a book take a PDF version of it put it into a FedEx box ship it over to New York and entered in New York would read the book mark it up make modifications and ship that PDF all over ship the paper version all the way back to India it appropriate the changes and then they kind of do that open over again I actually here in the back all right so we look at the processor like this whole fedex thing is kind of crazy I mean shipping things across the world is out of control but in reality it's also very similar to how software engineering processes work with cuarón ization swear yeah wondering station developing the software and you have another rejection kind of group reviewing and approving that code in the process so we took that and we applied version control to have a single repository we want to sort it the software than we added issue tracking and stuff like that to have a repository of how issues are working what's going on and he ended up with a fairly streamlined process for developing content digitally where you have people in various places so we've actually been using a lot of Scala you're starting age install about two and a half years ago on our content compiler so one of the things you don't like you uses Scala compiler Lexus at scala see we have a compiler for content to translate a lot of things into the final version and we've been using saw ever since on a lot of projects so if you are interested in finding out more we'll be giving some Q&A and demo sessions after the talk and so come either find me here anybody's coming so you can grab your gear and you be happy to kind of tell you more about what's going on here so thanks again and welcome and thanks Robin so come on elephants have actually very cool one of september's just happened this way so I'll just live it back to some Harper so we have to catch up here before that ah sep 10 or 12 is a actually we have an amazing battle look at the fennel broth Johnson who did a keynote at scale days proposing that we simplify scouring kind of production and John world and we're going to have a thing and amazing panel project versus a bunch of fractional polymers which will be full which will command another bidder office full support and turn 26 will have the original offer all the IntelliJ IDEA scale one plug in an exact solution and know how to pronounce that I guess all the way from Salzburg you know John wanna kick it has two talks he does sculpt a talk on September 19 well we'll confirm right well 19-3 thorough 19th is already 90 yeah so he's talking as alway and over 19 and on the 26 or September in the center and identified which is so on so this things are pretty full right now what we'll see in all of the Fox invasion list so if you want to join in yet with the soul and I think some books may have other announcements oh no Jason had some so i will just a few and the usual topic of hiring being hired you guys are interested basically just hang out of the words i usually deliver some i am corner which may be here right so great thanks Lexi I'm said pre-announcement to work at Netflix Thomas Edison looking for scholars voters there well you guys probably know it's hard to find good scholar so I really you know there's a lot of companies are installed the developers I think if you want to learn it if you're still picking it up you should go for the jobs there's a lot of people looking right now but we're also looking it's a great company we're a very job center for varying to open source and a lot of people are really starting to wake up to scholars so if you're interested is that with the netflix tosses maybe other moments just a big ball and i are giving a spell of course in sales a in case anyone's interested at the end of this month and vienna marshmellows you covered it and i guess going to close install this as well alright cool so not all 22 this ecology and it's also yours i think i have my theory when you look in my email my screen click to record full screen assuming that recording now okay so today I'm here to talk about the Scala said so the title of the talk is the warm fuzzy Scala library and a little background about that so the term warm fuzzy think is inspired by sandpainting Jones of Haskell Fame where he said one of the things one of the mistakes he believed well one of the mistakes he believed in Haskell was calling a monad opponent and he he believes that monad I guess the essence of a moment isn't really that hard to understand what a lot of people hear the word monad and they hear it from this abstract field called category theory and they sort of get scared and fingers hard to understand and so going in with that mentality of thinking that Mona's is difficult thing sort of hinders their understanding of it and so he believes Mon actually maybe even called 1 plus e thing instead and so that's sort of the inspiration for the title of his talk I know when I first started learning Scala I had heard about the skull as a library and how a lot of people complaining about all these symbolic operators taking implicit conversions to a whole new level and all these weird names monad functor but I think once you begin to understand sort of like what I call like the gateway data structures into Scala said as you become more familiar with them you'll become curious and and so we begin to understand more and more and dive deeper into scholars and definitely when I first started learning it that was definitely the case I start off with like maybe using two or three data structures in there and absolutely a dealt more went deeper into the rabbit hole so a little bit about me before i get started i am a fourth year student at UCSB i go back in about two weeks when I'm studying a computer science for both my bachelor's and master's I work as a research assistant on campus where to screen freaks out so I studied massive graph money on modeling so we take like grabs from say like Facebook or Twitter any any online social network and we see what interesting properties we can take out of it this summer I was working as a or I am working as an engineering analytics internet box we do use bits of scholars it and back-end so we use things like validation which I'll talk about today on analytics team I use the Scooby library which is the source call abstraction over Hadoop and Scooby uses colors head and by extension my code uses a lot of scholars in so it's pretty useful i hope to convince you today that it is a general-purpose library and not a purely academic ivory tower has no use in the real world kind of thing so this is how I'm vision of how things are going to go down over the next hour or so there's going to be lots and lots of rebel work and live coding oh that's actually this is probably like a second last slide I believe the screen keep freaking out whoa okay if you want me to try something wow I'm coding feel free to stop me let me know if you have questions feel free to stop me and let me know I'm trying to make this informal as I find typically when discussing perhaps more advanced topics is helpful to to ask a lot of questions instead of getting lost in the middle and this sort of tuning out at the end so on the agenda today these are my goals I hope that by the end you guys are familiar with what these things are specifically that weird back tick or backslash front slash thing and validation and so the general trend is going to be I'm going to implement some form of the data structure myself and sort of walk through what that data structure does and what sort of laws that data structure should hold and then once that's done i'm going to show you this Colosseum couplet to shoot a to sort of show how you would actually use call is it because the whole existence call is it is so you don't have to implement all these data structures and functions yourself you should be reusing them so the main motivation and building them is so we gain an understanding of what each thing does yes all right so this is disclaimer I'm learning as well I didn't really start heavily using scholars it until around beginning of this summer I guess quick question that has anyone here you scholars inn or fuel comes feels comfortable using scholars in you got a few people okay so if I get questions that I don't know I mean your guys's hope and I hope you guys can't help me but yeah I'm gonna do my best today to walk everyone through oh just a smiley face I'll try somebody go pull request for that after this and see see what the folks over there at type what we'll think about that okay so i have a two terminal screens this is a blank project can I make this bigger way bigger how's that okay all right so um the first function i always use to sort of motivate type classes and what scholars that provides is a sum function so i'll write like a really sort of naive implementation which will look like this and what it does is as you can probably tell it takes a list of interns to you an int and the way to implement is just as a simple reduction over the entire list so clearly if you want to some Alyssa Vince this work to put if you want to some say list of doubles or a list of begins the operations would pretty much be exactly the same say for a type parameter and so I of course being the good programmers that we are we want to abstract over this right we don't want to write a function the same function for into double string or into BB game or so on so let's add a type parameter on this I will get to that you're getting a bit ahead yes so let's pretend that either you don't know that reduce will fail on an empty list or that the list is has more than two elements in it so let's prioritize the type with a and of course if I try to compile what I think if I try to come how this is going to fail because there's no there's no plus method on any type so I need to give this a constraint thankfully the skull of standard library has a scholar math numeric which basically represents it's a type class I represent I think that is well numeric and to provide default instances for it for what you would believe to be numeric like int double begin whatever so the way we're going to do that is a implicit a you can only call this if there's a numeric and scope and set up this plus it's going to be a dot plus that should compile and then oh oh I see that should be an a okay so we can call this on list one two three you can just as easily hold this on a list of doubles in fact excuse me I have to call some o correct yes I do have to call some this is the downsides of live coding I will inevitably screw up at several points in the night and fact mr. that being compiled just do run see if I can make this bigger as well cool yeah so it's generic on numeric types now but if you look at how implemented it we're depending on also of all the numeric types of all the operations and dimeric provides for us it gives us minus and a gay plus x everything but we're only ever using plus and so if you can imagine that this same kind of function could apply to say a list of strings in which case you would take the list of strings take all the strings and concatenate them together or you can take a list of lists take all the internal lists and just concatenate and concatenate them together so really this kind of thing would work for anything that supports adding them together or pinning them together I guess so let's write a different function let's call this reduce the lack of a better word and so we need we don't want numeric right because there's no way you're going to make your going to give a numeric instance force a string so we want a different type class now and all that type specially all this function really needs is to be able to take 2 a's and combine them together to give you another a and so let's create our own type class and let's call that a let's say a double and then let's do exit a live a returns name and so you can only call this if you have an a dab'll instance of a and we are going to go ahead and delegate that to the reduced method on Aon this way that will still work so let's implement an instance for int implicit Val into edible equals new a double int and this going to be easy happen oh wait and do this will actually still work but actually we don't care about this anymore which reduce a list of ins that should get us oh I implus of six or yeah delam at six which is will be expected right it's the basically the same thing nothing new but now what we can do is go ahead and do the same thing for say string is edible and we say new a double string you take two strings in fact concatenation happens to be plus as well as that's convenient and so with the same function we can reduce on a list of strings right so before when we had to some function that would only work on anything that had a type class instance for numeric but we were only ever using the plus method on numeric so we can if we sort of create our own type class that just as all I want you to do is to be able to add 2 a's together we can now just create a function that abstracts on or that requires an instance of edible you can take 2 a's add them together i can go ahead and reduce down and tireless the pace for you now the downside to this of course is a if we try to reduce say an empty list events what's going to happen as you point out is that it's going to give a runtime error right and so the reason this happens is because all you've given reduce is a essentially a function that knows how to combine 2 a's but if your list is empty it says i have nothing to combine and i have no fallback value so instead of trying to guess what you wanted me to do i'm just going ahead and fail and make you fix your mistake so really what we want to do is say if there are two or more elements in a list go ahead and reduce them down at we've been doing otherwise you should fall back to a particular zero value and so that's an alternative way to implement the sum function would be instead of doing to reduce you can do a full left in which case we pass a zero value to the first parameter and we pass the binary operation to the second parameter and so now even if I try to use some a/c even if I try to some a and you go ahead and print line or now that's not I want yes so even if I try to some an empty list now empty with events it was going to return 0 because it has this fall back value now right the first parameter to full left is is the corresponding zero value to whatever numeric type class instance it's picking up so we want to do something similar to add it all right so for like going back to the example of strings we can go ahead and concatenate two strings but if we say we have an empty list of strings our fallback value can be just an empty string it's it's pretty intuitive so we're going to have this trade call let's say a dab'll with 0 that will extends adda Balay and this will include a zero value and so what this means is if you can give me an advil with zero instance that means that you're able to give me a zero value and a binary operation and now instead of I'll reduce function instead of doing list i'll reduce which may fail we're going to go ahead and say we'll stop fault left we're going to give it the 0 value and we're going to give it the plus value just like before and now if i go back to reducing on the list of empty ants i made an implicit Oh correct yes all right let's give this a 0 let's give this advil at 0 same for reduce yes of course add both with zero what's happening 0.o this should be int I'm having all sorts of add all sorts of problems there you go okay so now we're able to go ahead and reduce the empty list of int simply because for the same reason as with the numeric example we are now provided a fallback zero value so I've been using the terms a double and a dab'll with zero in scholars n as I'll show you in a few in a few moments edible is really called semigroup and advil with zero is really called mono I'd and so these names yes yeah yeah Craig correct yeah so he was pointing out that I was sort of using a wrong term it's not really a default value of what fold is going to do is just go ahead i take this zero value and do the binary operation on the zero and the first element if there is one if there's if the complete list is completely empty it's just going to give you the 0 value if there's at least one or if there's one or more elements it's going to take 0 the first element apply to binary operation and then that's your new I guess 0 value and then you're just going to go ahead and fold across the entire list so yeah advil with zero is really called mahanoy dance caller said audible is called semigroup and so these names are taken from the field of abstract algebra and basically the entire idea of that field is instead of is that they're going to describe what a structure can do a question yeah yeah so they're certain there are certain laws associated with monitoring center group namely for the add operation that we've been doing right so if you imagine that this is a dab'll if instead of a dab'll with zero it says annoyed the add operation or I believe they called a pen operation must have the wall that so we have x and y here if you have another value Z if you do add of x and y and you take that result and add it with Z that must have the same result as adding X with the result of adding y and z so this is the operation must be associative and the 0 value must have the property that append that adding the 0 value with X must return X and adding X with the 0 value must return X and actually Stella said has Scala check bindings which is props college I kisses property space testing library in Scala escala check bindings to say if you have your own ma noi de instance you can run these scholarship bindings on it and they'll go ahead and generate a bunch of test case or test input for you to make sure or as best as it can to make sure that whatever you're doing is following mon weight loss excuse me associative is your commute is a commutative x plus y plus Z X or the property I'm kind of go for is X plus y plus Z must equal X plus y plus see what did I say communities oh it does not have your community it just has to be associative yes yeah so yeah I'm going to go ahead and now show you the equivalent code in a scholar said so let's just make something call I don't know skull is in package so I'm going to go ahead and now import scholars Iman oil which is what we want in fact I'm going to try to pull up the Scala doc on mah annoyed so this is the scholars s call doc one way it defines two functions which we r you should be familiar with they call a pen you take two values of F append them together and you have this zero value and so here we can just as easily write our reduce function as a give me a list of a's constrained by the fact that you must have a moderate of a in scope and the implementation is simple in fact we might have to we have to actually do this eight out of hand so the reason I have to do this explicitly is because you notice here that the second parameter is a call by name I believe the correct term is a call by name parameter and what so the the binary operation takes one that's a call by value and when it's called by name the function that full left is expecting is a binary operation that takes to call my name so to make the types play nice i have to do this oh did it I well not everything that yeah okay okay so let me try this ok so we've imported scholars at da ma annoyed we've implemented reduced function like we did before we're using scholars in mono de now right so before I say we had this edible with zero that's really a monolith and anything that's in the scholars down a library and perhaps maybe even the Java library that makes where it makes sense to have a monitor value for scholars that will provide for you so I believe if I import that that will bring in them type class instances for ma noi dove say int so let me try reducing a let's reduce say lists and I hope this works and is probably going to tell me to pick a class yes of course so instead of doing that yeah okay so scholars it provides its own type class instances for types that makes sense right so it's going to provide mahanoy score for int double string even lists so we can try this so important solace di mano it gives me to moderate type class to type representing mahanoy importing the capital s scholars it will give me the actual type class instances here i'm going to go ahead and reduce a list of Lists where the binary operation is going to be of course list concatenation and zero operation is going to be the empty list and Phi of course if I go ahead and run that yeah that works as well and if you choose to have if you want to make your own thing that is that falls mon-wed loss you just provide it in scope as you would for any other type class and you can use any other scholars that function that requires you to have a monitor on it so now we have this pretty generic function right we have a reduced that takes a list of a is so long as that a has a mono to instance but we're not exactly really doing anything specific to a list right we could just as easily reduce down a say a vector events or a tree events right with because the mono e dot because mono it is associative it doesn't really matter the order in which we do it if I did fold left fold right if I we would have gone to same result so let's go one step further and abstract a way to list and so ideally at the end of this we like to have something a function that can reduce a tree events or reduce a vector of vector of lists so I'm going to create something called a type rascal foldable and just where higher clients come in our people here familiar with higher kinds do I need to explain them would anyone like me to explain how two kinds perhaps would be a better question go ahead and excellent icons so okay so our people familiar with higher order functions higher order functions functions I take all the functions that produce a value so the the short way of saying what I'm about to say for the next minute or so is going to be that types are two values what kinds are two types and so let me pull up something so I can talk this was me trying to be clever okay let's make this bit bigger so we're going to I'm going to use a notation called star this should be read as a type so stuff that were used to concrete types i guess and double string list event these all have kind star or kind type stuff list by itself right so this takes a type parameter and gives a takes a type parameter gives you a concrete value that has kind that has kinds type 2 type alright so it takes a type and returns to a type just like how a regular function takes a value and return to you a value higher kind of types which i'll show you i guess in a bit this will be the 1i show you are basically types that take type constructors and return to you a concrete type so this has a a kind of a kind type 2 type 2 type meaning i can create a foldable of list so list itself is has a kind type 2 type foldable can take something that has kind type 2 type and give to you back a concrete type dad does that make sense signature okay yeah i did not know Adrienne was here who is the person who brought us higher kind of types so now I'm going to just be nervous up here for the rest yeah if Asian corrects me he's probably right yeah yes so I'm gonna make a type class foldable that takes a higher kind of type and for my fold for my foldable skullossus is a bit different i'm going to make a very relaxed version foldable it's going to have a type parameter a that's going to be a Montoya and this says if I have some foldable of a where a is a monroy I can go ahead and fold or reduce that down into a single a value just like what we've been doing before then I can go ahead and give a instances for it list has foldable equals new foldable of list this will be a list of a will reduce that down into an A and I will go ahead and save delegate that to fold left oh great and I use I'll use it for post version oh now I have to do that weird thing again okay so now i'm going to write a function let's call it a fold for lack of a better word I need a function that takes in something of type 2 types or container i guess and something of type a give me a container of a's where the container is constrained by the fact that i must be foldable and a is constrained by the fact that it must be a mono wait and hear what i'm going to do is say F dot fold on F of a I believe see it like a piles okay I need a label higher kinds but I'm going to ignore them so yeah so now i can because i have a foldable instance in scope full foldable instance for listing scope I can go ahead and fold over a list events you know what to make this be quiet I'm just going to go ahead and import it cool yeah so now we're we pull out if our function now has pulled out the fact that we're using a list if you decide to create your own tree data structure you can think of how you would fold a trio say inch down into a single in value right because ma annoyed doesn't really care in what order you do to append operation on it you can do you can do some on the depth first search breath through search whatever you want to do any structure that really can be folded tree and list or perhaps the more common ones see what else i have here yeah okay and let's look at the scholars that equivalent of this you can go ahead and pull in a foldable pull a name one away and so now we have our foldable instances all right you can go ahead and look at the Scala doc for foldable if I can spell it yeah so where my foldable said you must implement this fold method that basically takes a container of aids and reduces it down to a single a you need to provide a bit more a bit more I guess involved operations for scholars available full of map basically means if you have a container of a if you can provide a function from A to B where B is a mon roi de then it will go ahead and reduce that down to a single B value and if you already have a container of a's i guess you could do a full map on identity and that would work and also requires to do to fold right which is the fold right perhaps that we're all used to in a scholar collection list and as long as you can implement those two methods you get a whole slew of other methods at your disposal one of which is fold which is a thing I was showing right so by importing a scholar Z foldable mano laid my function the signature remains the same scalzi provides to you write this this fifth line import this ecology provides to you foldable instances for list vector a lot of the standard library collection types and I believe they also have their own scalzi tree might be foldable but this should go ahead and compile and yeah so now we have a we've now made our function fully generic and no longer depends that we have a list events we first pulled out the fact that any two things that can be added and have a zero value and then we pull out the fact that this is list so now I want to show some other stuff in Scala said that's pretty cool let's make a separate one what's called I don't know I'm lazy of course I'm going to have to make this too what is their complaining about okay so one of the things that scholars that provides is a type-safe equals I'm going to go ahead and just bring in the entire world ecology here and so what types if equals is if you've if you've been in Java land before you know they have this equals method on object which means it's not a compilation error if I go ahead and compare it into a string it will generate a warning but it compiles fine and as you expected result is false what's called Z equals does is it gives you it using type classes it gives you a sort of type of using type classes along with implicit conversions it gives you a type-safe equals so this is a scholar Z ripple where I brought in all of scholars E and now the operator is triple equals now has a five triple equals hello it's going to say cannot find place a value for scholars e equal object what's happening is when you try to do fat compared five and an int with a string it's going to unify to a java.lang.object and since it doesn't really make sense to do equals an object you don't provide a type class instance for equal object don't try to provide your instance for equal object that would defeat the whole purpose but yeah so now you have type c equals if you do five triple equals five that works because you are able to compare to you inch right there is there is an equal event another thing to provide is order so in this khalistan library they do have I believe there's Scala Mac ordering and their skull of math ordered ordered i believe is sort of the more object-oriented approach where you have a class that extends ordered and then you say you can compare to a different thing ordering a sort of high class instance is the type class version of ordered taxing people barks we took cases 15 people in political by claim 0 and the case we're like on the left there is a superclass of the right it is I think five I think comparing a entity afloat should fail yeah so this types of Evil's will not work with comparing two numeric types now you're saying on the left is a superclass on the right as a subclass ok let's try do you have a super class and subclass of mind or should I create my own okay let me try let's Oh have to pin i have to implement equals no okay oh okay yeah true I guess class foo excuse me oh you want me to do his classic case class uh yes oh yeah we can't sell classic case class or I believe it's a compiler warning if we try to stop classic case class yeah o xn let's see what equals requires me to have equal us I just need to an eagle okay that's fine oh wait no foul x equals 0 you just want to see if it compiles in that case I don't care bar X I don't know and then no I don't I don't even think I need to go test this because if we look at the type signature for equal you can only compare oh I see yes you should it would compile I think and plis it this it foo is equal I plus vow who is equal equals nu nu equal of foo if i can type i'm going to put us to the operation equal of foo y OU fou must return a boolean so I do Val x equals new food three and if ly it closed knew I don't even know why i put the double on the bar yeah it works i guess i hope that fails ok apparently not yeah i guess the types work out oh yeah as usual be careful implanting equals when when dealing with subtyping in my experience i have yet to do to implement equals myself but for the default once i do give you on the scholars Anna library Dave they will I believe I haven't I haven't run into a case where I've had to use this types of equals with subtyping well I think the power and equals were maybe yeah power of equals is that you will not be able to compare two things that are completely separate types you will not be able to compare an industry it's a compile-time error as opposed to a runtime error which is always good another thing to bring in is order so so as I was saying a Scala has Scala map ordered and so am i ordering here's also scholars that order where order is going to have this disordering returned isn't this column at ordering it's a different skull as I tour during which I'll show you right now there's the CEO so here's where we getting to scholars adds sort of symbolic operator notation so it's ? pipe ? i can do five calling pipe kool & 6 and so scholars that ordering is sort of this i believe is an algebraic data type that represents less than equal than and greater than and if you implement order you get a bunch of the stuff that you would expect with anything that has an order on it so it's I believe an alternative to school online ordering I know Scooby uses order as opposed to ordering along with a few other the type of advice / for prefer order does anyone here know the difference between solid order and Scala my ordering is there a difference ok so I'm going to assume that they are equivalent and functionality another thing that skull as it provides is enum which is basically anything that can be enumerated for instance in Scala we're able to write a 1 to 10 right and it's going to generate a range from 1 2 3 4 5 6 7 8 9 10 because you can enumerate over an end oh let me see it can we do see to a we can't we have to do agency okay so that works scholars that provides its own enum so and along along with the enum it provides some some other methods so yeah you have to satisfy order of predecessor and successor of course if you implement so tre enum extends order is worth noting that if you're able to provide an enum instance then by definition let's say you have an enum of say java.util calendar then you are by definition you then also have an order of caliph java.util calendar so any function that's just expecting an ordering on the elements so long as you have an enum type if you have an enum type ass instance for that type then you can go ahead i call that function because in order to implement in them you must of course have an ordering one of the operators that scholars that provides on Yom is this weird so you can just ask you so there is five to ten that's also in fact let's see I believe scholars that enum scholars that provide its own implicit conversion so you have a 2 method on something that's innumerable too okay these are not helpful names okay so scholars it provides some lot of operators to to to define your own enumeration so I can just as easily do five to ten i can replace the dash with an equals and that returns to me a stream so if you have if you have like a range that's extremely large and you don't want to persist it in memory i'll return to you a scholarship from ephemeral stream the difference between of scholars at the ephemeral stream and a regular scholar collection stream is i believe as you evaluate the first few parts of a scholar collection stream those parts remain in memory is that correct Adrian yeah those parts will remain a memory whereas i believe scalzi ephemeral stream once you value the first part and don't do anything else with it that gets that is no longer available to you so with enum we can define our own so since you know is a type class you can go ahead and define our own instances for you numb for our own types so let's say I'm going to do something silly here well I'm going to go ahead and say in trapper there's just going to wrap it in and then I'm going to say implicit Val in rapper has enough and that equals a new instance of enum for in trapper what are the operations I need to define on it I need an order and you just take an in trapper another in wrapper return to me a ordering go ahead and hit explicitly I'm going to cheat and just do X dot X Y dot X delegate to the underlying integer and need a predecessor so Fred of a in trapper will be simply an inter a per let's cheat let's delegated to 2 x's and push them pred of X dot X and we can do the same thing with successor you know my int thought successor and i hope this compiles