Manage episode 195677748 series 1402166
Julie Moronuki: @argumatronic | argumatronic.com
This episode is a follow-up episode to the one we did with Julie in September: Learn Haskell, Think Less. We talk a whole lot about monoids, and learning programming languages untraditionally.
CHARLES: Hello everybody and welcome to The Frontside Podcast, Episode 93. My name is Charles Lowell, a developer here at The Frontside and I am your podcast host-in-training. With me today from The Frontside is Elrick also. Hello, Elrick.
CHARLES: How are you doing?
ELRICK: I’m doing great.
CHARLES: Alright. Are you ready?
ELRICK: Oh yeah, I’m excited.
CHARLES: You ready to do some podcasting? Alright. Because we actually have a repeat guest on today. It was a very popular episode from last year. We have with us the author of ‘Learning Haskell: From First Principles’ and a book that is coming out but is not out yet but one that we’re eagerly looking forward to, Julie Moronuki. Welcome.
JULIE: Hi. It’s great to be back.
CHARLES: What was it about, was it last October?
JULIE: I think it was right before I went to London to Haskell [inaudible].
JULIE: Which was in early October. So yeah…
JULIE: Late or early October, somewhere in there.
CHARLES: Okay. You went to Haskell eXchange. You gave a talk on Monoids. What have you been up to since then?
JULIE: Oh wow. It’s been a really busy time. I moved to Atlanta and so I’ve had all this stuff going on. And so, I was telling a friend last night “I’m going to be on this podcast tomorrow and I don’t think I have anything to talk about.”
JULIE: Because I feel like everything has just been like, all my energy has been sucked up with the move and stuff. But I guess…
CHARLES: Is it true that everybody calls it ‘Fatlanta’ there?
JULIE: Yeah. [Laughs]
CHARLES: I’ve heard the term. But do people actually be like “Yes, I’m from Fatlanta.”
JULIE: I’ve heard it a couple of times.
JULIE: Maybe it’s mostly outsiders. I’m not sure.
JULIE: But yeah, it’s a real cool city and I’m real happy to be here. But yeah, I did go in October. I went to London and I spoke at Haskell eXchange which was really amazing. It was a great experience and I hope to be able to go back. I got to meet Simon Payton Jones which was incredible. Yeah, and I gave a talk on monoids, monoids and semirings. And…
CHARLES: Ooh, a semiring.
JULIE: Semiring. So, a semiring is a structure where there’s two monoids. So, both of them have an identity element. And the identity element of one of them is an annihilator. Isn’t that a great word? It’s an annihilator…
JULIE: Of the other. So, if you think of addition and multiplication, the identity element for addition is zero, right? But if you multiply times zero, you’re always going to get to zero, so it’s the annihilator of multiplication.
CHARLES: Whoa. I think my mind is like annihilated.
JULIE: So, it’s a structure where you’re got two monoids and one of them distributes over the other, the distributive property of addition and multiplication. And the identity of one of them is the annihilator of the other. Anyway, but yeah, I gave a history of where monoids come from and that was really fun.
CHARLES: But I think it’s actually quite powerful. And I think one of the things that I’m coming to realize is that these are well-worn pathways for composing things.
CHARLES: So, what you encounter in the wild is people generating these one-off ways of composing things. And so, for a shop like ours, we did a lot of Ruby on Rails, a lot of Ember, and both of those frameworks have very strong philosophical underpinnings that’s like “You shouldn’t be reinventing the wheel if you don’t have to.” I think that all of these patterns even though they have crazy quixotic esoteric names, they are the wheels, the gold standard of wheel. [Laughs] They’re like…
CHARLES: We should not be reinventing. And so, that’s what I’m coming to realize, is I’m into this. And last time you were talking, you were saying “I find monoids so fascinating.” I think it took a little bit while to seep in. But now, I feel like it’s like when you look at one of those stereo vision things, like I’m seeing monoids everywhere. It’s like sometimes they won’t leave me alone.
JULIE: In ‘Real World Haskell’ there’s a line I’ve always liked. And I’m going to misquote it slightly but paraphrasing at least. “Monoids are ubiquitous in programming. It’s just in Haskell we have the ability to just talk about them as monoids.”
CHARLES: Yeah, yeah.
JULIE: Because we have a name and we have a framework for gathering all these similar things together.
CHARLES: Right. And it helps you. I feel like it helps you because if you understand the mechanics of a monoid, you can then when you encounter a new one, you’re 90% there.
CHARLES: Instead of having to learn the whole thing from scratch.
JULIE: Right. And as you see them over and over again, you develop a kind of intuition for when something is monoidal or something looks like a semiring. And so, you get a certain intuition where you think, “Oh, this thing is like a… this is a monad.” And so, what do I know about monads? All of a sudden, this new situation like all these things that I know about monads, I can apply to this new situation. And so, you gain some intuition for novel situations just by being able to relate them to things you already do know.
CHARLES: Exactly. I want to pause here for people. The other thing that I think I’ve come in the last three months to embrace is just embrace the terminology.
CHARLES: You got to just get over it.
CHARLES: Think about it like learning a foreign language. The example I give is like tasku is the Finnish word for pocket.
CHARLES: It sounds weird, right? Tasku. But if you say it 10 times and you think “Pocket, pocket, pocket, pocket, pocket.”
JULIE: Yes, yeah. [Laughs]
CHARLES: Then it’s like, this is a very simple, very useful concept.
CHARLES: And it’s two-sided. There on the one hand, the terminology is obtuse. But at the same time, it’s not. It’s just, it is what it is. And it’s just a symbol that’s referencing a concept.
JULIE: Right, right.
CHARLES: It’s a simple concept. So, I just want to be… I know for our listeners, I know that there’s a general admonition. Don’t worry about the terminology. It’s…
JULIE: Right, right. Like what I just said, I said the word ‘monad’. I just threw that out there at everybody, but [chuckles] it doesn’t matter which one of these words we’d be talking about or whatever I call them. We could give monads a different name and it’s still this concept that once you understand the concept itself, and then you can apply it in new situations, it doesn’t matter then what it’s called. But it does take getting used to. The words are… well, I think functor is a pretty good word for what it is. If you know the history of functor and how it came to mean what it means, I think it’s a pretty good word.
CHARLES: Really? So, I would love to know the history. Because functor is mystifying to me. It sounds like, I think the analogy I use is like if George Clinton and a funk parliament had an empire, the provinces, the governors of the provinces would be functors.
CHARLES: But [Laughs] that’s the closest thing to an explanation I can come up with.
JULIE: I might use that. I’m about to give a talk on functors. I might use that.
ELRICK: Isn’t that the name of the library? Funkadelic?
CHARLES: Well, that’s the name of the library that I’ve been…
JULIE: [Could be], yeah.
ELRICK: That you’d been…
CHARLES: That imports all these concepts.
ELRICK: So awesome.
JULIE: Yeah. Yeah, I have…
CHARLES: So, what is the etymology of functor?
JULIE: Well, as far as I can tell, Rudolf Carnap, the logician, invented the word. I don’t know if he got it from somewhere else. But the first time I can find a reference to it is in, he wrote a book about… he was a logician but this is sort of a linguistics book. It’s called ‘The Logical Syntax of Language’. And that’s the first reference I know of to the word functor. And he was trying to really make language very logically systematic, which natural language is and isn’t, right? [Chuckles]
JULIE: But he was only concerned with really logically systematizing everything. And so, he used the word functor to describe some kinds of function words in language that relate one part of a sentence to another part of a sentence.
CHARLES: Huh. So, what’s an example?
JULIE: So, the example that I’ve used in the past is, as far as I know this is not one that Carnap himself actually uses but it’s the clearest one outside of that book… well the ones inside the book I don’t really think are very good examples because they’re not really how people talk. So, the one that I’ve used to try to explain it is the word ‘not’ in English where ‘not’ gets applied to the whole sentence. It doesn’t really change the logical structure of the sentence. It doesn’t change the meaning of the sentence except for now it negates the whole thing.
CHARLES: I see.
JULIE: And so, it relates this sentence with this structure to a different context, which is now the whole thing has been negated.
CHARLES: I see. So, the meaning changes, but the structure really doesn’t.
JULIE: Right. And it changes the whole meaning.
JULIE: Not just part of the sentence. So, if you imagine ‘not’ applying to an entire sentence because of course we can apply it just to a single word or just to a single phrase and change the meaning just of that word or that phrase, but if you imagine a context where you’ve applied ‘not’ to a whole sentence, to an entire proposition, because of course he’s a logician. So, if you’ve applied ‘not’ to an entire proposition, then it doesn’t change the structure or the meaning of that proposition per se except for it just relates it to the category of negated propositions.
JULIE: So, that’s where it comes from. And…
CHARLES: But I still don’t understand why he called it functor.
JULIE: He’s sort of making up… well, actually I think the German might be the same word.
CHARLES: Ah, okay.
JULIE: Because he was writing in German. Because he’s looking for something that evokes the idea of ‘function word’.
JULIE: So, if you were to take the ‘func’ of ‘function’ [Laughs] and the, I don’t know, maybe in German there’s some better explanation for making this into a particular word. But that’s how I think of it. So, it’s ‘function word’. And then category theorists took it from Carnap to mean a way to map a function in this category or when we’re talking about Haskell, a function of this type, to a function of another type.
JULIE: And so, it takes the entire function, preserves the structure of the function just like negation preserves the structure of the sentence, and maps the whole thing to just a different context. So, if you had a function from A to B, functor can give you a function from maybe A to maybe B.
JULIE: So, it takes the function and just maps it into a different context.
CHARLES: Or if I have a promise that has an int in it, I can take that same function to get a promise of a string.
CHARLES: Yeah. I had no idea that it actually came from linguistics.
JULIE: Yeah. [Laughs]
CHARLES: So actually, the category theorists even… it digs deeper than category theory. They were actually borrowing concepts.
JULIE: They were, yes.
CHARLES: We just always are borrowing concepts.
ELRICK: I like the borrowing of concepts.
ELRICK: I think where people struggle with certain things, it’s tying it back to something that they’re familiar with. So, that’s where I get… my mind is like [makes exploding sound] “I now get it,” is when someone ties it back to something that I am…
CHARLES: because you realize, you’re using these concepts. People are using them, just they're using them anonymously.
CHARLES: They don’t have names for them.
CHARLES: It’s literally like an anonymous function and you’re just taking that lambda and assigning it to a symbol.
CHARLES: You’re like “Oh wait. I’ve been using this anonymous function all over the place for years. I didn’t realize. Boom. This is actually a formal concept.”
ELRICK: True. And I think when people say like “Don’t reinvent the wheel” it’s a great statement for someone that has seen a wheel already.
ELRICK: You know what I’m saying? If you never saw a wheel, then your’e going to reinvent the wheel because you’re like “Aw man. This doesn’t exist.” [Chuckles]
ELRICK: But if people are exposed to these concepts, then they wouldn’t reinvent the wheel.
JULIE: Right. Yeah.
CHARLES: Instead of calling in some context, calling it a roller. [Chuckles] It’s a round thingy.
JULIE: Right. Yeah, so that’s a little bit what I tried to do in my monoid talk in London. I tried to give some history of monoid, where this idea comes from and why it’s worth talking about these things.
JULIE: Why it’s worth talking about the structure.
CHARLES: So, why is it worth the… where did it come from and why is it worth talking about?
JULIE: Oh, so back when Boole, George Boole, when he decided to start formalizing logic…
CHARLES: George Boole also, he was a career-switcher too, right? He was a primary school teacher.
JULIE: Right, yeah.
CHARLES: If I recall. He actually, he was basically teaching. Primary school is like elementary school in England, right?
JULIE: I believe so, yes.
CHARLES: Yeah. I think he was like, he was basically the US equivalent of an elementary school teacher who then went on to a second and probably, thankfully a big career that left a big legacy.
JULIE: Right. Although no one knew exactly how big the legacy was really, until Claude Shannon picked it up and then just changed the whole world.[Laughs] Anyway, so Boole, when he was trying to come up with a formal algebra of logic so that we could not care so much about the semantic content of arguments (we could just symbolize them and just by manipulating symbols we could determine if an argument was logically valid or not), he was… well, for disjunction and conjunction which is AND and OR – well, disjunction would be the OR and conjunction the AND – he had prior art. He had addition and multiplication to look at. So, addition is like disjunction in some important ways. And multiplication is like conjunction in some important ways. And I think it took me a while to see how addition and disjunction were like each other, but there are some important ways that they’re like each other. One of them is that they share their identity values. If you think of, it’s sort of like binary addition and binary multiplication because in boolean logic there’s only two values: true or false. So, you have a zero and a one. So, if you think of them as being like binary addition and binary multiplication then it’s easier to see the connection. Because when we think of addition of just integers in a normal base 10 or whatever, it doesn’t seem that much like an OR. [Laughs]
CHARLES: Mmhmm. No, it doesn’t.
JULIE: [Inaudible] like a logical OR. So, it took me a while to see that. But they’re also related then to set intersection and union where intersect-…
CHARLES: So can… Let’s just stop on that for a little bit, because let me parse that. So, for OR I’ve got two values, like in an ‘if’ statement. This OR that. If I’ve got a true value then I can OR that with anything and I’ll get the same anything.
CHARLES: So, true is the identity value of OR, right? Is that what you’re saying? So, one…
JULIE: Well, it’s false that’s the identity of OR.
CHARLES: Oh, it is?
JULIE: Zero is the identity of addition.
CHARLES: Wait, but if I take ‘false OR one’ I get… oh, I get one.
CHARLES: Okay. So, if I get ‘false OR true’, I get true. Okay, so false is the identity.
CHARLES: Oh right. You’re right. You’re right. Because… okay, sorry.
JULIE: So, just like in addition, zero is the identity. So, whatever you add to zero, that’s the result, right? You’re going to get [the same]
JULIE: Value back. So, with OR false is the identity and false is equivalent to zero.
CHARLES: [Inaudible] ‘False OR anything’ and you’re getting the anything.
JULIE: Right. So, the only time you’ll get a false back is if it’s ‘false OR false’, right?
CHARLES: Right. Mmhmm.
JULIE: Yeah. So, false is the identity there. And then it’s sort of the same for conjunction where one is the identity of multiplication and one is also the… I mean, true is then the identity of logical conjunction.
CHARLES: Right. Because one AND…
JULIE: ‘True AND false’ will get the false back. [Inaudible]
CHARLES: Right. ‘True And true’ you can get the true back.
JULIE: And it’s also then true, getting back to what we were talking about, semirings, it’s also true that false is a kind of annihilator for conjunction. That’s sort of trivial, because…
CHARLES: Oh, because you annihilate the value.
JULIE: Right. When there’s only two values it’s a little bit trivial. But it is [inaudible]. So…
CHARLES: But it’s [inaudible]. Yeah. It demonstrates the point.
CHARLES: So, if I have yeah, ‘false AND anything’ is just going to be false. So, I annihilate whatever is in that position.
CHARLES: And the same thing as zero is the annihilator for multiplication, right?
CHARLES: Because zero times anything and you annihilate the value.
CHARLES: And now I’ve got… okay, I’m seeing it. I don’t know where you’re going with this.
CHARLES: But I’m there with you.
JULIE: And then it turns out there are some operations from set theory that work really similarly. So, intersection and union are similar but the ones that are closer to conjunction/disjunction are disjoint unions and cartesian products. So we don’t need to talk about those a whole lot if you’re not into set theory. But anyway…
CHARLES: I like set theory although it’s so hard to describe without pictures, without Venn diagrams.
JULIE: It is. It really is, yeah. So anyway, all of these things are monoids. And they’re all binary associative operations with identity elements. So, they’re all monoids. And so, we’ve taken operations on sets, operations on logical propositions, operations on many kinds of numbers (because not all kinds of addition and multiplication I guess are associative), and we can kind of unify all of those into the same framework. And then once we have done that, then we can see that there’s all these other ‘sets’. Because most of the kinds of numbers are sets and there are operations on generic sets with set theory. So, now we can say “Oh. We can do these same kinds of operations on many other kinds of sets, many other varieties of sets.” And we can see that same pattern. And then we can get a kind of intuition for “Well, if I have a disjunctive monoid where I’m adding two things or I’m OR-ing two things…” Because even though those are logically very similar, intuitively and in terms of what it means to concatenate lists versus choosing one or the other, those obviously have different practical effects.
CHARLES: So, I’m going to try and come up with some concrete examples to maybe…
JULIE: Okay, yeah.
JULIE: That would become a disjunctive monoid, right?
CHARLES: That would be a disjunctive monoid because you’re like basically, you’re OR-ing. Yeah.
JULIE: You’re kind of, [inaudible]
CHARLES: Hard to find the terminology.
CHARLES: But like object assign would be a disjunctive monoid because you’re like mashing these two objects. And the resulting object has all of the things from both of them.
JULIE: Right. So, it’s like a sum of the two, right?
CHARLES: Right, right. Okay, so then another one would be like min or max where you’ve got this list of integers and you can basically take any two integers and you can mash them together and if you’re using min, you get the one that’s smaller. Basically, you’re collapsing them into one value but you’re actually just choosing one of them. Is that like…
CHARLES: Would that be like a conjunctive monoid?
JULIE: No, that’s also disjunctive but that’s more like an OR than like a sum.
JULIE: Right. So, that’s what I said. It’s hard to think of disjunctive monoids I think because there’s really two varieties. There’s some underlying logical similarity, like the similarity in the identity values. But they’re also different. Summing two things versus choosing one or the other are also very different things in a lot of ways.
CHARLES: Right. Okay.
JULIE: And so, I think the conjunctive monoids are all a little bit more similar, I think. [Chuckles] But the disjunctive monoids are two broad categories. And we don’t really have a monoid in Haskell of lists where you’re choosing one or the other. The basic list monoid is you’re concatenating them. So, you’re adding two lists or taking the union of them. But for maybe, the maybe type, we do have monoids in Haskell where you’re just choosing either the first just value that comes up or the last just value that comes up. So, we do have a monoid of choice over the maybe type. And then we have a type class called alternative which is monoids of choice for… so, they’re disjunctive monoids but instead of adding the two things together, they’re choosing one or the other.
JULIE: Though we have a type class for that. [Laughs]
CHARLES: [Sighs] Oh wow. Yeah.
JULIE: Mmhmm, yeah.
CHARLES: I’l have to go read up on that one.
JULIE: That type class comes up the most when you’re parsing, because you can then parse… like if you found this thing, then parse this thing. But if you haven’t found this thing, then you can keep going. And if you find this other thing later, then you can take that thing. So, you allow the possibility of choice. The first thing that you come to that matches, take that thing or parse that thing. So, that type class gets mostly used for parsing but it’s not only useful for parsing.
JULIE: So yeah. That’s the most of the time when I’ve used it.
CHARLES: Is this when you’re like parsing JSON? Or is this when you’re just searching some stream for some value? Like you just want to run through it until you encounter this value? Or how does that…?
JULIE: Right. Say you want to run through it until you find either this value or this value. I’ve used it when I’ve been parsing command line arguments. So, let’s say I have some flags that can be passed in on my command line command. There are some flags that could be passed in. So, we’ll parse until we find this thing or this thing. This flag or this flag. So, if you find this flag, then we’re going to go ahead and parse that and do whatever that flag says to do. If you don’t find that first flag then we can keep parsing and see if you find this other flag, in which case we’ll do something different.
JULIE: It’ll take the first match that it finds. Does that make sense?
CHARLES: Yeah, yeah, yeah. It does. But I’m not connecting how it’s a monoid. [Laughs]
JULIE: How is that a monoid? Well, because it’s a monoid of OR-ing
CHARLES: What’s the identity value or the empty value in that case?
JULIE: Well, the empty value would be… let’s say you have maybes. Let’s say you have some kind of maybe thing, so you’re parser is going to return maybe this thing, maybe whatever you’re parsing. Like maybe string.
CHARLES: Yeah, yeah.
JULIE: So, it’s going to return a maybe string. So well, nothing would be the empty.
JULIE: But nothing is like the zero because it’s a disjunction, logical OR. So, only when you have two nothings will you get back a nothing. Otherwise, it will take the first thing that it finds.
CHARLES: Okay. I see.
JULIE: Yeah. So, the identity then is the nothing, like false is the identity for disjunction.
CHARLES: Mmhmm. Okay.
JULIE: Yeah. If you have nothing or this other thing, then you return this other thing. Then you return the maybe string. If you have two nothings, then you get in fact nothing. Your parsing has failed.
CHARLES: Right, because you’ve got nothing.
JULIE: Because you’ve got nothing. There was nothing to give you back.
CHARLES: So, you concatenated all of the things together and you ended up with nothing.
JULIE: Right, because there was nothing there.
CHARLES: Right. [Laughs]
JULIE: You found nothing. So, it’s useful when you’ve got some possibilities that could be present and you just want to keep parsing until you find the first one that matches. And then it’ll just return whatever. It’ll just parse the first thing that it matches on.
CHARLES: Okay, okay.
JULIE: Does that make sense?
CHARLES: Yeah. No, I think it makes sense.
JULIE: I’m not sure. Because I feel like I kind of went down a rabbit hole there. [Laughs]
CHARLES: Yeah. [Laughs] No, no. I think it makes sense. And as a quick aside, I think… so, I was, when we were talking about min and max, are min and max also like a semiring? Because negative infinity is the annihilator of min and it’s the identity of max. and positive infinity is the annihilator of max but it’s the identity of min.
JULIE: I guess. I don’t really think of min and max as having identities. Is that how [inaudible]?
CHARLES: I’m just, I don’t know. Well, I think if you have negative infinity and you max it with anything, you’re going to get the anything, right? Negative infinity max one is one. Negative infinity/minus a billion is minus a billion.
JULIE: Yeah, okay.
CHARLES: I don’t know. Just off the cuff. I’m just trying to… annihilators sound cool. And so…
CHARLES: And so I’m like, I’m trying to find annihilators.
JULIE: Yeah, they are cool.
JULIE: One of my friends on Twitter was just talking about how he used the intuition at least of a semiring at work because he had this sort of monoid to concatenate schedules. So, he’s got all these different schedules and he’s got this kind of monoid to concatenate them, to merge the schedules together. But then he’s got this one schedule that is special. And whenever something is in this schedule, it needs to hard override every other schedule.
JULIE: And so, that was like the annihilator. So, he was thinking of it as a semiring, because that hard override schedule is like the annihilator of all the other schedules.
JULIE: If anything else exists on this day or whatever, then it’d just get a hard override. So, there’s a real world use. [Laughs]
CHARLES: Yeah, a real world example. That’s the thing that I’m finding, is that all these really very crystalline abstractions, they still play out very well I think in the real world. And they’re useful as a took in terms of casting a net over a problem. Because you’re like… when I’m faced with something new, I’m like “Well, let’s see. Can I make it a functor?” And if I can, then I’ve unlocked all these goodies. I’ve unlocked every single composition pattern that works with functor.
JULIE: Right, right.
CHARLES: And it’s like sometimes it fits. It almost feels like when you’re working on something at home and you’ve got some bolt and you’re trying on different diameters. So you’re like, “Oh, is it 15 millimeter? Is it 8 millimeter?”
JULIE: Right. [Laughs]
CHARLES: “Like no, okay. Maybe it’ll work with this.” But then when it clicks, then you can really ratchet with some serious torque.
JULIE: Right, right. Yeah.
CHARLES: So, yeah. Definitely trying to look for semirings [Laughs] is definitely beyond my [can] at this point. But I hope to get there where it can be like, if it’s a fit, it’s a fit. That’s awesome.
JULIE: Right. Yeah, it’s kind of beyond my can too. Semirings are still a little bit new for me and I can’t say that I find them in the wild as it were, as often as monoids or something. But I think it just takes seeing some concrete examples. So, now you know this idea exists. If you just have some concrete examples of it, then over time you develop that intuition, right?
JULIE: Like “Okay, I’ve seen this pattern before.” [Chuckles]
JULIE: Yeah. Oh, that’s cool, yeah.
CHARLES: And so, usually that initial state, that’s your identity. And then that function is just your concat function from your monoid. And so, usually anytime I do a reduce, there’s the three pieces. Boom. Identity value, concatenation function, it’s usually right there. And so, that’s the way I’ve found of extracting these things, is I’m very suspicious every time I’m tempted to…
CHARLES: A fold. I’m like “Hmm. Where’s the monoid I’m missing? Is it [under the] couch?” Like, where is it? [Laughs] Because it just, it cleans it up and it makes it so much more concise.
JULIE: Oh yeah, that’s awesome.
CHARLES: So anyhow.
JULIE: Have we totally lost Elrick?
ELRICK: Nope, I’m still here.
JULIE: Okay. [Laughs]
ELRICK: I’m sitting in and listening to you two break down these complex topics is really good. Because you guys break them down to a level where it’s consumable by people that barely understand it. So, I’m just sitting here just soaking everything in like “Oh, that’s awesome.” Taking notes. Yes, okay, okay.
ELRICK: So, I’m like riding the train in the back just hanging out, feeling the cool breeze while you guys just pull the train ahead in…
ELRICK: In the engine department, you know? It’s awesome.
ELRICK: I don’t know if they’re related. But you were talking about semirings and I heard of semigroups or semigroups. I have no idea if those two things are related. Are they related or [inaudible]?
JULIE: They're kind of related. So, a semigroup is like a monoid but doesn’t have an identity value.
CHARLES: What is an example of a semigroup out there in the wild? Because every time I find a semigroup, I feel like it’s actually a monoid.
JULIE: Well, you know I feel like that a lot, too. We do have a data type in Haskell that is a non-empty list. So, there is no empty list
CHARLES: Ah, right. Okay.
JULIE: So then you can concatenate those lists, but there’s never an identity value for it.
CHARLES: I see.
JULIE: Yeah. So, that’s a case. There’s actually a lot of comparison functions, greater than and less than. I think those are semigroups because they’re binary, they’re associative, but they don’t have an identity value. Like if you’re comparing two numbers, there’s not really an identity value there.
CHARLES: Right. Well, would the negative infinity work there? Let’s see. Like, negative infinity greater than anything would be the anything. Well, okay wait. But greater than, that takes numbers and yields a boolean, right?
CHARLES: Right. So, it couldn’t be… could it be a semigroup? Don’t semigroups have to… Doesn’t the [inaudible] function have to yield the same type as the operands?
CHARLES: But a non-empty list, that’s a good one. Sometimes it’s basically not valid for you to have a list that doesn’t have any elements, right? Because it’s like the null value or the empty value and it could be like a shopping cart on Amazon. You can’t have a shopping cart without at least something in it.
CHARLES: Or, you can’t check out without something. So, you might want to say like the shopping cart that I’m going to check out is a non-empty list. And so, you can put two non-empty lists together. But yeah, there’s no value you can mash together, you can concat with anything, that isn’t empty.
CHARLES: So, I guess going back to your question Elrick, I don’t know if it’s related to semiring. But semigroup is just, it’s like one-half of monoid. It’s the part that concats two values together.
JULIE: Right. Well, yeah. And so, it’s supposed to be half a group, right? But I don’t remember…
JULIE: [Inaudible] all of the group stuff is, all the stuff that these types have to have to be a group. And similarly, I forget what the difference between semiring and ring is. [Chuckles] Because a ring and a group I know are not the same thing. But I forget what the difference is, too. So, I kind of got a handle on what semigroups are, and I know all my Haskell friends are going to, when they hear this podcast they’re going to tweet all these examples of semigroups at me, especially my coauthor for ‘Joy of Haskell’, Chris Martin. He’s really into semigroups. And so, I know he’s going to be very disappointed in my inability to think…
JULIE: To think of any good examples. But it’s not something that I find myself using a lot, whereas semirings are something that I have started noticing a little bit more often. So, how a monoid relates to a group is something that I can’t remember off the top of my head. And I know how semirings relate to monoids, but how monoids then relate to rings and groups, I can’t really remember. And so, these things are sort of all related. But the relation is not something I can spill out off the top of my head. Sorry. [Laughs]
CHARLES: No, It’s no worries. You know, I feel like…
ELRICK: It’s all good.
CHARLES: What’s funny is I feel like having these discussions is exactly like the discussions people have with any framework of using one that we use a lot, which is EmberJS. But if you could do with React or something, it’s like, how does the model relate to the controller, relate to the router, relate to the middleware, relate to the services? You just have these things, these moving parts that fit together. And part of… I feel like exploring this space is really, absolutely no different than exploring any other software framework where you just have these things, these cooperating concepts, and they do click together. But you just have to map out the space in your head.
JULIE: Yeah. This is going to sound stupid because everybody thinks that because I know Haskell I must know all these other things. But I just had to ask people to recommend me a book that could explain the relationship of HTML and CSS, because that was completely opaque to me.
CHARLES: [Laughs] Yeah.
JULIE: I’ve been involved in the making now of several websites because of the books and stuff like that. And I have a blog. It’s not WordPress or anything. I did that sort of myself. So, I’ve done a little bit with that. But CSS is really terrifying. And…
CHARLES: Right. Like query selectors, rules, properties.
CHARLES: Again, might as well be groups and semigroups and monoids, right?
JULIE: Right, right.
ELRICK: That is really interesting. [Chuckles] I’ve never heard anyone make that comparison before. But it’s totally true, now that I’m thinking about it.
JULIE: Yeah, yeah.
CHARLES: Yeah. In the tech world we are so steeped in our own jargon that we could be… we can reject one set of jargon and be totally fine with another set. Or be like, suspicious of one set of concepts working together and be totally fine with these other designations which are somewhat arbitrary but they work.
CHARLES: So, people use them.
JULIE: So, it’s like what you’ve gotten used to and what you’re familiar with and that seems normal and natural to you. [Chuckles] So, the Haskell stuff, most of it seems normal and natural to me. And then I don’t understand HTML and CSS. So, I bought a book.
CHARLES: Learning HTML and CSS from first principles.
JULIE: Yes, yeah. I just wanted to understand. I could tell that they do relate to each other, that there is some way that they click together. I can tell that by banging my head against them repeatedly. But I didn’t really understand how, and so yeah. So, i’ve been reading this book to [Laughs] [learn] HTML and CSS and how they relate together. That’s so important, just figuring out how things relate to each other, you know?
ELRICK: Yeah. That is very true.
ELRICK: We can trade. I can teach you HTML and CSS and you can teach me Haskell.
CHARLES: There you go
ELRICK: Because I’m like, “Ooh.” I’m like, “Oh, CSS. Great. No problem.”
ELRICK: Haskell, I’m like “Oh, I don’t know.”
CHARLES: No, it’s amazing [inaudible] CSS.
CHARLES: It is, it’s a complicated system. And it’s actually, it’s in many ways, it’s actually a pretty… it’s a pretty functional system, CSS is at least. The DOM APIs are very much imperative and about mutable state. But CSS is basically yeah, completely declarative.
CHARLES: Completely immutable. And yeah, the workings of the interpreter are a mystery. [Laughs]
JULIE: YEs. And you know, for the Joy of Haskell website we use Bootstrap. And so, there was just like… there’s all this magic, you know? [Laughs]
ELRICK: Oh, yeah.
JULIE: Oh look, if I just change this little thing, suddenly it’s perfectly responsive and mobile. Cool.
JULIE: I don’t know how it’s doing this, but this is great. [Laughs]
CHARLES: Yeah. Oh, yeah. It’s an infinite space. And yeah, people forget what is so easy and intuitive is not and that there’s actually a lot of learning that happened there that they’re just taking for granted.
CHARLES: Yeah. Well, definitely probably stepping into bizarro world.
JULIE: And I went backwards. But [Laughs]
JULIE: Not that it’s backwards in terms of… just backwards in terms of the normal way, progression of [inaudible]
CHARLES: Yeah. It’s definitely the back door. Like coming in through the catering kitchen or something.
CHARLES: Instead of the front door. Because you know the browser, you can just open up the Dev Tools and there you are.
JULIE: Exactly, yeah.
CHARLES: The level of accessibility is pretty astounding. And so, I think t’s why it’s one of the most popular avenues.
JULIE: Oh, definitely. Yeah.
ELRICK: It’s the back door probably for web development but not the back door for programming in general.
JULIE: Mm, yeah. Yeah.
CHARLES: Yeah. It seems like Haskell programming has really started taking off and that the ecosystem is starting to get some of the trappings of a really less fricative developer experience in terms of the package management and a command line experience and being able to not make all of the tiny little decisions that need to be made before you’re actually writing ‘hello world’.
ELRICK: Interesting. Haskell has a package manager now?
CHARLES: Oh, it has for a while.
ELRICK: Oh, really? What is it called? I have no idea? Do you know the name off the top of your head?
CHARLES: So, I actually, I’m not that familiar with the ecosystem other than every time I try it out. So I definitely will defer this question to you, Julie.
JULIE: This is going to be a dumb question, I guess. What do we mean by package manager?
JULIE: Okay, okay.
CHARLES: Emacs has Emacs Packages. And usually, there’s some repository and people could publish to them and you can specify dependencies.
JULIE: Right, yeah. Okay, so we have a few things. Hackage is sort of the main package repository. And then we have another one called Stackage and the packages that are in Stackage are all guaranteed to work with each other.
CHARLES: Mm, okay.
JULIE: So, on Hackage, some of the packages that are on Hackage are not really maintained or they only work with some old versions of dependencies and stuff like that, so the people who made Stackage were like “well, if we had this set of packages that were all guaranteed to work together, the dependencies were all kept updated and they all can be made to work together, then that would be really convenient.” And then we have Cabal and we have Stack are the main… and a lot of people use Nix for the same purpose that you would use Cabal or Stack for building projects and importing dependencies and all of that.
JULIE: Yeah, yeah. Right, so managing your dependencies and building your project. Because Haskell’s compiled, so you’ve got to build things. And so yeah, we have both of those.
CHARLES: And now there’s like web frameworks and REST frameworks.
JULIE: Oh there are, yeah. We have…
CHARLES: All kinds of stuff now.
JULIE: We had this big proliferation of web frameworks lately. And I guess some of them are very good. I don't really do web development. But the people I know who do web development in Haskell say that some of these are very good. Yesod is supposed to be very good. Servant is sort of the new hotness. And I haven’t used Servant at all though, so don't ask me questions about it.
JULIE: But yeah, we have several big web frameworks now. There are still some probably big holes in the Haskell ecosystem in terms of what people want to see. So, that’s one thing that people complain about Haskell for, is that we don’t have some of the libraries they’d like to see. I’d like to see something… I would really like to see in Haskell something along the lines of like NLTK from Python.
CHARLES: What is that?
JULIE: Natural language toolkit.
CHARLES: Oh, okay.
JULIE: So yeah, Python has this…
CHARLES: Yeah, Python’s got all the nice science things.
JULIE: They really do. And Haskell has some natural language processing libraries available but nothing along the lines of, nothing as big or easy to use and stuff as NLTK yet. So, I’d really like to see that hole get filled a little bit better. And you know…
CHARLES: Well, there you go. If anyone out there is seeking fame and fortune in the Haskell community.
JULIE: That’s actually why I started learning Python, was just so that I could figure out NLTK well enough to start writing it in Haskell.
JULIE: So, that’s sort of my ambitious long-term project. We’ll see how that goes. [Laughs]
CHARLES: Nice. Before we wrap up, is there anything going on, coming up, that you want to give a shoutout to or mention or just anything exciting in general?
JULIE: Yeah, so on March 30th I’m going to be giving a talk at lambda-squared which is going to be in Knoxville and is a new conference. I think it’s just a single-day conference and I’m going to be giving a talk about functors. So, I’m going to try to get through all the exciting varieties of functors in a 50-minute talk.
JULIE: So, we’ll see how that goes. Yeah. And I am still working with Chris Martin on ‘The Joy of Haskell’ which should be finished this year, sometime. I’m not going to…
JULIE: Give any more specific deadline than that. And in the process of writing Joy of Haskell, I was telling him about some things that, some things that I think are really difficult. Like in my experience, teaching Haskell some places where I find people have the biggest stumbling blocks. And I said, “What if we could do a beginner video course where instead of throwing all of these things at people at once, we separated them out?” And so, you can just worry about this set of stumbling blocks at one time and then later we can talk about this set of stumbling blocks. And so, we’re doing… we’re going to start a video course, a beginner Haskell video course. I think we’ll be starting later this month. So, I’m pretty excited…
JULIE: About that. Yeah.
CHARLES: Yeah, I know a lot of people learn really, really well from videos. There’s just some…
JULIE: Yeah. [Inaudible] for me, so I’m a little nervous. But [Laughs]
CHARLES: Yeah, especially if you can do… are you going to be doing live coding examples? Building out things with folks?
CHARLES: Yeah. Well, you just needn’t look no further than the popular things like RailsCasts and some of the… yeah, there’s just so many good video content out there. Yeah, we’ll definitely be looking for the.
CHARLIE: Alright. Well, thank you so much, Julie, for coming on.
JULIE: Well, thank you for having me on. Sorry I went down some… I went kind of down some rabbit holes. Sorry about that. [Laughs]
CHARLES: You know what? You go down the rabbit holes, we spend time walking around the rabbit holes.
CHARLES: There’s something for everybody. So…
CHARLES: And ultimately we’re strolling through the meadow. So, it’s all good.
JULIE: [Laughs] Yeah.
CHARLES: Thank you too, Elrick.
JULIE: It was nice talking to you guys again.
ELRICK: Yeah, thank you.
CHARLES: If folks want to follow up with you or reach out to you, what’s the best way to get in contact with you?
JULIE: I’m @argumatronic on Twitter and my blog is argumatronic.com which has an email address and some other contact information for me. So, I’d love to hear questions, comments. [Laughs] Yeah. I always [inaudible].
CHARLES: Alright, fantastic.
JULIE: To talk to new people.
CHARLES: Alright. And if you want to get in touch with us, we are @TheFrontside on Twitter. Or you can just drop us an email at email@example.com. Thanks everybody for listening. And we will see you all later.
124 episodes available. A new episode about every 0 hours averaging 44 mins duration .