haskell.

Поділитися
Вставка
  • Опубліковано 30 вер 2024
  • I tried to learn Haskell. I tried to be a good boy and learn the way of functional programming. But what the func is happening. What's the deal with Haskell? Why? Monoids?
    Follow along with me on my journey in learning this "programming language". If you think Haskell is hard... try learning C • coding in c until my p...
    🏫 COURSES 🏫
    Learn to code in C at lowlevel.academy
    🔥🔥🔥 SOCIALS 🔥🔥🔥
    Low Level Merch!: www.linktr.ee/...
    Follow me on Twitter: / lowlevellearni1
    Follow me on Twitch: / lowlevellearning
    Join me on Discord!: / discord

КОМЕНТАРІ • 755

  • @LowLevel-TV
    @LowLevel-TV  Місяць тому +9

    haha anyway learn a better language (c btw) at lowlevel.academy

  • @charleshawkins8481
    @charleshawkins8481 Рік тому +3580

    Every Haskell tutorial:
    Lesson 1: To add 2 numbers, use "+". Easy!
    Lesson 2: To concatenate two lists, use "++". Easy!
    Lesson 3: So to do I/O the only thing you really need to understand is that a monoid is simply a noncomposable convex bijection into inverse functor space. In other words it is a mapping over types. This allows you to

    • @Stopinvadingmyhardware
      @Stopinvadingmyhardware Рік тому +124

      That’s confusing for non-math nerds though.

    • @torarinvik4920
      @torarinvik4920 Рік тому +215

      It becomes a lot easier when one realises that Haskell can't execute code. One can only make functions that is a chain of operations to be executed when the program runs. An incredible clever idea, really. This was the program OG John Backus wasn't able to solve. He said in an interview that he wasnt able to solve the problem of time and considered his explorations of FP to be failure.

    • @mrtruman4339
      @mrtruman4339 Рік тому +148

      Allows you to what? ALLOWS YOU TO WHAT?

    • @Stopinvadingmyhardware
      @Stopinvadingmyhardware Рік тому +88

      @@mrtruman4339 It allows you to build a state based algorithm that is great for timing based attacks on systems that are otherwise rather difficult to build injection and attack packages for.
      Julia is still better. Can do almost all of the same things, and the syntax is easier for when it's 3am and you're still working on an annoying project with far too many issues to work reasonably well.

    • @iwant2tryhard337
      @iwant2tryhard337 Рік тому +48

      @@Stopinvadingmyhardware I like your word soup of an explanation

  • @ThePrimeTimeagen
    @ThePrimeTimeagen Рік тому +1963

    this is great

  • @LunarSoul255
    @LunarSoul255 Рік тому +310

    "foldr mappend mempty" is exactly how this makes me feel

  • @LeRoyDecapite
    @LeRoyDecapite Рік тому +1291

    Haskell fanboy here and I've been laughing hysterically for 2 minutes straight.

    • @GeorgijTovarsen
      @GeorgijTovarsen Рік тому +10

      ahahah same

    • @Verbatino
      @Verbatino Рік тому +214

      As the video is only 1:02 long, I can clearly state that your 2 minutes of laughter is *out of bounds*
      And that's not acceptable...

    • @kphaxx
      @kphaxx Рік тому +16

      And that was before you even watched the video!

    • @Stopinvadingmyhardware
      @Stopinvadingmyhardware Рік тому +14

      “Rubs two brain cells together intensely.”
      Nope, Erlang still makes more sense.

    • @remrevo3944
      @remrevo3944 Рік тому +14

      ​@@Verbatino Technically, they never said they laughed only during the video, so still totally in bounds.
      (Also some people might be weird and watch youtube at 0.5x speed.)

  • @sarpsomer
    @sarpsomer Рік тому +117

    "How to exit vim" 🤣🤣🤣🤣 🤣

    • @jonathantest12
      @jonathantest12 7 місяців тому +3

      The video ended and I still can't stop laughing about it.

    • @ianmcnaney6528
      @ianmcnaney6528 4 місяці тому +2

      That just becomes muscle memory after a few years. :q! of course, why would it be anything else? Colon ":" for "this is a command", q for "quit", and ! for "simon says, I really mean it this time, so do it or I'll set you on fire"

  • @apollowellstein188
    @apollowellstein188 Рік тому +981

    Everyone's having fun until the functional languages arrive

    • @tophy9865
      @tophy9865 Рік тому +21

      Lisp is functional but isn't annoying like the ML family.

    • @moltony
      @moltony Рік тому

      ​@@tophy9865yeah I agree

    • @ern0plus4
      @ern0plus4 Рік тому +34

      The weirdest part is that functional languages just simply _deny_ the most common concept of computers: memory.

    • @tophy9865
      @tophy9865 Рік тому +58

      @@ern0plus4 No. They don't deny it. They abstract over it. Our machines have memory. But our minds don't do well when we have to think about operations of the underlying machine. Instead we use a different model of computation to think about and let the compiler and runtime worry about talking to the machine.

    • @tophy9865
      @tophy9865 Рік тому +15

      And I should note that these abstractions not only make things incredibly easy to think about, but they work very well. Even systems languages like Rust now have tons of functional APIs where you just don't have to bang your head against the wall worrying about unsafe stuff. I think the Lisp and Rust way is just good: make things easy by default, but allow people to do weird mutable stuff (Rust allows much more than this).

  • @PS3PCDJ
    @PS3PCDJ Рік тому +169

    Wait until you see the APL guy pull out his special keyboard

    • @raskr8137
      @raskr8137 Рік тому +32

      wait until the J guy slams his fist on the keyboard a few times and that produces a working constraint solver

    • @DavidLoveMore
      @DavidLoveMore Рік тому

      Can you not just use ANSI trigraphs to generate apl characters?

    • @cramble
      @cramble 10 місяців тому +3

      The APL guy keeps his special keyboard in a very special place.

    • @MinecraftMasterNo1
      @MinecraftMasterNo1 5 місяців тому +3

      @@raskr8137 Still more legible than Perl

  • @ivanjermakov
    @ivanjermakov Рік тому +245

    A nice mental excercise is to come up with a type system where types share as much common typeclasses as possible. This is how you get Semigroup (anything that can concat), Monoid (Semigroup + a way to concat an empty value), Foldable (fold, a.k.a. reduce), etc.. Typeclass names sound complicated, but it gets easier once you can understand the meaning behind it.

    • @IronCandyNotes
      @IronCandyNotes Рік тому +6

      tc = interface

    • @galaxygur
      @galaxygur Рік тому +22

      Well explained, you should record some tutorials

    • @scvnthorpe__
      @scvnthorpe__ Рік тому

      Make sure they're magma as well... although that presumably comes with the territory of having types and such!

    • @ivanjermakov
      @ivanjermakov Рік тому +7

      @@galaxygur thianks, I can recommend reading "Learn You a Haskell for Great Good!" if you want to learn more.

    • @donkeyy8331
      @donkeyy8331 Рік тому +24

      I didn't understand a single thing you just said.

  • @officialbfi01
    @officialbfi01 Рік тому +116

    God looks away when one programs in Haskell

    • @perfectionbox
      @perfectionbox Рік тому +9

      Seems like God abandons the programmer too

  • @konnilol4
    @konnilol4 Рік тому +110

    I've glanced over at Haskel a few times now but I still think I'm fine with C...

    • @IronCandyNotes
      @IronCandyNotes Рік тому +13

      we need to rename it H

    • @DrSpooglemon
      @DrSpooglemon Рік тому +19

      @@IronCandyNotes I can't wait for H++.

    • @konnilol4
      @konnilol4 Рік тому +23

      @@DrSpooglemon how about Microsoft's H#

    • @DadofScience
      @DadofScience Рік тому +3

      I'd consder going it alone with a bucket of diodes, transistors and resistors before whatever that was/is/shouldn't be.

    • @Instr
      @Instr Рік тому +1

      Almost a thing until SPJ, one of the big names in Haskell-land, talked the Microsoft team out of it.

  • @m1geo
    @m1geo Рік тому +103

    I love the little jokes that you add into the videos. They don't go unnoticed. "How do I escape VIM" as the default search. Love it. Been in EE/CS/Linux for many years and the joke never gets old. There's always a Grad or something asking! :)

  • @jabal_team
    @jabal_team 8 місяців тому +4

    0:15 any body notice "how to exit vim " 😅

    • @vladimirprotein3275
      @vladimirprotein3275 Місяць тому

      @@jabal_team
      1st month of programming: "How to exit Vim"
      10 years of programming: "How to exit Vim"

  • @Cobblestoned100
    @Cobblestoned100 Рік тому +6

    Well now, butter my butt and call me a biscuit! Yer tellin' me you ain't hip to the wonders of Haskell? Well, sit a spell, partner, 'cause I'm about to school ya.
    Now, I ain't no high-falutin' big city computer whiz, but I know a thing or two about good old fashioned logic. An' that there's what Haskell's all about. Ya see, it's got this thing called a "static type system," which basically means the computer does a whole mess of checkin' before it even runs your program. Cuts down on them pesky bugs, don't ya know.
    Ever hear tell of "side effects"? In most o' them other languages, your functions can just go 'round changin' things willy-nilly. Not in Haskell, no sir. Functions in Haskell are like good, honest work: ya put somethin' in, ya get somethin' out. None o' this behind-the-scenes tomfoolery.
    An' speakin' of work, Haskell's got this thing called "lazy evaluation." Now, I know what you're thinkin', but it ain't what it sounds like. It ain't about avoidin' work, it's about doin' work only when you need to. It's like when you're fixin' to build a barn, but you only cut down trees as you need 'em instead of all at once. Saves a heap o' time an' effort, I tell ya.
    Now, I ain't sayin' Haskell's the be-all and end-all. Like a good pickup truck, every tool's got its job. But I'll be hog-tied if it ain't got a lot goin' for it. So next time ya hear some city slicker yammerin' on 'bout Python or Java, just remember: there's more'n one way to skin a cat, an' Haskell's one heck of a knife.

  • @austinbutts3000
    @austinbutts3000 Рік тому +837

    What you get when a computer scientist is married to a software engineer but the milkman is a category theorist 👀

  • @SkyyySi
    @SkyyySi Рік тому +112

    EDIT 2: Please read my whole comment. I keep getting replies about functional programming. This comment is not about functional programming, as I already added at the bottom.
    ------
    My main gripe with Haskell is just that... you can tell it was made by mathematicians, not by IT people, bringing along design philosophies that make sense in math, but probably not as much in a programming languages, like optimizing for fast writing, not fast reading of code
    ------
    EDIT: Just to be clear: I'm talking about Haskell as a language and its syntax. Not about functional programming.

    • @BlauerTeeLp
      @BlauerTeeLp Рік тому +19

      But that's what Haskell is for. It has its place. If you want performance you wouldn't use Haskell. But if you wanna prove a complex peace of software does and does only what it's supposed to e.g. cause it handles something critical functional programming offers you that.

    • @rj7250a
      @rj7250a Рік тому +16

      @@BlauerTeeLp Thanfully Rust is a viable language today, i have seen a very good description of Rust online: "Haskell if it were useful"

    • @rj7250a
      @rj7250a Рік тому +8

      @@techtutorvideos Rust have lots of functional features, for example the Option monad, like Maybe in Haskell. you do not need a PhD to understand its type system, but it still very strict like Haskell.
      But it is closer to imperative languages, so it is more "normal" compared to Haskell.
      The hardest part is ownership and borrowing, since Rust do not have a GC, you have to think more about memory, it is going to be hard if you never learned C or C++. For example, if you a a data structure with unkown size at compile-time, you need to put in a box, Box puts the variable in the heap, Or Rc if you want multiple ownership over a value. Example:
      enum List {
      Cons(i32, Box),
      Nil,
      }
      This enum emulates a Lisp list, there can be a list inside a list, so there could be a stack overflown, it is only safe to store in the heap, that is what Box indicates, unlike lisp where everything is allocated on the heap without you noticing.
      That is because Rust is a systems language, so it needs to give up some abstractions to be very fast.

    • @anon_y_mousse
      @anon_y_mousse Рік тому +6

      @@rj7250a More like C++ if it had worse syntax. I thought C++ had disgusting syntax until I learned Rust. Now I know where all the brain damaged people that learned Haskell went. Moral of the story is, you actually can have a worse language and Rustaceans have shown us the way.

    • @sharoyveduchi
      @sharoyveduchi Рік тому +7

      @@rj7250a is it necessary for you crabs to be everywhere? Don't kid yourself. Rust advertises itself as a C replacement, not a Haskell replacement.

  • @brandonc8792
    @brandonc8792 Рік тому +292

    If you haven’t learned Haskell or another functional language I highly recommend. I was taught in university and at first I was lost but once it clicks it becomes fun. You start to notice how your brain thinks differently as you slowly go into flow.

    • @SaHaRaSquad
      @SaHaRaSquad Рік тому +61

      Functional: yes. Haskell: no thanks.
      I have no issues with FP but Haskell feels more like maths than programming.

    • @Synthetic_geth
      @Synthetic_geth Рік тому +13

      @@SaHaRaSquad Agda:

    • @БогданСтасив-ч8к
      @БогданСтасив-ч8к Рік тому +19

      ​@@SaHaRaSquad It is natural for purely functional language to be able to express things from category theory with ease (typeclasses, immutability, overall purity).

    • @SaHaRaSquad
      @SaHaRaSquad Рік тому +19

      @@БогданСтасив-ч8к My point has nothing to do with features, but the user experience. Haskell isn't a bad language but its design is more oriented at theory than practice.

    • @UnrealOG137
      @UnrealOG137 Рік тому +11

      I took a compiler design class in OCaml. Ocaml is one of the better functional languages. I still prefer imperative programming.

  • @Dust599
    @Dust599 Рік тому +26

    Your synopsis is 100% correct. I haven't had to touch Haskell in > 20 years and its still giving me nightmares!

    • @jboss1073
      @jboss1073 Рік тому +4

      If you think Haskell is hard, try its tooling.

  • @arunbeckham8384
    @arunbeckham8384 Рік тому +168

    Yep functional programming languages are designed to communicate with aliens.😂

  • @zilog1
    @zilog1 Рік тому +15

    haskel is built around pure maths and theory in more mathematical stuff. If you don't have the foundation and that already then you're just going to be very confused. Unlike other languages, instead of it being based off of the foundations of more of a literal Hardware aspect of computer science this is mostly very high-level theory of computer science. It's not that it's a dumb or bad language it's just that it's very foreign to most people who don't already have the foundation in theoretical mathematics. It's a very fascinating and very interesting topic if you decide to do a deep dive. I'm not very good at it, but personally I think it is very cool

    • @ProjectExMachina
      @ProjectExMachina 7 місяців тому +2

      I don't have mathematics foundations but II like Haskell because it makes me feel like I'm learning programming from the beginning. I learn it to fight depression, believe it or not, and it helps.

    • @timcarpenter2441
      @timcarpenter2441 8 днів тому

      I do not have the maths background or even background to learn the background. I so want to love Haskell, but so far I cannot grok it, nor the materials that try to help me do so.

    • @timur1538
      @timur1538 День тому

      I don’t even know if this comment is satire or not

  • @khengari77
    @khengari77 Рік тому +113

    Funnily enough I found Haskell quite straightforward from the beginning and I wrote my first "useful" project using it and I am like 3 weeks into the language.
    I really recommend everyone to do a paradigm switch it teaches you a lot. It doesn't have to be Haskell if you're not comfortable with it maybe consider trying ocaml, elixir, scala or even F#. Just break your norm.

    • @reed6514
      @reed6514 Рік тому +16

      I miss learning new tech. After work, i just don't have the mental capacity for it. And if i do feel like coding, i typically wanna improve one of my many foss projects.

    • @XplosionYT
      @XplosionYT Рік тому +10

      OCAML made me fall in love with programming

    • @pertsevds
      @pertsevds Рік тому +1

      "3 weeks", omg, that's a lot.

    • @astroid-ws4py
      @astroid-ws4py Рік тому +2

      You forgot Clojure or Lisp.

    • @DrunkGeko
      @DrunkGeko Рік тому +2

      ​@@reed6514 i don't know if I would call it "new tech", it's more of an entirely different paradigm really. And that's why it is so cool and useful to learn, it just trains your brain to think in entirely new ways that make you feel stupidly smart even though you really aren't that special at the end of the day

  • @zackyezek3760
    @zackyezek3760 Рік тому +3

    Haskell and friends contain many good ideas.
    The problem is they suck as actual programming LANGUAGES. Their syntax is terrible, and not everything in the world is modeled well by verbs. The real world has both nouns & verbs; pure OOP languages suffer a milder version of this same problem by refusing to have 1st class functions. All you need do is look at Haskell’s inability to intuitively model files & I/O to see the underlying problem. A file is an inject, a thing, not a process.

    • @СергейМакеев-ж2н
      @СергейМакеев-ж2н Рік тому +1

      Strongly-typed functional languages are just as much about "nouns" as they are about "verbs". The use of "Maybe", "Either" and other algebraic data types is a way better approach to "nouns" than in the OO languages.

    • @Vitorruy1
      @Vitorruy1 Рік тому +1

      ​​@@СергейМакеев-ж2нnd imperative is superior to both IMO, no noun/verb nonsense, no false pretense that the real world can be accurately and consistently modeled through code, just data and functions.

  • @kurtmayer2041
    @kurtmayer2041 Рік тому +8

    while the instructions were kind of unclear, that's a terrible solution that chatgpt gave you, if just because it returns a function of *undefined*, which will throw an exception when evaluated.
    the best solution my friend and i could come up with, given the (again, very vague) assignment, was
    ... haskell code incoming, brace yourselves:
    data Tree a = Leaf a | Node [Tree a] deriving (Show, Eq)
    instance Semigroup (Tree a) where
    Node l Node r = Node (l ++ r)
    l@(Leaf _) Node [] = l
    Node [] r@(Leaf _) = r
    l@(Leaf _) Node r = Node ([l] ++ r)
    Node l r@(Leaf _) = Node (l ++ [r])
    l r = Node [l, r]
    instance Monoid (Tree a) where
    mempty = Node []
    a binary tree can't fulfill the associativity requirement on the Semigroup operator , so we instead defined an arbitrary tree where inner nodes have a list of their children. the obvious definition for concatenation (that's the operator) is then just appending those child lists at the roots, and the neutral element is a node with no children. if a leaf is involved, you just add it to the other node's children; if there are two leaves, you just combine them into a node.

    • @Instr
      @Instr Рік тому

      Binary tree can fulfill associativity requirement if the binary tree holds data in branches, not leaves, and the joining of a binary tree is done on the leaves.
      Think of defined as "left tree has right tree connected via the right-most leaf", then (tree tree) tree = connections via right-most leaf, tree (tree tree) looks exactly the same.

    • @Instr
      @Instr Рік тому

      As the question is proposed, you need a rose tree to make it work, since (tree tree) tree has the long portion on the left, whereas tree (tree tree) has the long portion on the right.

  • @torarinvik4920
    @torarinvik4920 Рік тому +32

    This is how I understand it: A Monoid sometimes called a Combinator in F# is a datatype that can be combined/concatenated. This is usually done on a collection such as a list or in your case a tree. Without using loops you have 2 choices either sum the tree recursively, or use the more elegant method by using a fold. Fold applies a binary function such as plus operator between all elements of the Monoid. So applying fold on + function on the list [1,2,3] it sticks the plus in between the values and calculates a result. Concatenating a string is also an example taking a list of strings and adding them together to form a larger string. So it's sort of like anything that is a collection that can be reduced to a single value. Another frequent operation of folds are checking if a list has "any of", "none of", or "all of" a certain element. So for instance fold (==5) [1,2,3,4,5] will result in the value false since not all values are 5. This is a somewhat simplified version. In a short sentence a Monoid is a collection that can be reduced to a single value(simplified version). Btw use F# instead of Haskell is my advice to everyone if you want to stay sane, Cabal will take 10 years off your life :-D

    • @woosix7735
      @woosix7735 Рік тому +4

      ah, F#, the Ocaml ripoff. (Im kidding. I don't actually know anything about F#, but it looks uncanny similar to OCaml)

    • @bigshrekhorner
      @bigshrekhorner Рік тому +9

      A monoid is simply a collection of elements that has just one operation defined for them, whose properties align with the properties of multiplication as we know it.

    • @torarinvik4920
      @torarinvik4920 Рік тому

      @@bigshrekhorner That is a good way to look at it.

    • @stevefan8283
      @stevefan8283 Рік тому +1

      Why combinator?

    • @torarinvik4920
      @torarinvik4920 Рік тому +1

      @@stevefan8283 Folding is about combining various elements into a new one. So «ab» + «c» = «abc». I think that is why they chose to call it that.

  • @CallousCoder
    @CallousCoder Рік тому +11

    1 minute and 3 seconds until you got lost! You outdone me!!! I was lost after 15 seconds - not worthy of a video in my case 😂 I just can’t understand that there are people who can program
    Haskell and not C/assembly…

    • @Finkelfunk
      @Finkelfunk Рік тому

      Well these are two different skillsets entirely. Good luck trying to program cryptographically secure applications in Assembly.

    • @CallousCoder
      @CallousCoder Рік тому +5

      @@Finkelfunk That's not that hard on modern cpus as there's hardare for that on the CPU. And frankly you wouldn't do that in Haskell either but in C/C++ :D

    • @blemmyes
      @blemmyes Рік тому +2

      @@Finkelfunk AFAIK haskell isn't that good for cryptographic security due to the potential implications of lazy evaluation for secrecy - half of the cryptonite library is written in C

  • @Zeitgeistpionier
    @Zeitgeistpionier Рік тому +74

    At University the Haskell programming class was (after OS programming with C) my second most favorite class (in IT - but of course nothing goes above Mathematics, which is my only true love).

    • @kikihun9726
      @kikihun9726 Рік тому +2

      You love Discrete math and analysis?

    • @Zeitgeistpionier
      @Zeitgeistpionier Рік тому +13

      @@kikihun9726 I don't narrow it down to these both topics. Mathematics is the beautiful search for truth. And all parts belong together.

    • @kikihun9726
      @kikihun9726 Рік тому +2

      @@Zeitgeistpionier i was acing all math classes until i faced dischrethe math. I failed on the first year🤣 so no. Don't group them together

    • @stevefan8283
      @stevefan8283 Рік тому

      you must be a cs-math double major student

    • @yahyae420
      @yahyae420 Рік тому

      @@kikihun9726 complete opposite. i got straight D's/C's in all my maths classes Except discrete maths, easy A-.

  • @Tomyb15
    @Tomyb15 Рік тому +52

    Haskell is the best programming language and there's nothing anyone can say to change my mind.
    With that said, this video showed basically how I felt when I began learning it.

    • @torarinvik4920
      @torarinvik4920 Рік тому +8

      It's certainly is extremely enjoyable to program in, but the tooling and ecosystem makes it difficult to use for real work. Not impossible, but difficult. The cabal folks should really study Cargo and pip, but at this time it might be too late.

    • @mskiptr
      @mskiptr Рік тому +4

      > pip
      But slightly more seriously: we would be way better off if we began replacing language-specific package managers with Nix or Guix

    • @torarinvik4920
      @torarinvik4920 Рік тому +1

      @@mskiptr Thats a really good idea! Love it!

    • @joestevenson5568
      @joestevenson5568 Рік тому

      What about the fact that Haskell literally can't even excecute without the Haskell runtime? - which is written in C, because of course it is.

    • @torarinvik4920
      @torarinvik4920 Рік тому

      @@joestevenson5568 There are of course pros and cons to having a runtime. It can help with a lot with concurrency like it does in Go and Swift. But you always pay a price for it of course.

  • @billigerfusel
    @billigerfusel Рік тому +9

    I was so lost just watching this minute

  • @harleyspeedthrust4013
    @harleyspeedthrust4013 Рік тому +15

    it helps to look at the math definitions for this kind of stuff, because that's what haskell and related languages are based on. a monoid is just a semigroup equipped with an identity element, and a semigroup is a set of elements with a closed "combination" operation defined over the set. you could take the set of natural numbers and form a semigroup where the operation is simple addition. to extend it to a monoid, define the identity element to be zero, because n + 0 = n. You could instead define a semigroup over the natural numbers that uses multiplication, and the identity element is 1. In this "assignment" the natural semigroup operation would be to create a new node and install both operands as its children, and the identity element would be an empty tree.

    • @homelessrobot
      @homelessrobot Рік тому +8

      i think the problem IS the math definitions (and the vocabulary itself) for most people. But this is a good explanation either way.

    • @colin398
      @colin398 Рік тому +6

      @@homelessrobot The problem is education that convinces people that math has to be hard

    • @idiomaxiom
      @idiomaxiom 11 місяців тому

      Versus: Think of a monad like a conveyor belt in a factory (the factory is your program). Items (values) are placed on the conveyor belt (wrapped in a monad). As they move along, various machines (functions) can act on these items, transforming them as needed. However, the items remain on the conveyor belt throughout the process (stay within the monad). In the end, you get a transformed item still on the conveyor belt (a new monad).
      The monadic operations allow you to chain together computations that might fail without having to constantly check for failure at each step. If any computation fails, the entire chain "short-circuits" with a failure result.

    • @jakekrajewski5300
      @jakekrajewski5300 4 місяці тому +1

      Wow it finally just clicked for me.

  • @philippebarillecavalier9275
    @philippebarillecavalier9275 7 місяців тому +2

    I took a break from Haskell after I tried modifying values in an XML document, looking for simple operations.
    It's been a few years...

  • @ZenoTasedro
    @ZenoTasedro Рік тому +20

    It seems we had the same impression of Haskell 😂
    I made more progress with Erlang, thanks to "learn you an erlang for great good" but most of the functional weirdness remains. This is why programming languages are for engineers, not math people who would do everything in lisp with cryptic single letter variables based on words nobody else has ever heard

    • @rake9768
      @rake9768 Рік тому +3

      There's "learn you a haskell for great good" too if you feel like taking another shot!

    • @torarinvik4920
      @torarinvik4920 Рік тому +8

      Abbreviations are the wrk of the dvl. Just wrt evrythng in pln eglsh.

    • @torarinvik4920
      @torarinvik4920 Рік тому

      @@AndreiGeorgescu-j9p I have done a ton of programming in Haskell as well as F# and learning Coq at the moment, and in my opinion Haskell isn't really about the math that one usually learns at school. One doesn't need to be good at math to do functional programming. I do find that people usually complains that Haskell is different from other languages or "I don't understand it", but of course that is just in the beginning until one gets used to it. With time it will become natural and intuitive.

    • @Jupiter__001_
      @Jupiter__001_ 3 місяці тому

      ​@@torarinvik4920 As a dyslexic person, that was awful to read.

    • @torarinvik4920
      @torarinvik4920 3 місяці тому

      @@Jupiter__001_ I can understand that!!!

  • @pedrovasconcelos8260
    @pedrovasconcelos8260 11 місяців тому +10

    Monoids are a useful concept in programming indepently of Haskell. For example: if an operation is a monoid (hence associative) then it can more efficiently evaluated in parallel but performing the computation as a tree instead of sequentially.

    • @grivza
      @grivza 9 місяців тому +2

      Yeah I think he got the meme wrong. It should have been something about monads. Monoids are a pretty straight forward concept. Monads are the ones notoriously hard to understand.

    • @bruhmoment1835
      @bruhmoment1835 9 місяців тому +1

      @@grivza aren't they just a proxy to represent whatever is inside them?

    • @grivza
      @grivza 9 місяців тому +1

      @@bruhmoment1835 No, monad is a monoid in the category of endofunctors, don't you know? But seriously, I don't know. Interesting explanation though, I'll keep it in mind.

  • @nicktreleaven4119
    @nicktreleaven4119 Рік тому +6

    The thing is if Haskell tutorials simply banned using math terms and built on my understanding of map, fold, closures etc, I'd probably get somewhere

    • @jboss1073
      @jboss1073 Рік тому +1

      If only Haskell folks fixed their package manager, we could all try learning the language.

  • @rokoblox
    @rokoblox Рік тому +7

    Your programming-wiki reading experience is so similar to mine!
    I thought I was just stupid lol 😂

  • @mrk131324
    @mrk131324 Рік тому +70

    Never used Haskell, but as a mathematician reading that short definition of a monoid, it sounded really straight forward and useful to me. It’s like a Group in mathematics, defining a type of object and a function of combining these objects - very straight forward.

    • @voxelfusion9894
      @voxelfusion9894 Рік тому +31

      That's because Haskell was cooked up by a committee of programming professors that wanted to represent higher mathematics more easily in code.
      It's by no means an efficient language, but it allows for very mathematical code, typically extremely short but incomprehensible. You'll usually only ever find it in research and teaching, hardly ever in practical applications.
      But if you want to play around with it as a mathematician, it might just be right up your alley.

    • @Instr
      @Instr Рік тому +8

      @@voxelfusion9894
      You do realize the imperative side is just slightly-more-verbose Python, right? And all you need to understand "pure" Haskell code is to be comfortable with recursion and be willing to read the definitions of the operators, functions, and values in use.
      main = for_ [1..100]
      um ->
      case (num `mod` 3, num `mod` 5) of -- case equals match + pattern matching, `mod` is the function mod (modulus, % in other languages) converted to an operator
      (0,0) -> putStrLn "FizzBuzz"
      (0,_) -> putStrLn "Fizz"
      (_,0) -> putStrLn "Buzz"
      _ -> putStrLn (show num)
      -- show converts a value of showable type to String
      for_ is a higher order function that takes a value of foldable type (a container that supports reduce operations) and a function that returns values of applicative type (IO is, in this case, an applicative type) and sequences the resulting applicative values together; this is the semantic equivalent of a for loop.

    • @tauiin
      @tauiin Рік тому +5

      @@jindrichsedlacek5298 at least thats readable instead of just character soup

    • @spl420
      @spl420 Рік тому +1

      ​@@tauiinwhat do you mean, what >>= does is intuitively understandable

    • @jboss1073
      @jboss1073 Рік тому

      @@voxelfusion9894 If you want an efficient Haskell, there is Rust.

  • @CubOfJudahsLion
    @CubOfJudahsLion Рік тому +38

    I actually recommend Haskell. To everyone. Sure, weird at first... but definitely worth it. It's not everyday (or every programming language) that, when you finish, you think to yourself "that's the most f***ing beautiful code I've ever written."

    • @Instr
      @Instr Рік тому +6

      @@doublewhopper67 Haskell refactors easily. The only reason you need skilled Haskellers is to work around performance and laziness issues, with the latter causing memory leaks. And you can always turn on strict mode with -XStrict to turn off laziness (in most cases), with a moderate performance penalty.
      Haskell can replace Python in any case where the Haskell library ecosystem is sufficient; since at the scale Python works at means that you're unlikely to face Haskell memory leaks, there's little to lose as long as you have the Haskell libraries you need.

    • @CubOfJudahsLion
      @CubOfJudahsLion Рік тому +6

      @@doublewhopper67 Suit yourself then. I'll keep it as my secret weapon ;)

  • @mzerone-g6m
    @mzerone-g6m Рік тому +3

    I think the problem with acadamic languages 😂😂😂😂 not with the functional languages

    • @qm3ster
      @qm3ster Рік тому

      Sorry, what problem? There's a problem?

    • @mzerone-g6m
      @mzerone-g6m Рік тому

      @@qm3ster it is not a practical languages

    • @qm3ster
      @qm3ster Рік тому

      @@mzerone-g6m that's not something shown in the video.
      Out of curiosity, what makes it impractical?

    • @isodoubIet
      @isodoubIet 9 місяців тому

      @@qm3ster bad syntax, bad tooling, inconsistent standards (everyone uses their own flavor of ghc with whatever cherry-picked extensions), bad compile times, huge binaries, bad/difficult-to-reason-about performance. It's also a fact that Haskell is difficult to learn and impossible to teach, which means using it in industry will greatly restrict the pool of available programmers.

  • @triggerost9023
    @triggerost9023 Рік тому +4

    The only course I failed during my undergraduate study is the Functional Programming, even though my lecturer is one of the creator of the GHC...

  • @alexandersanchez9138
    @alexandersanchez9138 Рік тому +4

    As a math major, Haskell’s typeclass names are very intuitive for me.

  • @almantuxas9248
    @almantuxas9248 11 місяців тому +2

    (Dis)functional programming.

  • @sumdumbmick
    @sumdumbmick 9 місяців тому +1

    mathematicians be like: functional programming just makes so much more sense!
    mathematicians also be like: 2^3 is 3 copies of 2 multiplied together, using 2 multiplications, because exponentiation is iterated multiplication so obviously when you multiply 3 times it results in 2 multiplications, which is why we can't figure out what 0^0 means.
    meanwhile irl: 2^3 = 1 *2 *2 *2; 2^0 = 1; 2^-3 = 1 /2) /2) /2)... so there's always an initial condition of 1 which explains everything perfectly including why 0^0 = 1. but because the 1 is optional in the expansion when the exponent is positive absolutely nobody ever noticed this, and the discrepency between the exponent and the number of multiplications in the conventional approach is doubled-down on in the definition of the hyperoperations, like tetration and pentation, etc. because... rigor? no, no... RiGoR!

  • @Terrados1337
    @Terrados1337 7 місяців тому +1

    When you leave someone to do a project, and they lock themselves in their basement for years, that project was probably a programming language.
    Haskell is made to drive mortals mad. But at least it isn't JS.

  • @calopii
    @calopii Рік тому +3

    I have just one question. Why?

  • @zamplify
    @zamplify Рік тому +2

    Lmk if you ever figure out how to exit vim, I've been stuck here for three years.

  • @ZantierTasa
    @ZantierTasa 10 місяців тому +1

    "yields the trees appended at the root node". What root node? How do you append trees?

  • @OnFireByte
    @OnFireByte 5 місяців тому +1

    not gonna lie, it kinda easy to understand if you get the idea that Semigroup is stuff that can be concatenated, and monoid is just Semigroup + mempty function that return default value.
    The 4 line semigroup part is just a pattern matching that tell what to do if it get the leaf or the tree 🤓☝

  • @nyverinorlyth9555
    @nyverinorlyth9555 Рік тому +2

    * lang is evil
    Long live rust lang

  • @thanatosor
    @thanatosor Рік тому +7

    It's really painful to move from imperative to functional programming

    • @2k10clarky
      @2k10clarky Рік тому +10

      A pain in the monoids

    • @dithy
      @dithy 7 місяців тому

      Its even harder to move back to imperative

    • @thanatosor
      @thanatosor 7 місяців тому

      @@dithy imagine getting used to Rust safety standards then back to JS 🤷‍♂️

    • @dithy
      @dithy 7 місяців тому

      @@thanatosorwho codes in JS? its only a compiler target 😆

  • @qm3ster
    @qm3ster Рік тому +1

    Did you get mad because of how simple the `append` "implementation" was?
    Or because of 🤢`undefined`🤮?

  • @ashk3734
    @ashk3734 9 місяців тому +1

    Haskell is a real piece of work, it's a pain. Almost any other functional language is easier to learn. Absolutely pointless dump that forces recursion.

  • @ic6406
    @ic6406 9 місяців тому +3

    Next time, when a friend asks you to learn them programming and you are confused why they can't understand so obvious basic programming principles, think about haskell

  • @stopper0203
    @stopper0203 Рік тому +12

    More Haskell please 🥹👉👈?

  • @DummyFace123
    @DummyFace123 8 місяців тому +1

    I like the video, but all languages are garblygoop when you name variables like that 😄

  • @yash1152
    @yash1152 Рік тому +1

    0:46 since when do vim has right click context menus for "cut, copy, paste, del"?

  • @r2com641
    @r2com641 4 місяці тому +1

    Is this language created by mazochists for mazochists?

  • @Yewtewba
    @Yewtewba Рік тому +5

    Way back in 2002 this was typically the 1st programming language my uni taught for computer science, though I happened to take a C elective before it. I thought it was interesting rather than annoying, as I had little exposure to programming before then.

  • @biomorphic
    @biomorphic Рік тому +3

    This was funny, I would have done the same. And as you, I am closing the laptop, getting a shower, and going to the groceries store.

  • @originalni_popisovac
    @originalni_popisovac Рік тому +1

    im not sure if few hours back the text on the thumbnail was different but nvm once i posted a video and changed the thumbnail like 5x times 💀

  • @disekjoumoer
    @disekjoumoer 8 місяців тому +1

    I did seriously lol. Haskell reminds me of all that is bad in our world.

  • @electroflame6188
    @electroflame6188 Рік тому +1

    You'd absolutely hate prolog going off your username.

  • @yoavmor9002
    @yoavmor9002 Рік тому +8

    In math, a Monoid is a group of objects as well as a function that takes any two of those objects and returns a third one; such that the function is associative and there exists a neutral element in the group
    For all a,b,e in the group:
    the function (f) is associative if f(a,f(b,e))=f(f(a,b),e)
    e is neutral if f(a,e)=f(e,a)=a

    • @DavidLoveMore
      @DavidLoveMore Рік тому +2

      I've learnt quite a lot thorough watching this video because of reading helpful comments like this.

    • @friedrichmyers
      @friedrichmyers 10 місяців тому +1

      Ok. I understand the fn you gave here. What deparment of Mathematics is this exactly? And can I learn it on a 10+2 Level of Mathematics that I'm currently on? Meaning that I know know what someone needs to know to study Engineering.

    • @yoavmor9002
      @yoavmor9002 10 місяців тому +1

      @@friedrichmyers Not sure what department of Math this is in.
      I studied that for engineering so shouldn't be a problem for you.
      This isn't related to Calculus

    • @friedrichmyers
      @friedrichmyers 10 місяців тому

      Yeah, I think it is related to Discrete Mathematics and Set Theory, then.@@yoavmor9002

    • @mycrushisachicken
      @mycrushisachicken 10 місяців тому +2

      @@friedrichmyers abstract algebra

  • @彩虹97
    @彩虹97 5 місяців тому +1

    gosh,I wound rather be abused by those borrow checkers.

  • @ohwow2074
    @ohwow2074 Рік тому +2

    The code looked like it was written by some faros back in the ancient Egypt.

  • @alexhd4747
    @alexhd4747 Рік тому +2

    i love haskell its utterly incomprehensible

  • @V0W4N
    @V0W4N 6 місяців тому +1

    that how to exit vim was personal 😭

  • @burnin8orable
    @burnin8orable Рік тому +10

    Is it weird that I really like both C and Haskell? They are at opposite ends of the spectrum but both great at what they do.

    • @Diapolo10
      @Diapolo10 Рік тому +3

      How, exactly, are they polar opposites? Because to me they're way less different than, say, Java and Haskell.
      C and Haskell are both relatively small, terse, and you can technically use both for functional programming. In contrast, Java is very verbose, has a ton of boilerplate, and you can realistically only do OOP with it.

    • @burnin8orable
      @burnin8orable Рік тому

      @@Diapolo10 Fair point.

    • @khengari77
      @khengari77 Рік тому

      No it's perfectly normal. I'm also like that.

    • @khengari77
      @khengari77 Рік тому

      ​@@Diapolo10
      I'm not sure what you mean when you say Haskell is small because Haskell is actually one the largest and richest languages that I was exposed to.

    • @Diapolo10
      @Diapolo10 Рік тому +1

      @@khengari77 At least from my point of view, Haskell's "vocabulary" is fairly small. Like in C, there's the usual operators, and a few keywords thrown into the mix.
      Compared to Python, C++, Java, or C#, the total is considerably less.

  • @MaxonerousX
    @MaxonerousX 10 місяців тому +2

    foldr mappend mempty

  • @dithy
    @dithy 7 місяців тому +1

    The task isn't clear whether it has to be a binary tree and the trees have to be added continuously, or a regular tree with all the trees at root at the end. I understood the later, which makes ChatGPT's solution incorrect. It would be a really easy task however, since all you have to do is lift the list monoid.

    • @dithy
      @dithy 6 місяців тому +1

      @@TapetBart any tree that can fulfill the requirement to have *the trees appended at the root node*. a binary tree can not have more than two trees at the root node at the same time.

  • @holonholon1141
    @holonholon1141 Рік тому +3

    its ez bro Haskell is just a Lisp but with types instead of parens

  • @Manuel-j3q
    @Manuel-j3q Рік тому +1

    Wow, you managed to exit vim?! Ho did you do that?

  • @benpowell3993
    @benpowell3993 Рік тому +2

    Haskell Programming from First Principles is a wonderful book, and I absolutely recommend it if you read Learn You a Haskell for Great Good and hit a wall at typeclasses.
    Haskell is fun as hell when you "get it", and HPFP makes getting it fun and easy-ish.

  • @hardshellin6673
    @hardshellin6673 10 місяців тому +1

    Haskell code giving off abstract algebra vibes

  • @didiok7
    @didiok7 Рік тому +4

    Had to learn it on functional programming classes and was actually really fun. Extreme confusing on the beginning, but when it clicks your brain fly

  • @magoomba
    @magoomba Рік тому +1

    It's easy, just "foldr mapend mempty"

  • @DriftKing18594
    @DriftKing18594 Рік тому +2

    I'm getting Vietnam flashbacks to my college module with Haskell.

  • @jurajchobot
    @jurajchobot Рік тому +28

    Well, it looks like it's a brand new concept. Programming is a form of communication and if you were used to communicate in Italian, you can't expect to switch to French in a couple of minutes. It looks like Haskell requires heavier background in mathematics and some extra vocabulary. Only once you get there you can start judging the language. Imagine if the entire world spoke Mandarin and they would refuse English for being too hard to learn. Does it really mean Mandarin is so easy?

    • @reed6514
      @reed6514 Рік тому +3

      I agree, and i understood the video as good humored teasing.

    • @Vitorruy1
      @Vitorruy1 Рік тому

      For those people yes

    • @jboss1073
      @jboss1073 Рік тому

      Maybe and Either are not "brand new concepts", they have been around in our field of Computer Science for many, many decades. Please inform yourself about your own field instead of saying silly things like "Maybe and Either sound like brand new concepts!"

    • @jurajchobot
      @jurajchobot Рік тому

      @@jboss1073 A brand new concept for him or anyone who wants to learn it. I never specified it. Mandarin is a brand new concept for anyone too, although it's been around for ages.

    • @jboss1073
      @jboss1073 Рік тому

      @@jurajchobot But Mandarin has nothing to do with programming, whereas you are supposed to know the mathematical foundations of computer programming if you are a programmer. So your analogy is invalid.

  • @exitus2010
    @exitus2010 Рік тому +2

    had to use haskell in one of my university courses...made a serious knot in my brain.

  • @qweriop
    @qweriop Рік тому +1

    Ah, haskell. My favorite esolang.

  • @attilatorok5767
    @attilatorok5767 10 місяців тому +1

    Bro, mempty = undefined sent me 💀

  • @warplanner8852
    @warplanner8852 Рік тому +1

    Wasn't it invented and developed by Eddie Haskell, that neighbor kid on Leave It To Beaver?

  • @abadreference
    @abadreference 11 місяців тому +4

    I'm in the process of learning Haskell for a class right now and this explains perfectly how I feel

    • @thomas_c
      @thomas_c 8 місяців тому

      Good luck, I went through that last year and it was the worst time of my life (I had to implement AES encryption with Haskell)

  • @ksb2112
    @ksb2112 Рік тому +1

    I get that same feeling about web frameworks.

  • @yesdo8758
    @yesdo8758 5 місяців тому +1

    "how to exit vim" got me laughing 😂, too relatable

  • @abhinavnatarajan4180
    @abhinavnatarajan4180 4 години тому

    A monoid is a collection of things that can be combined to form other things - like combining numbers by adding them together - such that there's an analogue to 0, which when combined with some other thing x just returns x. Here are examples of monoids that we probably use every day: (whole numbers, +, 0), (lists, list concatenation, the empty list), (words, word concatenation, the empty word), (matrices, matrix multiplication, the identity matrix), (dance choreography, joining up dance moves, staying still). You might notice the word "associative" in any "proper" definition of a monoid - this just means that (x + y) + z = x + (y + z). I'm not a professional programmer but I do need to write code for my job to implement mathematical or combinatorial algorithms, so I find these sorts of abstractions useful to compress the information I need to hold in my head when writing code. It takes some time to get used to the "conpression" and "decompression" while moving from idea to code. YMMV.

  • @uwuzote
    @uwuzote Рік тому +1

    Well this isn't really hard, monoids represent anything which can be combined in a way like lists or strings, with neutral element which when combined changes nothing.
    `mappend` is such combining
    `mempty` is such neutral element
    You had to implement Tree datatype and implement Monoid instance for it, which combines two subtrees into one
    and i know about about haskell like nothing

  • @OneMilian
    @OneMilian Рік тому +1

    You only pretented to close the laptop, because no programmer ever closes the laptop except he goes outside every few years.
    A good programmer always has some empty pizza boxes everywhere that validate his credentials, just like seeing his butt when he bends down, to impress the ladys.
    Coding and problem solving skills are secondary at best

  • @kivimangoproductions9655
    @kivimangoproductions9655 Рік тому +1

    dont waste your time, guys

  • @martingeorgiev999
    @martingeorgiev999 Рік тому +1

    haskell filters the soydevs

  • @torarinvik4920
    @torarinvik4920 Рік тому +1

    For anyone interested: #Here is a simple, but possibly flawed python snippet
    #to illustrate how the IO Monad works.
    class IO:
    def __init__(self, f):
    self.f = f
    def bind(self, g):
    return IO(lambda: g(self.f())())
    def __call__(self):
    return self.f()
    #A few functions wrapped in IO
    def ask_user():
    return IO(lambda: input("Please enter your name: "))
    def greet_user(name):
    print(f"Hello, {name}, nice to meet you!")
    return IO(lambda: None)
    def uppercase(s):
    return IO(lambda: s.upper())
    #Here is the "main" program. A Haskell program is a long
    #chain of commands executed in sequence.
    program = ask_user().bind(uppercase).bind(greet_user)
    program()
    #The program uses bind to glue IO operations into a bigger
    #IO operation, they are composable :)

  • @flaviomprado
    @flaviomprado Рік тому +2

    This is funny :)
    I do programming in haskell as a hobby (yes) but i say something along with the motto of the video:
    Haskell itself is not hard, the type system is kinda of. The big problem on the past was the lack of learning material that don't try to prove that something is a monad, or something like that.
    If you are really triyng to learn haskell first read learn yourself a haskell for great good from lipovaca, then read Haskell in depth from Bragilevsky. Both are more focused on the programming than the theory behind the language and the type system.

    • @isodoubIet
      @isodoubIet 9 місяців тому +1

      I wouldn't even say the type system is difficult per se; but the compiler error messages are criminally bad.
      The other problem is the glut of monad tutorials written by people who don't understand monads.

  • @adriteixehax
    @adriteixehax 10 місяців тому +1

    How to exit vim😂😂

  • @nobyra
    @nobyra Рік тому +3

    Decided to try learning at least one FP language yesterday for the sake of understanding it's concepts and this drops. Can't decipher if it's a good sign or...

    • @SaHaRaSquad
      @SaHaRaSquad Рік тому +4

      I can really recommend learning functional programming, but imho don't start with Haskell unless you love maths. Haskell is just mathematics pretending to be a programming language, and there are others which are much simpler.

    • @nobyra
      @nobyra Рік тому

      @@SaHaRaSquadif Haskell is math pretending to be programming that is kinda cool haha but not what I'm looking for. I just want to learn FP concepts. There's still Ocaml to consider.

    • @qm3ster
      @qm3ster Рік тому

      @@SaHaRaSquad Which do you recommend?

  • @BenEehayeh
    @BenEehayeh Рік тому +1

    Lisp, Clojure, Scheme, Guile, Zig
    Christian Schafmeister, Why he chose Lisp for complex 3D molecular modeling for Chemical Engineering.
    See Andy Keep and his Nanopass compiler, very cool.

  • @raptoress6131
    @raptoress6131 Рік тому +1

    Just popped in to say that a monad is a monoid in the category of endofunctors

  • @KoltPenny
    @KoltPenny 5 днів тому

    Watching you struggle with Haskell as much as I do, reminds me that I'm not stupid, just not patient enough to deal with this language.

  • @HappyCheeryChap
    @HappyCheeryChap Рік тому +1

    A monad is just a monoid in the category of endofunctors. What's the problem?

  • @astrahcat1212
    @astrahcat1212 Рік тому +1

    "Obviously" loool

  • @sicko_the_ew
    @sicko_the_ew Рік тому +1

    Ah! So a monoid is just a monoid, then? Binary operation, closure, and that's it? (I think that's all the structure it has).
    Maybe I'm wrong, but I saw a semigroup there, and that's one complication up from a monoid. I mean a monoid-monoid ... um ... an actual monoid - which a Haskell monoid is looking like it might be ...
    At which point this becomes like the ancient Punch cartoon where a man and a little girl are walking into a field on a country ramble, and the little girl says, "What's that, Daddy?"
    Daddy: "That's a cow, dear."
    Little Girl: "WHY?"

  • @Y0y0Jester
    @Y0y0Jester Рік тому +3

    love the meme content, keep em coming 👍

  • @StepwaveMusic
    @StepwaveMusic Місяць тому

    For those trying to understand, the 'monoid' in this case is just a way to add properties to your type. When a type is a monoid, you can assume it always has 2 functions: an empty function, kind of like the first element of a set/category. Think of this as 0 for natural numbers, or the empty list. Then there is a binary function that can take 2 instances of the same type, and produce a new instance of that type. For integers, this could be addition, for lists this is appending lists together (just like for this tree).
    Essentially, because appending 2 instances of the Tree type has a couple of different cases, we use the Semigroup to cover the complexity of appending. But now, mempty is the empty function, and is the append function. Whenever you use type Tree, you can always use these functions, essentially making the type a monoid. It's just a way of summarizing certain properties that a type has.
    Now, the type definition is a bit harder to grasp... these are inductive types and they're just recursive (like everything in Haskell), but I wouldn't be able to explain this here