 All right Welcome to today's stream Been a while right but Here we are. Let me see. Oh, I think I might be too big today Give me a second. I need to Like this because the chat will appear here. So You know, oh don't want those chat comments to be missed. Wait, so I can make this a bit smaller Okay, and then I can make Myself a bit bigger But move myself down a bit. All right I Think this will be okay. Yeah, it looks good. So today We're not gonna be doing the end of coke I did that for a while right but It's a Yeah, it's It got it got it wasn't as fun at the end, right? So today we're gonna do something real We're gonna actually implement A Haskell library. Uh, we're gonna start, you know, I think we'll stream today We'll stream tomorrow We'll see how it goes Uh, but this is like a Yeah, so the project will take a couple of a little time, you know, you want to do it properly. So We're gonna do it. Uh, so what is aws lambda run times? Well aws Allows you to run lambda functions Right and they are So, so they started out being these simple It's these simple, um JavaScript functions But then Oh give me a second I gotta charge my watch Yeah, they started out being these simple JavaScript functions. Then you could like, uh, you could you could write python functions And now you can write ruby and java and go and dotnet, but They've actually opened it up completely now. So As long as your Program implements a certain interface You're supposedly able to Run any programming language Which should be cool. So what we're going to try to do we are going to try and make a, um Custom runtime for Haskell as a library And that will essentially, you know, uh, you define some hooks It's going to start like a warp server or like a servant A warp server. Yeah warp server directly and respond to those requests by applying, you know You get past the function Uh, the parameters Your function returns a result And uh warp does the shuttling between We'll see we'll see how it works out Like I said, no promises about progress today In fact, I think a lot of the work today will be Just figuring out, you know docker aws how to get how to get Haskell running in one of these Custom runtime containers. I'm gonna have to use sudo a lot. That's okay. Uh, because I've uh changed my passport So even if you see me type it on the keyboard It's going to be different So don't try anything Ackerman. All right, let's let's get started See so if you use other languages, you know, you can implement a custom runtime Lancelot changing provides a runtime interface for getting invocation events and sender responses You could deploy a request runtime function alongside your function code or In a layer this is what we're going to try to do And we'll see how it goes How's everyone doing I got three viewers. I mean I was offline for like Two weeks three weeks And enjoying Christmas Christmas break, but now Everyone's getting back to work Those that have work and then, you know, it's time to Fire up the old stream See what we can do. Okay. So let's see custom aws runtimes You can include a runtime in your functions deploy package And Container images And that's what we want docker hub as it was this Yeah tags al2 So what's the difference between amazon linux and amazon linux too? amazon linux 2 Okay, I mean it's probably newer, right? So probably better, right? Next generation amazon linux optimized performance predictability Container image Let's use that. Let's see. Let's use this So we are going to look up this Linux 2 is good. Yeah, I think so I think it's gonna be good But you know the issue is here Are we gonna get Haskell to run on it, right? And let's buy amazon Bing bing bing. I used to use docker a lot, but like Three years ago three or four years ago. I'm hoping I mean and then you know back then you were using these Like you didn't use kubernetes or anything you used We used I don't know some beans some some custom amazon thing they had And if but it was okay Um What was it called? They said lamp. I have aws lamp to provide it. Here we go. Let's see if I remember Tags and then we want al2 right al2 All right Pull it 99 megabits That's not a lot. All right, let's see Uh I'm running nixos Uh, it's in a virtual machine and I haven't been able to update my windows So I can't run reaccel to but I think I will this will be fine But we just have like the demon running gear it's very uh It's very gangsta Right, let's pull it. No, it's not what I want to Keep you instant. I wish there was a are you ready catch my password Did you catch it I typed it On the keyboard It's for the virtual machine only though so And if you do decode it, you'll see why it doesn't actually Let's let's stop the lo-fi music. Let's put on hip-hop Oh See copyright free hip-hop music. That's a little bit more gangster, right? All right. Yeah, it's not it's not it's not jc You know, I You all see an office space, right? I'm that I'm the I'm the guy from office space, you know, I listen to Listen to hardcore rap How do my way to work, but I'm super white And that's just how it is. Okay What was again the commands here Yeah, damn it. Do I really need to do? Yeah, okay. Anyway So we're gonna say docker images has to go This is going to be a mess. Okay. Um, uh, docker run I think it's rm and then it is on there. Yeah Amazon Uh Provide entry point requires. Okay, right. I think we need to Yeah, Michael Bolton Why should I change my name? He's the one that sucks That's how it goes. Okay. Uh, let's make this what we're gonna call it Make dear Runtime api rapy. Oh That is not pc You just make up a name. This is my superpower. They say it's one of the hardest things in computer science naming things Okay, now knows what's up Uh, I I don't remember. Wait, man Docker It's like a there's like a this is like an argument you can say To make it run like another executable than the entry point Yes So we are going to say And three point Does the number remember what is the What is the uh Oh, I just want to run bash or shell or something and three point All right, we're googling Exec right. Yeah. Yeah. Yeah. See I was almost there. I can see it in the chat, but like on the screen The one that you you all see you can't you can't see You can't see the string for some reason. I don't know why it's like Thought it was a curse curse curse word It's censorship. We're being censored. God damn it. Okay. Yeah, I need to oh no No such container It's because it's not running Yeah, okay, we need to do we need to do Yeah, so it that's what we're doing But run it first. Yeah, but like if I run it It's going to start doing stuff, right? So because I I can't I can't just run it Uh Requires to have this Okay Now Let's see. I wish I had a written like a Like shared history or something like that. Okay. So sudo. Oh, no, you can't see anything Uh, so I just this window And then let me open up something dark So you can see the chat. Okay. That's it. Uh, sudo. Uh, docker X ETA What did you do? Docker container Docker ms, I think Oh Because it's like it's gonna it's it allocates like a docker ps. Yes sudo docker ps That's a passport. Okay. Uh Yes Docker X I.T. How does this help us though? So what we gotta do Is we kind of have to Do that whole thing Where we kind of download ghc We can we compile it things This was the status in 2016 right you had to like have one extremely long run command That basically, you know downloaded everything Compiled it and then kind of compiled the the resulting executable And then deleted everything And accept the resulting executable because otherwise things would Things that would would would like it would cache it And then like the container image size would be so big because like if you just install ghc And then you like remove it later Like it would be in the cache and it would take up all your cache Which was a suboptimal. Let me see. Okay. Yeah, let me run it again Okay, let's see Let's run it again run it back because so what I'm gonna do. Yeah, I'm gonna do this container recipe thing Except I have no idea what capabilities Uh What capabilities this How do we install things into this container, right? So I'm gonna play around with bash a little bit To to figure out, you know, how can we do it? We do it. Okay. Um, let's see and This is a pws lambda provided there was like a Was one with the python here Landed job at lambda python. Okay. How do they do it? Yeah That's the that's the that's the stuff Can I not So used to be the case that you could That you could Okay, so there's branches you could like you could always see the docker file At some point Is this just the look at the docker Yeah, but I want to see okay docker file python. Yeah, okay We're in. Okay. This is absolutely useless It doesn't tell us how this container was built. We're gonna look at amazon linux too. Whoop whoop Uh, yeah, let's start it. Let's gonna start something. Uh amazon linux 2 jc This is like an ec2 though. Uh yunga lambda 2 jc What is yumdah Yumd for lambda. Oh, that's convenient. I just want to see how they do it Or file and grab devil files Right, so do we have Yum, oh we have yum. Okay, that's nice Uh Okay So yum, uh Can we like search yum somehow? I'm hoping that this dumps everything and then Oh Okay, we're downloading That's good Because this this this image is just like 99 megabytes, right? So it probably doesn't have yum stuff By default that's exactly the output we wanted now Put it into this We don't have less we have more No, my god, let's see similar stuff just if you want Yeah, yeah, yeah But the thing is like we can't do yum install y go line, right? But you know yum install y gt I mean it's not that easy So That's the that's the real issue here This will be this will be nice, right? But we can't do it This is not hard enough. Oh, okay, so this is cool I didn't know you could do this Like just write one docker file now and then like copy things over That's actually very Convenient Is this all we need Okay, so Because we do have this right and You know Yeah, oh my god, let's just look up gt Party He is Let's just see Yeah, so this guy's like a legend In some sense, um, but uh, it's not what we want Yeah, like I said, you know this this stream It's not about doing the thing in high school, right? It's mostly about like how do we How do we even get started? We're not doing this because it easy. We're doing it because it's hard That's what jfk said, right? Okay, I mean so like, uh, but you know This thing has 10k poles And you know, it is we do need gcc. So, you know, I'm thinking that That using this container isn't Isn't too bad actually and then kind of just doing the same thing as the go Go thing does but you know with like this Go mod on the goproxy direct Add dot dot go build. Okay, so Okay, let's shut this down. Let's go to city aws larpy I like the name larpy And we made out of chess And Ohio Hello So, uh jc I made out of chess Just compile it link it. Okay print. Hello It's tough. Oh, we want to say Docker poll for a lot Sudo for all for all Vlad for all Vlad Oh, thanks, Oliver. I think for the follow Yeah, but this is like Oh no wait For a lot. Oh, oh, it's it's halftime. Let's see pulling FS. Whoop. Whoop Whoop whoop whoop whoop It's working It's working Now of course, this would be nice if we had a football And stuff also Oh, we don't so Let's see. Let's see what happens Do-do-do-do-do-do it's because what I'm gonna do it's what I'm gonna do like this Hey, let's let's just copy this over And let's go here. Let's say We keep them coming back. So if you any of you listen to This guy Rick Rouse And his unforgettable single hustling He makes it sound like he's very gangsta apparently He was like a prison guard like prior to Becoming a rapper like he's That's like the least gangsta job you can have Because like in this song she keeps bragging about all these You know gangsta things these days So this is what I want and then I want this stuff Because I want the runtime It gives you things so you can test Do-do-do-do-do, okay Because then I can like test locally like with already. That's nice. So let's see this now Maya Xiao Icelandic. So if I just do ghtc Oh main just Ghtc I really want to be able to use cabal So we're gonna have to mix that somehow. Okay now cash appendages We're gonna do this later ghtc main.hts. Oh main and then we're gonna copy from uh, okay be Yeah And then we're gonna add the mdi right and then okay Now I want to just do sudo docker fill what Oh, I wrote this wrong name again It's frolad and find file Main.hts. Okay We keep on coming back keep on coming back Okay, that was cool. We added the right Okay, now New password right because I can give it like a name, right? So we added Line 3 user local bin Lambda right not found Okay, what are you gonna do now? Why isn't it? Oh, why? So here it adds the two user bin lambda. Oh my god. There's just a bug between the In the description Of this, okay now we compile link Yeah Compile copy run mod. Okay And now we're gonna run larpy larpy is running so sudo docker exec it larpy And no such container. Okay sudo docker exec it This thing and then no sent any Okay, so this doesn't work floating share library lib gmp lib ffi Okay, so we can't run the executable That sucks. So I think that's because You probably have to do it from a frolad You see like this we have to change it up a bit. Let's see see what happens Do we want this lib ffi and and uh Maybe you actually just need the entire gtsy there. I don't This is a bit of a waste though, right? And we we can like tag it, right? By something t right I think and then I can just do your like name larpy main And now we're gonna go dexing Uh, actually we can go like this And it's gonna be bin. Oh my god To go docker. Yes Let's move this to seven Whereas our I should have done it before Okay This I think should do the trick. Oh, yeah, wait Nice. Yeah lib ffi.so doesn't work. Okay Uh, so I think we might just need to you know, use the alpine ghc Which is What is our thank you. All right, I'm gonna remove it first. I should be able to do it. There we go Okay, we managed to run main.hs On the alpine image And how big is it? Eh larpy It's 1.1 gigabytes, you know, that's That is a lot That is a very big image For one small program, right? And I don't even have the ball Let's do docker hub. Now I'm looking for a gc compile static Can I do that? It's the same thing, right? I don't think it actually changed anything So here we build it And then we run it, but In this window, we don't edit it Can I do gc Static Let's see if this does anything. Hey, it doesn't crash Here we're gonna write. Okay, let's see. Okay, so now this is alpine sorry apk Lib ffo, sweet Lib gmp apk search Okay Can I run it now? Yes okay, so Then We should be able to do this right from So from build main main, right and then run apk Add lib ffi and gp and look now see docker images Docker images, right Now larpy we should clean this up Uh is 22 megabytes and not like 1.1 gigabytes What does the static flag do? That is a good question. I think it like it's because I don't know What does the static flag do ghc? Because like, you know, shouldn't it can copy the you know, that's what the flag is supposed to do, right? ghc user guy flags Do you have a flag? Use static haskell libraries Okay. Yeah, so it Doesn't generate That is lame Yeah, so it generates static libraries it doesn't generate static binaries It's like I'm not sure how we just like Make it do Yeah, I mean there's a lot that's I think that's like the point right you just I just want a binary That I can run directly. I I don't I don't want it this way, right? Okay, but anyway, we found out how to do this now. How do I Docker Let's just say here Docker RMI star Just remove all the images Oh I think I could do like a docker images The imq Imq. I think I can do like this and then I can do like pseudo docker RMI I'm just gonna force it Okay, that's okay. This is fine. Now. I kind of deleted everything except the ones that we're using. Oh, okay Download some stuff The man and then we length the main Okay, oh This is APK Now let's exec it again Sweet Yeah, exactly. I mean it shouldn't be that hard, but like I don't I don't know the whole tire tool chain that well to be able to Like do it right away It's gonna be a bit rough anyway, we got We got ghc working. I would like a ball to work That would be nice, right? That is nice Like use it That's cool. That's nice And we do Let's see now. Let's let's make a package A ball version uh same version So So this is not gonna be like the avs larp be a ball. This is gonna be like the tests Okay, and then Can I like output it somewhere else? Let me see Yeah, I just do like a Let's say here docker file. Okay, so here we're gonna say this and I'm gonna say uh run apk add cabal Now I'm gonna say and then we're gonna say I'm not gc static anything We're gonna say Run cabal build There equals three But then we're like forcing it to generate. Oh, I can't end this. Thanks for the follow Now we're like trying to We need to we need to change The name of the executable Because if the executable is not named The executable is not named name. It's not actually going to be copied Uh, okay, let's say here come ball build dear About this this is work We had a cabal add test run make a cabal pins. Yeah unrecognized unrecognized option input five equals dash Why does it Let's say, okay, we want to actually build a test like this won't work, but It gives a bit closer This here unrecognized target test Can we do a Can we just add Okay, that's something else at least a Package list. Oh my god. I add static to Configure Okay, so I can I can say here build Okay, and then this is going to be In here. Okay, and then enable static Enable static Enable executable Building there's probably some better way to do this. Um This is like always gonna. Oh, it's gonna update with the latest gtc Latest cabal. I mean this is also taking super long That's not good. Let me see. I'm just gonna send a meme. Okay. This is not good. Uh We can like download a tar file, right? Cabal update Let's say Snackage one question actually What so it ran Okay, so we're running So So I have gc version so it's using it's like 8.8 gc 8.8. Apparently Okay, that's not so We were Running back. Okay Sometimes it fails, but then we just uh Just run it again. We keep coming back We keep on coming back not copy it over. Okay. That's a shame Uh, let's uh, maybe it didn't install the bins there. I think if I say install it puts the bins in the bender It puts the lotion on the skin What's the bin in the bin there? Yeah, you know, everyone's what open binary file Nice build system, huh? Okay. Well now it at least fails every time 50% of the time it fails every time Okay, uh, where where where does it actually put The things of course Okay, and data there installation directory or your own data sub directory Can I just say prefix and then I'm just gonna see because I just want to see what it does, you know But this fail here Is weird. Uh, some cabal install weirdness. Okay, license 883. Okay. Okay. Okay. Okay Copy from bill. Yes Oh, see sometimes it works Which is good No God damn it Let me see rerun it Execute it So here we have There's nothing in there ball put everything Oh, maybe it's built here. Oh, see now it actually put something somewhere in the cabal bins. Okay, that's nice But it's a It's a you know, it's gonna be placed in like a Yeah, it's gonna be like a function of the It builds and runs, right? But like I want I want this executable to be placed At a certain location. Let me actually Let's see do what happens Uh So can I Can I just do Why you know, why doesn't the ball install burl? Because you know, that should like copy it to you know, like a little global location, right open bind license. Okay Okay, it's a license file Because we do say in test that that should be a license We have a sdst I say, okay, that was something And Now can we say Here equals cabal Cabal bin can I do this? I have to wait for this again Good thing I have my phone, huh? I'm gonna give this uh 40 more minutes And then we'll uh, we'll continue tomorrow. You know, it's all about Yeah, I gotta have I gotta have dinner soon. Well, I'll see So what do you all do like when you're building? I just I just go on my phone usually, you know I wish it was like a nice mini game Oscar, I'm an Iceland Okay, it's like 720 First of all, it's 720 second of all Even if it was 2020 That wouldn't be too late for dinner, right? What do you mean? This takes too long. I wish I was like a seems like a mini game you could play. Yeah Do we have a mini game on this machine? Oh, okay. We got it Okay, we got this work tar of all discs resolving dependencies install building Yes Sim linking It's all Breaking out I made a new password because I knew I was gonna be typing it. I don't have any muscle memory Oh, yeah, I have to actually run it again. Where does it install? Install method copy, right? Oh install there. Oh nice Okay, so we we will say Yeah, so couple install build there bender. Okay, we don't care about that But we will say We're gonna change that. Okay. Let's just keep this as it is install there equals small things install method equals copy This trick. Okay. Okay. Rotar ball. Okay, it's built dependencies starting Building copying Oh my god, I think it's working I think we've got it. I think we got it. Let me see. Start it again And then we run it. All right. We got to working with cabal even Which is nice Because we're gonna be doing a library And we actually want that library to kind of work We will write the library will use the library From the test file and we'll see what happens We will see what happens. I need to wait. I'm gonna put some color here Even have some color. Let me see Uh, wait, why is this? I can see the chat Sometimes my genius scares even me That was a joke sometimes. Okay. But why is it like I don't get the The chat is weird now I need to It's like centered somehow Oh, I don't know let me see. Okay, so let's say Let's actually Create a repository New LRB So the docker file is the entry Test License for the MIT license best license, right? We can actually do it here. We can do we can do like You do Yeah, no, we can't license mit Choose a license Uh, what it's simple Okay, MIT Let's do it copyright 2021 Nice gonna have them Icelandic letters, you know Like I wondered, you know if I use like non-asky letters In the license and like like that is not my legal name, you know, my legal name has non-asky letters Is it just license to someone else? How does that even work? And then we want a get ignore add github com 3 flow EWS get remote Add main or something now, right? They change something, right? And then I will do I like this a docker No, and then we Commit it then report Yeah, cool. I'll say this. Okay, uh, okay Okay, okay, okay, okay, but we still like it's still Not good in the sense that Like we build an executable. No, no, it doesn't explode We we managed to build it and it even builds with the ball and everything So it works quite good. Uh, let's see And it It actually builds, you know a 25 megabit image It's including packages So we can Yeah, and now see it's like it generates these cabal bins and we can actually Run them without a crashing which is good Pretty good stuff But my issue now Is the following that This is actually going to Take the copies over everything from cabal bins And then we have entry dodge. Sorry for no shell, right? Now we're gonna say enter dodge And what we're gonna do is we are gonna say That's gonna be our entry, uh, then, you know Because that's gonna be user defined, right? No I wish I could undo And then we add this entry Point and now it's executing that and not But I have no idea what that even means I don't know what this right thing does I think it I think it I think it takes in I think we can now Like send HTTP events And it will it will invoke this executable Something like that Let's let's just look it up. Oh, yeah. Now. It's it's online now. AWS larpy Feel free to start if you want to follow along A But yeah, this will also serve as a kind of experimental Now a amazon rye Wait, where did we add it from? Just lambda runtime interface emulator now this This Run your container image This command runs and then we can Okay, what will happen? Wait, so I have to first run it and I have to like map the ports, right? It's a 9,080 80. Okay. That's something And I think we want yet another window And Okay, and then we're gonna just curl this Curl this Okay So it runs It is You know, it runs the main function and then it fails It's just nice, which is exactly we want to do What haven't you tried all over the the runtime interface emulator thing Because I think uh, yeah, yeah, so I think I think I think So there's two ways to go. So let's start out with like Implementing it using the runtime emulator Which just invokes something and then Like because this actually, you know, this is what it will do, you know, you have to start an end point That listens on this here and that's like, you know, we want to do that with warp but But the command invokes the function Now, what does that even mean? What does it mean by invoking the function? Okay, that's it. Let's figure it out And go beam test My god, hs. Uh, we're gonna say There's a function called get args Uh, I don't remember. It's insistent on environment Import system dot environment I do, uh, this is my favorite star wars quote It's working It's working Remember that like anakin when he fixed his pod raiser Good. So, you know, I could relate to that. I was like eight when I saw that my first and I'm like He fixed his pod raiser, you know Stop this no compile error Because like reading the error message from this talker output would be Would be non fun Not fun trademarked Because I don't know how we're getting this Like we don't get any args Read lines I think we just we just want like maybe it's in standard Standard input I this like there's functions for this but I forget system.io I think it's just get contents. Yeah, let's just do that print print and get contents std std was break it use it by fix it crash update it name it read it tune it print it scan it send it fax your name Yeah, I think so I think it's like then we run it I don't know what's happening Let's see I mean it's it's gotta it's gotta be and you know standard in right Doesn't make sense if anything else I guess the standard in was okay. So that was it was nothing build a duration I hope I'm not getting built for this No, I don't think so It's just it's just doing all the runtime stuff Now it's not even Now it's not even printing anything Where did you learn all this? I worked with Docker for a couple of years way back when like three four years ago Otherwise, we just we just been learning it now We just been this guy have like general command line knowledge and then we were We're fiddling around So it's gonna invoke It's gonna invoke the function But what does it mean? What does that mean? aws Lambda invocation Okay When you work with a lot of the place to go to execute it, let me call the code entry points by that in the function configuration The entry point or CMD. Yeah, but what is it? Can we just like say? Hey Do you work in the industry? I I do both Or like I used to work in I used to work. I've worked at a bunch of startups Or like not a bunch like two or three um That's but I mean I get Damian out technically but I still try to keep up because You know, I'm gonna be working in industry eventually, right? So you got to know what you're doing Hey But you know you you can find mathematicians in academia in industry. Let's say We're here We're uh, I mean some of us are queer but Get used to it. I guess I don't know. I don't even know what I'm saying Uh wish get environmental. Let's just Let's just dump everything Environment print. I mean, there's just a lot of mathematicians working in Haskell, you know It's uh, it's a very I give you are used to math Yeah, I think Haskell comes very naturally, you know, I initially I was uh, yeah, I just did math because I thought it was hard And I wanted to do something hard, you know, you're gonna be studying All the time might as well be studying something hard, you know, you got to challenge yourself Yeah, it's yeah, it's a functional language Hey, well, it's a lazy functional language. I think that's kind of the definition of Haskell All right, I get all this but what does it mean What does it mean? Like how how does the handler get invoked? How does the handler get invoked? That is a question Okay Okay, we have the idea of this runtime API. Okay. Okay. Okay Okay, so this just invokes the function This just invokes the function and now we Now we have to query We have to do the query so now Now we're at this this part We're at this part Custom runtime runtime interface Yeah, so now we have to Now we have to do the get some of the stuff run times get an endpoint from the awslender runtime environment variable at the api version And use the following resource paths to interact with the api Okay, so now we're gonna do a get We have runtime invocation index. Okay. Uh, so I'm just gonna do something weird Just to see if it's actually doing what it's doing Uh System dot process System dot process we're just gonna we're just gonna run We don't have the get web request Also known as rec. It's gonna be good. So Yes, okay. Now, let's see here So we need this aws lambda runtime API variable Okay, so we're gonna say g i import system dot environment now is look up and That's gonna take in this. Yeah, okay. So we say here, okay, so Convict Yeah, so let's just okay. Let's just hard code it first. We leave this so we're gonna say A api It's just gonna be uh, so look up and has the type maybe I guess right look up and Yeah, so is it gonna be uh, so Just api it's gonna be look up and aws runtime time api So that's gonna be this Now we're gonna we want to do a get request to this point here a I have to copy And I have to Yeah, yeah, I'm just gonna use rec right because I'm gonna be doing Well, I don't actually need rec right because rec is like super powerful And does https and stuff, but I don't I don't think I need https So http I think I can just use Network dot http rec. I think that's enough. That would be nice, right? It depends on network and network is built in I think Yeah, yeah, this is too much. This is too low level Uh network some api network base network You're right. Okay. Yeah, I think there is There's there is a module Jules included with gt. I think it's here. Uh, I just I'm just I'm just hoping that it is like a I remember the what there was like a uh, there was you know something there was something that was a Part of the like hasco platform, uh, that was just you could just use it directly Oh, the http packet. Is that is that included? What does it depend on? Okay, these are all built in right Yeah, okay. Yeah, so it's just kind of yeah, okay. This is very low level. That's it. Let's see So let's uh, let's just build it in test first, right? Okay, start the ball and here we're gonna say Because I don't even know, you know, this works import network dot http And network So we're just gonna say get request Okay, so it's gonna be simple http. Yeah, okay So, uh, we're gonna say Simple http How would it be already? Yeah, I like this I'll get request And what is it gonna be? http plus api plus the string here the api path gonna be this Then we're gonna say Get response body response body Let's build it now. It's gonna have to install the http package, right? I'm just hoping that this doesn't like introduce any dependencies that we're not gonna have So there's a really good book called learn you a Haskell Uh, and that's where I learned my Haskell It's there's um I don't remember there's one very good book And programming in Haskell is really good I like that one and I like this one This one is also good. I think I have both of these This is the one I learned from. Hey, I've read this one too But I would recommend probably this one like It's pretty recent and it goes into a lot of the good stuff But uh, this one was good. This one was pretty good. Yeah, what I would recommend And then, you know, just get started and start filling out See what happens now. We're building a rack. Oh, yeah, nice also, uh Yeah, Graham Graham is a nice guy. So Yeah Everyone should buy his book And he's like he teaches Haskell, you know, so it's like a book to teach Haskell by a By a guy who teaches a lot of Haskell, you know, which is All right, it didn't fail. Nice. Okay, let's go. Let's see. Okay And B we got the data Hello Okay. Oh, okay. Yeah, so what it's doing Is that it's it just because it's not starting a it's supposed to start a server That like listens on these invocations and then waits for the next one, but it's it just dies as the one see It's working We're getting uh, we're getting good stuff pretty good stuff. So we're we're getting there I mean this this time around was a bit much about Getting docker to work and everything Uh, so let's let's let's turn this off. Let's Let's say a touch. Okay. Now this is So this is a test command. Okay, and what is the command we run here? And it's this so we need to build it And then we need to run it, but here we want to detach go docker Uh, after we don't want to stop the previous container And then we run it detach it Let's run it back. Yeah. So now we need So we build it and then it Uh, successfully tagged This is no such a container at larpy. All right, we don't want it to fail. Okay, we run it It tries to stop docker yes So docker wait, so it's running now but uh Oh, yeah, okay I mean, we're not returning any reply or anything So it's not gonna. It's not gonna do anything actually, but uh, at least We're getting there, right? I want to see a I think because I can I think we should be able to do hgdp package The state of the art classical eco system r com. There was a guy who No, that's that's the that's the that's the thing, right? I don't have I don't have the uh Let's see here. HTTP client Uh Let's see. Okay. This one is okay. This is the conduit one This is wreck wreck depends on A lot of stuff and wreck Mark carpa. He's also He's a legend Uh, it's what I'm what I'm thinking is uh Yeah, no, so I mean so I don't I don't actually have anything listening All right, it uh, it it just kind of it starts it And then instead of waiting or starting a server or anything it just It just immediately queries the api and that's why we're getting this, you know Like a runtime dot exit error here because you know, it's it stops It doesn't actually continue after it does this, right? So we're we're that's what we should work on next I think I will What is the difference between wreck and wreck? Motivation of wreck versus other libraries. That's sweet Yeah, so this we need to go to the github page. Yeah, exactly. That's what I need and that's but like that's the next step Uh, but we're just not quite there yet Okay, so they don't like htdp Http client is supposed to be very simple Yeah, yeah, yeah, yeah, yeah for sure I'm just wondering, uh Well, we should be using We want to use warp super fast Super fast Let's see Request Okay, I think it should I think it has to like open a server and listen for requests On online Quest and runtimes receiving location events. Okay. Yes. So next invocation We send a get Do not set a timer on the get go Uh between when lambda bootstraps are one time and when the runtime is an inventory run The runtime process may be frozen for several seconds Okay, so let's just write here Loop Loop equals I don't think we actually need a We probably want our web server, right? Otherwise, we always have to run the user runtime api Let's say here. No, let's build it again. Yeah, we're gonna. So I'm gonna use warp warp is super fast and super quick Uh And it's like the that that's that's what you use to build a web server Or like you can use or maybe I'll use serve it To make it more typesafe. Uh, but uh, let's see Now I want to modify the uh, modify the docker file and I want to say I want to say add test test.com all And then I want to say Run All of this except I want to say Dependencies And then I want to add the rest Because then so if I do it this way like, uh, whenever I uh I will I'll do that There's this way too Let's go to a docker file Yeah, so I did this way too much All right configurable then we build it and then this will work That's it. Okay return a non-zero code one So what I'm trying to do now is that I wanted to Just install the dependencies So that uh, I don't have to do that every single time I rebuild And change the code Uh, because then that will be cached by By the uh, so the the dependencies will be cached By the docker image and I won't uh You don't need to redo that every single time Which is good So I'm gonna I'm gonna do this. I'm gonna see if it if we do the loop Uh, let's see Now let's look at the get request And you're absolutely right. You know, we need to remove the We need to remove the time out here Uh request, uh, so let's see. Let's uh It seems to be configured in simple HTTP. Let's actually let's move away from this network.http library. Um Not that it's not good. It's just a It's just a it's just, um I I don't think you can configure the timeout, but there wasn't wasn't anything there Uh to to configure it. Okay, let's see reccooper rec prime HTTP method Scheme body. Okay, so network.http.rec and see now Instead of so we've failed on the code itself But because we We cached the uh the cobalt build We don't have to rebuild everything again, which is nice Uh Do you mean? Okay, wait Let's see. Okay Now we're gonna building. Okay. It seems to have worked The compilation copying copy I'm actually wondering now we can probably do this right? Uh, I think we can do this. I don't think like we can We can like put the cobalt bins in there like at the end So that you know, it doesn't do the whole you'll get the runtime stuff or every single time either See now this now these parts will be cached, right? Okay, let me run it. Oh, right. I have these detached ones Now let's run it. Okay. Then we send an okay Yeah, yeah, yeah, yeah. Well, okay, so so that just looped it again and again It wasn't like updating the request Let's see Invocation response Uh send an indication to the response of lambda After that, I mean works the function handler puts the response from the function Okay, so we get I get so next Okay, so there's some headers. Yeah, I see now we have to do some header work, right? So we we need to do the next Uh And then we get the request id And then we will like we have to post the response, right? I'm actually gonna use this rack thing. I think that's it seems good. Okay Rack 3.38 So we're just gonna say here, uh, let's see Vint has Because you only wanted to Okay, uh, okay, so it's uh, we've been going for two and a half hours now And I really need to actually To get something to eat So we're gonna pause for today and uh, I think so I think we should say we'll be back tomorrow I'll push what we have now Yeah Uh Yes, uh, so I'm gonna push this and then Uh, so this will finish running I guess and then I pushed the code up. So if you want to play around with it, you can Try it out yourselves, but I'm gonna Take a break for now. How's the dinner and I guess uh, yeah, I mean I would want to say like I'll be back in two hours, but that's uh That's gotta be a bit much. So I'll be back tomorrow Uh, same time Like I started at six o'clock utc Which is like seven o'clock in a In a The europe not quite sure what it is in the us actually, but uh, something good And then we will keep going and we'll see You know Where we get but I think we're you know, we managed to get the runtime working We managed to get cabal and g8c working In the alpine docker image And I'm thinking you know, that's pretty good that's uh That's kind of half the battle now. We just actually have to implement the You know the api, right? Uh, which is you know, and we kind of know how to do that, but we've kind of dealt with all the systems hacking We needed to do so far Which is good So, yeah, thanks for tuning in And see you tomorrow at the same time All right