What is IO monad?

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ธ.ค. 2024

ความคิดเห็น • 140

  • @AdamSchelenbergCom
    @AdamSchelenbergCom 6 ปีที่แล้ว +157

    Trust me, I'm an engineer.

    • @cadebriar9921
      @cadebriar9921 3 ปีที่แล้ว +1

      @Amos Royal yea, have been using flixzone} for years myself :)

    • @daytondeclan3567
      @daytondeclan3567 3 ปีที่แล้ว

      @Amos Royal yup, been using Flixzone} for months myself :D

  • @cuadernoazul5958
    @cuadernoazul5958 8 หลายเดือนก่อน +6

    Wow man you are the first content creator who really explains IO monad clearly and rigouroly without philosophical bullshit. Congrats!

  • @kozmicluis2552
    @kozmicluis2552 6 ปีที่แล้ว +56

    I love it everytime I hear eye-oh monahd

  • @leonardomoraes6505
    @leonardomoraes6505 5 ปีที่แล้ว +43

    HEY, that's just state monad with the state being the outside world!

  • @Bravo-oo9vd
    @Bravo-oo9vd 5 ปีที่แล้ว +100

    "Monad is just a monoid in the category of endofunctors, what's the problem?"

    • @anticipayo
      @anticipayo 4 ปีที่แล้ว +3

      Duuuhh!

    • @EidosGaming
      @EidosGaming 4 ปีที่แล้ว +5

      "You just made these words up!"

  • @tricky2014
    @tricky2014 6 ปีที่แล้ว +47

    You are really good at explaining things in an accessible way. Also your pacing and tone of voice is very good.

  • @peter62709
    @peter62709 5 ปีที่แล้ว +65

    This is the first explanation of a monad that actually made sense to me, and also the first I've come across that explained it as changing the state of the world. It seems a lot simpler now. Thank you!

    • @Tsoding
      @Tsoding  5 ปีที่แล้ว +43

      This is not an explanation of a monad. This video is about the *IO* monad specifically. There are many different monads out there. And they all do different things.

  • @kahnfatman
    @kahnfatman 2 ปีที่แล้ว +6

    THE BEST IO Monad explanation - EVER! This is PURER than gold.
    Btw, I love your wtf transformer.

  • @DeH4er1
    @DeH4er1 5 ปีที่แล้ว +20

    Хорошая работа, спасибо за видео!

  • @himselfe
    @himselfe 6 ปีที่แล้ว +75

    First 15 minutes: Hey, Haskell doesn't seem that bad! Might try learning it...
    Last 20 minutes: Why!? Seriously... WHY!?

    • @Tsoding
      @Tsoding  6 ปีที่แล้ว +43

      IT'S A TRAP!

  • @ivanperevezentsev7395
    @ivanperevezentsev7395 5 ปีที่แล้ว +31

    Perfect, finally I understood the IO monad. The explanation with world transformers really makes sense.

    • @GerinoMorn
      @GerinoMorn 3 ปีที่แล้ว +6

      I went from "what is IO monad" to "I probably can implement it from memory" in 30 min. The guy is amazing truly.

  • @cranknlesdesires
    @cranknlesdesires 4 ปีที่แล้ว +8

    Tonight on CN9 News; Russian Hacker replements reality in program to print names, solves science in the process; are jackets really used to keep you warm or are they a Chinese marketing ploy?

  • @sho3bum
    @sho3bum 6 ปีที่แล้ว +35

    This is exactly how brian beckman explained monads but instead of using the world as an universal set he used monoid, this is a pretty nice example, I loved it!

  • @andrew_ray
    @andrew_ray 5 ปีที่แล้ว +16

    I knew it would be `unsafePerformIo`. That weird behavior of performing side effects in the middle of printing a supposedly pure value is a classic example of the issues of `unsafePerformIo`.

  • @yagarf9510
    @yagarf9510 2 ปีที่แล้ว +10

    My first Haskell book just came in the mail and I’m super excited to explore the world of FP. I decided to pause the video until I learn more Haskell but I will surly come back and rewatch after playing around with Monads on my own!

  • @superrritschy
    @superrritschy 4 ปีที่แล้ว +12

    Damn. This is the best explanation of IO Monad I’ve ever seen.

  • @EidosGaming
    @EidosGaming 4 ปีที่แล้ว +5

    I just wanted to know about input output now I have an existential crisis on whether the world is just a state or not

  • @Diamonddrake
    @Diamonddrake 10 หลายเดือนก่อน +3

    If a pure function is a function that always returns the same result for the same input then preventing the possibility of passing the same input twice makes it effectively pure... But also… what?

  • @hansschenker
    @hansschenker 4 ปีที่แล้ว +2

    Imperative programming is vertical: statement after statement! ≡
    functional programming is horizontal: funtion -> function - - -

  • @exciting-burp
    @exciting-burp 2 ปีที่แล้ว +2

    I'm going to have to watch this 3 more times, but I this video have have been the furthest I have gotten in terms of understanding monads.

  • @fyradur
    @fyradur 4 ปีที่แล้ว +14

    This is one of the best videos I've ever seen, regardless of genre for the last 10 years of watching TH-cam atleast 2 hours a day.

    • @arshadpakkali
      @arshadpakkali 3 ปีที่แล้ว +1

      Jokes on you im watching 5 hrs a day and still confused about monad but this video actually made some things work on my brain

  • @b_two
    @b_two ปีที่แล้ว +3

    conceptualizing side effects as a localized illusion in a pure global function is genius

  • @vnshngpnt
    @vnshngpnt 3 ปีที่แล้ว +3

    Brilliant video man, very good :) It's a very interesting approach to explain monad (well, just IO monad) from a different perspective, from top to bottom so to speak, without first explaining functor and applicative. Inspires to keep learning Haskell and FP

  • @andreffrosa
    @andreffrosa 4 หลายเดือนก่อน +1

    I think it would be cool to now explain monads but instead using an imperative language, like C.

    • @agcouper
      @agcouper 2 หลายเดือนก่อน

      Check Bartosz Milewski videos, he does exactly that.

  • @redumptious2544
    @redumptious2544 3 ปีที่แล้ว +3

    Others: Learning math from some Indian dude
    Me, an intellectual: Learning Monads from some slavik dude
    Great tutorial, thank you 👍

  • @gerardgauthier4876
    @gerardgauthier4876 6 ปีที่แล้ว +6

    I thought Martin Odersky said "The IO monad does not make a function pure. It just makes it obvious that it's impure.".

    • @Tsoding
      @Tsoding  6 ปีที่แล้ว +8

      For that I have only one thing to say: 6:31

    • @gerardgauthier4876
      @gerardgauthier4876 6 ปีที่แล้ว

      @@Tsoding@ I find Haskell and Java suffer from the same problem. They take a limited(rigid) paradigm and shoehorn unlimited problems/solutions into it. A monad is a beautiful/simple design pattern that becomes 'almost' incoherent when its applied to state in a 'pure' system.

    • @leftaroundabout
      @leftaroundabout 6 ปีที่แล้ว +5

      The comparison with Java doesn't fit, but you could perhaps say this about Smalltalk, which (unlike Java) is a purely-OO language. If you design the fundamental principles of a language rigidly around a paradigm, then it changes the very meaning of what “programming” is. From that point it's nonsensical to complain you can't do mutation etc., because mutation is not a concept that _can exist_ - or in Smalltalk, standalone functions aren't something that can exist.
      Java with OO, or F# with functional (or Scala with both!), give you a weird compromise: they are in principle imperative, but then impose restrictions on how this imperative code is supposed to be structured. “Patterns”. But that's missing the point IMO.
      In particular a monad is not a design pattern, it's a _property_ of some higher-order type. It turns out that the State-Of-The-World updating that needs to be done to model imperative in a pure-functional language fulfills the property of being a monad. But in an impure language, there's actually no way to prove a property like that, so F# and Scala don't have monads.
      (Strictly speaking, you can't prove it in Haskell either because of ⊥, but in “total Haskell” you an prove it.)

    • @gerardgauthier4876
      @gerardgauthier4876 6 ปีที่แล้ว

      @@leftaroundabout@ I guess the jury is still out on - design pattern. en.wikipedia.org/wiki/Monad_(functional_programming)

    • @leftaroundabout
      @leftaroundabout 6 ปีที่แล้ว +4

      @Gerard you should know not to quote Wikipedia as an “authorative reference”, right? Quote Eric Lippert directly. Unfortunately, he doesn't really understand monads (as variously proved online), he's just good at using _the translations of particular Haskell monads into imperative/OO languages_ - which can be pretty useful already, no doubt, but it's still little more than cargo-cult-science.
      What a monad really is is explained in Wiki's category theory article on the subject.
      en.wikipedia.org/wiki/Monad_(category_theory)
      This is not to say that one must understand all of that, certainly not the part about adjoint functors, to use monads. You're good if you know the monad laws and how to prove them within the pure subset of your favourite language. But you should keep in mind that there's more to monads than that.

  • @anticipayo
    @anticipayo 4 ปีที่แล้ว +3

    A perfect Haskell program is an inEFFECTive program by definition

  • @Tomyb15
    @Tomyb15 2 ปีที่แล้ว +3

    I really liked this approach to understanding the IO Monad. However, I'm a bit confused on the aspect of calling the diy monad "pure" in the abstract when we know that the function readStr doesn't always return the same result from the same input, given that what the function reads from stdin isn't part of its "inputs".

    • @fredoverflow
      @fredoverflow 2 ปีที่แล้ว +4

      stdin is part of World

    • @christophhofer303
      @christophhofer303 ปีที่แล้ว +4

      Well its pure because it always returns the same thing given the same world. The „world“ is you sitting in front of the computer and typing into the console.

  • @duanwen4648
    @duanwen4648 4 ปีที่แล้ว +2

    Dude, love your channel, please keep doing it

  • @juang.garcia7390
    @juang.garcia7390 ปีที่แล้ว +1

    Absolutely brilliant. You've won a subscriber

  • @guidof6116
    @guidof6116 4 ปีที่แล้ว +3

    Well, I guess changing the world wasn't that hard after all

  • @thymiosdouvis575
    @thymiosdouvis575 4 ปีที่แล้ว +4

    "What is my name btw?" hahahaha

    • @DanDart
      @DanDart 4 ปีที่แล้ว +2

      Side effects make you forget your name.

  •  4 ปีที่แล้ว +1

    Now for me is completely clear... I have to study more.

  • @Zorgatone
    @Zorgatone 4 ปีที่แล้ว +1

    Name of the outro song?

  • @vorname1485
    @vorname1485 3 ปีที่แล้ว +1

    Me being asked: "What are all those red buttons?"
    Me: "side effects"
    Me being asked: "Is the app finished? I'v started it but nothing happens"
    Me: "Oh, you wanted it with side effects?"

  • @IvanNIlic
    @IvanNIlic 4 ปีที่แล้ว +1

    28:09 seconds of pure triumph (as the shit flies towards the fan)
    . oh, inverted World!

  • @markuspfeifer8473
    @markuspfeifer8473 5 ปีที่แล้ว +1

    What if I want to have two buttons - one button starts a lengthy operation and the other button can abort it because it takes too long? That sounds quite hard to me...

    • @deidyomega
      @deidyomega 5 ปีที่แล้ว

      Yeah... in python, js or any oop language that's super easy... not sure about haskell though

    • @PacificBird
      @PacificBird 2 ปีที่แล้ว +2

      @@deidyomega Monads in Haskell have a lot of extra functionality baked into them that allows for concurrency and stuff, so this isn't a problem.

  • @nekoill
    @nekoill 4 ปีที่แล้ว +2

    Is it just me, or functional programming languages are very distinctively similar in syntax? Elixir, Clojure, Haskell, Elm as well (I think)... Only Lisp is its own beast, E-Lisp specifically.

  • @detaaditya6237
    @detaaditya6237 4 ปีที่แล้ว +2

    You can't spell haskell without hell

  • @valigotech
    @valigotech 6 ปีที่แล้ว +8

    Surprisingly, I kinda get it and feel a bit "whoa"! Cool, really great video!
    Btw, I assume that underneath this nicely done illusion of a pure environment lies highly mutable conglomeration which is built in C. Otherwise, this whole thing would've consumed all memory really fast. Am I right?

    • @alexeykutepov3767
      @alexeykutepov3767 6 ปีที่แล้ว +5

      I don't know the specifics of the IO implementation, but IO itself is defined in terms of something called `State# RealWorld` github.com/ghc/ghc/blob/2c959a1894311e59cd2fd469c1967491c1e488f3/libraries/ghc-prim/GHC/Types.hs#L187 the value of which occupy 0 space: stackoverflow.com/a/32673064/2951870

    • @sbditto85
      @sbditto85 5 ปีที่แล้ว +5

      if you are referring to the fact that Haskell has a runtime then yes. Often people describe it as your Haskell program is a recipe that the runtime "chef" creates (runs) for you

  • @justinroughley151
    @justinroughley151 5 ปีที่แล้ว +2

    Really great explanation of IO Monad - Thanks

  • @arcuscerebellumus8797
    @arcuscerebellumus8797 8 หลายเดือนก่อน +1

    Ok, I sorta' get the "how" (not really)... but, WHY?

  • @TheOlian04
    @TheOlian04 6 ปีที่แล้ว +2

    So a monad is a pure function that takes and returns a world-state?

    • @Tsoding
      @Tsoding  6 ปีที่แล้ว +8

      Yeah, I believe it's a pretty good way of thinking of it. Of course internally the actual IO is probably just a bunch of hacks, but on the outside it's a pretty good way to fit side-effects into a pure functional language.
      P.S. Keep in mind that we are talking specifically about IO monad. Not monads in general. There are many monads. And not all of them are about modifying real world states.

    • @monnef
      @monnef 6 ปีที่แล้ว

      I believe monad is rather a type, which has an accompanying operator (pure function - bind) which transforms the world.

    • @ViktorKronvall
      @ViktorKronvall 6 ปีที่แล้ว +8

      No, the IO monad is a monad that hides the world type which is used by the Haskell runtime similar to what was shown in this video.
      A monad is a much more abstract concept. A monad (in Haskell) is some data type that has three functions defined for it. Let’s call this data type `x`. The three functions are then:
      1. fmap :: (a -> b) -> (x a -> x b)
      2. pure :: a -> x a
      3. (>>=) :: x a -> (a -> x b) -> x b
      What is more there are some laws that must hold for these three functions for the data type to actually be a monad.
      1. fmap f . fmap g = fmap (f . g)
      2. fmap id = id
      3. pure x >>= f = f x
      4. m >>= pure = m
      5. (m >>= f) >>= g = m >>= (\x -> f x >>= g)
      where id is the identity function implemented as `id x = x`. It just returns what it’s passed.
      If you can prove those five properties you have a monad. If you are interested I can show you the proof for these properties for WorldM.

    • @beforth
      @beforth 5 ปีที่แล้ว

      A monad is a type within a context, a function to wrap a value of the type into the context, and another function to apply a function to a value of that type inside the context. Plus in haskell you have syntactic sugar (do notation) to avoid explicit nesting of functions, so you don't have to count parens. But it's easy to mix both concepts and get confused.

  • @dvtt
    @dvtt 3 ปีที่แล้ว

    Is there a link to the code ie - github?

  • @unrealnews
    @unrealnews วันที่ผ่านมา

    Is IO Monad a case of changing the world through meditation?

  • @junderfitting8717
    @junderfitting8717 3 ปีที่แล้ว

    great video. I'm confused with "side effect", I've browsed the comments at the very bottom, but didn't get the answer.

    • @ea_naseer
      @ea_naseer 2 ปีที่แล้ว

      side effect is something additional your function does. For example a reverse function should reverse an array but it could also change the original array. Changing the original array here would be a side effect of reversing.

  • @0xlkda
    @0xlkda 2 ปีที่แล้ว

    Im still not get it.

  • @TRex-fu7bt
    @TRex-fu7bt ปีที่แล้ว

    I want that color scheme. That yellow pops.

    • @bhavyakukkar
      @bhavyakukkar 4 หลายเดือนก่อน

      Gruber darker (emacs theme is on his github and people have also ported it to vim/vscode)

  • @Jere1515
    @Jere1515 ปีที่แล้ว

    Thanks for the vidéo, it helps to understand better IO Monad.
    Is the world concept really used? Or is it just a "thought experiment"?
    Do you know if ZIO or IO from Cats Effect in Scala are implemented like that???

    • @sebastiangudino9377
      @sebastiangudino9377 ปีที่แล้ว +4

      In clean, yeah! But you cannot "touch" the world. And you cannot clone it either, since that's kinda the point of uniqueness typing
      In Haskell. The world is "There", but you cannot touch it either. The IO monad IS the world, when you input from the user for example you cannot just take the value out of the IO monad (The world). You have to keep it wrapped by the world's state. And you just send it the instructions to make a new world where your side effects will be executed. And get a new world as a result
      As you can see, the world is NOT accessible (We cannot touch the IO monad), which is GREAT because things are still inmutable. While also actually producing side effects by making those changes in the world manifest in your screen
      And of course since we don't need to access the "world". There is no reason for your computer to actually store the entire world, so the compiler optimizes it away 😉

    • @Jere1515
      @Jere1515 ปีที่แล้ว

      @@sebastiangudino9377 Thanks for the answer :)
      And what about IO executed in parallel? 😅

    • @sebastiangudino9377
      @sebastiangudino9377 ปีที่แล้ว

      @@Jere1515 FP is implementation dependant (So there is no "Other thread" as far a the Haskell type system is concerned). But in general each Thread would be running a function that takes an IO and returns an IO. Then a function (Like ForkIO) would make sure that, while they do happen at the same time, the world is still a just one world. And it does that by making sure the results of the functions gets "Applied" to the world in the correct order (So if for example you need to process two files at once and then concat the results and print them, haskell will make sure you are still using a function that gets the file from the world, then both files will start to process, but then when BOTH are done we will tell the world that file one is processed and a new world where ONLY that file is processed will come out, and then to that one we apply the already computed result of the other file and then we can concatenate and print them as if there was never a fork (Since we never cloned the world) )
      I'm not sure if my explaination is more confusing than helpful. But I hope it helped. As far there are never two world everything will still be "inmutable" to Haskell. That makes multiprocessing in Haskell a blessing and a curse. Since there is a little bit magic going on behind the scenes that makes it kinda hard to know WHAT exactly the code is doing physically. But I guess that's kinda the point of declarative code

  • @DanDart
    @DanDart 4 ปีที่แล้ว +1

    4:59 conspiracy

  • @joshbassett
    @joshbassett 8 หลายเดือนก่อน +2

    Mind blown 🤯

  • @AdamSchelenbergCom
    @AdamSchelenbergCom 6 ปีที่แล้ว +1

    If you draw a monad how it would look like?

    • @softwareminimalist
      @softwareminimalist 6 ปีที่แล้ว +2

      Like a railway :)

    • @Pradeep1989
      @Pradeep1989 6 ปีที่แล้ว

      @@NazariiBardiuk Thanks for sharing this link. This is super useful.

  • @DanDart
    @DanDart 4 ปีที่แล้ว +1

    by 8:46 "world" has no meaning

  • @aziz0x00
    @aziz0x00 ปีที่แล้ว

    First time I understand it!! Thanks a ton!!!!

  • @rnoro
    @rnoro 11 หลายเดือนก่อน

    What stops you making videos? It's a shame there is no update in this channel XD

    • @bhavyakukkar
      @bhavyakukkar 6 หลายเดือนก่อน +3

      he uploads videos very often on his other channel (most of which are vods of 2-3 hr streams where he implements a new idea in whatever language)

  • @AlexLexus42
    @AlexLexus42 2 ปีที่แล้ว +1

    Круто!
    Знаю что ты забросил писать на хаскеле, но я уверен, многие бы хотели увидеть haskell стримы от тебя!

  • @LeoOno
    @LeoOno 4 ปีที่แล้ว +10

    4:40 "you see what side effects do to you ?" lol xD
    very awesome video ! i'm trying to study haskell and please can you explain this part again for me?
    readStr :: World -> (String, World)
    can it be considered pure function ? i mean, i have the impression that even passing the same World, it can return different values ... am i misunderstanding something ?
    thanks for this amazing video :)

    • @nicolasmarcora9330
      @nicolasmarcora9330 4 ปีที่แล้ว +1

      Imagine that by World you're freezing time and capturing the exact state of the world as it was at that moment. If you print "Hello!" to it you get a new World where "Hello!" was said.
      Now you have two Worlds, the initial one, and the one you've printed to. If you keep printing to the initial World, you wouldn't be changing it, but creating multiple new Worlds with "Hello!" printed on them.
      It's confusing because you know that's not how things work in the real World. But it's a nice abstraction to keep things pure within Haskell while doing useful input and output.

    • @LeoOno
      @LeoOno 4 ปีที่แล้ว +1

      @@nicolasmarcora9330 first of all, thanks for your reply :D
      In the case of IO print, i could get the idea of 'world' + String argument returning the new 'world' with String printed to it, it's all immutable, so in this case i can see it's pure.
      But when it comes to IO user input, i'm still confused because i have the impression that passing 'world' as argument, it returns 'world' with some arbitrary String, so in this case how we can affirm this is pure ?

    • @kirill_itheo
      @kirill_itheo 4 ปีที่แล้ว +5

      Maybe its based on the idea that By knowing the state of the world we know what the user's input is going to be.

    • @mrmimeisfunny
      @mrmimeisfunny ปีที่แล้ว +1

      @@LeoOno The World (which includes the console window) gives you the input string. An alternate world where a different string was typed will get you a different string and a different world.

  • @hahas95
    @hahas95 2 ปีที่แล้ว

    Thank you for this video!!!

  • @WomboBraker
    @WomboBraker ปีที่แล้ว

    difficulty to write actually useful programs with fp paradigm is long lasting major problem hahahahahaha

  • @aziz0x00
    @aziz0x00 ปีที่แล้ว +1

    Haskell is just so amazing ❤

  • @johannbauer2863
    @johannbauer2863 5 ปีที่แล้ว +2

    Wow! This video is great! ^^

  • @gbcr09
    @gbcr09 5 ปีที่แล้ว +1

    Great video!

  • @arnejarek3308
    @arnejarek3308 6 ปีที่แล้ว +1

    keep up the good work

  • @nathaaaaaa
    @nathaaaaaa 5 ปีที่แล้ว +1

    Nah, I dont wanna learn relativity now

    • @vertie2090
      @vertie2090 4 ปีที่แล้ว +1

      No hello world in Haskell for you then ¯\_(ツ)_/¯

  • @jit_rs
    @jit_rs 5 ปีที่แล้ว +2

    Отличное видео
    Я не до конца понял почему тип оператора (>>=) именное такой, какой есть, но в целом очень помогло понять как пользоваться IO и как оно устроено

    • @expurple
      @expurple ปีที่แล้ว +1

      (>>=) :: m a -> (a -> m b) -> m b
      У нас есть две функции трансформации мира, которые мы хотим скомпоновать: `m a` и `m b`. Помимо собственно трансформации мира, эти функции ещё потенциально возвращают некоторые значения `a` и `b`. Скомпонованная функция будет возвращать последнее значение в цепочке, поэтому у финального результата тип `m b`. Тип `a -> m b` возникает из-за того, что у нас вторая трансформация может _зависеть_ от результата первой. Здесь например второй >>= компонует `readLn :: IO String` и `case :: IO ()`, значение которого зависит от name (результата readLn):
      whatIsYourBranchName :: IO ()
      whatIsYourBranchName =
      putStrLn "What is your name?" >>= \_ ->
      readLn >>=
      ame ->
      case name of
      "Alexey" -> putStrLn ("I love you, " ++ name)
      _ -> putStrLn ("I hate you, " ++ name)

    • @expurple
      @expurple ปีที่แล้ว +1

      For English speakers: here I'm explaining the signature of >>=. In case you're interested, my comment seems to be Google-translatable just fine

  • @niikurasu2855
    @niikurasu2855 2 ปีที่แล้ว

    Bro lives in the backrooms

  • @freaking1122
    @freaking1122 3 ปีที่แล้ว

    Well explained!

  • @SolathPrime
    @SolathPrime ปีที่แล้ว

    branchWorld :: World -> (World, World)
    I've tried the same thing in python it's behaviour is undefined

  • @xdman2956
    @xdman2956 ปีที่แล้ว +1

    28:43 Why did it print "(()" before "What is your name" ?
    btw great vid, Im the happiest one could be after filling in the >>>= return type and body myself despite not having written no haskell ever :) .* It is unreasonable how transferrable are some math skills to writing in a language I only saw type definitions in beforehand. (Well, being freshly after th-cam.com/video/e6tWJD5q8uw/w-d-xo.html helped with the monad return type and knowing what was going on - that we were writing flatmap :)
    Gosh, this 2-vid combo is the greatest to understand the topic in detail, if you know/broke your head for a while over what monad is, but without type definitions beforehand (all the "adding logging to functions" is a monad, "Option" is a monad like in this vid: th-cam.com/video/C2w45qRc3aU/w-d-xo.html and some by A Byte of Code).
    *Well, gotta admit I wrote composition explicitly as w->uncurry(f)(wt(w)) instead of uncurry(f) . wt (which I hope is too - syntactically, I mean). I could've thought of composition after the vid I mentioned and in general if I was more aware that it has to be in this language, but before you wrote it in its symbol could be ∘ for all I knew :)

    • @xdman2956
      @xdman2956 ปีที่แล้ว +1

      Oh, I think I see. I stopped immediatetly when I saw it, and then also expressed my gratitude. Turns out is not so mysterious just a few seconds later

  • @yungclump
    @yungclump 2 ปีที่แล้ว

    Seen.

  • @mechmaker9346
    @mechmaker9346 5 ปีที่แล้ว

    Very good video!
    About unsafePerformIO:
    1.it,s bad,because haskell hasn't got stability in evaluation,and
    monads is only thing,which helps you.
    2.It,s not declarative,to have dirty code in pure,it brings imperative order in declarative code.

  • @goosygoose2517
    @goosygoose2517 6 ปีที่แล้ว

    I made a snippet pastebin.com/z6GHKL8F. How the returned value from printStr (World) is the new state of the world. It is the same data constructor that was passed as an argument to the function. It's the same value, - World. And if you meant that every time you write data constructor World you get a different World (in that instance of time let's say), then that value (World) in itself is not pure and is against what a value is. 5 = 5. World = World.

    • @Tsoding
      @Tsoding  6 ปีที่แล้ว +2

      I lied

  • @first-thoughtgiver-of-will2456
    @first-thoughtgiver-of-will2456 3 หลายเดือนก่อน

    In Rust functions are third world citizens (Fn FnOnce FnMut)

  • @DjLeonSKennedy
    @DjLeonSKennedy 5 ปีที่แล้ว +1

    Жестко

  • @sidjoosin6549
    @sidjoosin6549 5 ปีที่แล้ว

    input and output - are not "side effect" . if your your function takes arguments and prints them on screen, like printf() or console.log() , this is not "side effect" of this functions, this is pretty strait effect, theese functions are made for output some args. Side effect - is when your function "add()" write something on screen, or return to the world something, but sum of args

    • @deidyomega
      @deidyomega 5 ปีที่แล้ว +1

      io is def a side effect

    • @sidjoosin6549
      @sidjoosin6549 5 ปีที่แล้ว

      @@deidyomega so function without io is pure? i think answer is obvious. there is no function in the world that don't takes input and don't returns output, who gives input args -- another fntion or user -- inside the function it is no difference. as well as it is no difference where it returned value -- to another fn or to your screen, or both

    • @deidyomega
      @deidyomega 5 ปีที่แล้ว +2

      ​@@sidjoosin6549 You can take an input and return an output without using print (or equivant)
      python example:
      def pure_add(a, b):
      return a+b
      def inpure_add(a, b):
      print(a+b)

    • @Bravo-oo9vd
      @Bravo-oo9vd 5 ปีที่แล้ว +5

      I think that "a side effect is something that a function doesn't say it's doing" might be a good way to put it

  • @sh_zik
    @sh_zik 4 ปีที่แล้ว

    World changese in time so....

  • @Chemaclass
    @Chemaclass 4 ปีที่แล้ว +1

    So easy going hahaha

  • @GerinoMorn
    @GerinoMorn 3 ปีที่แล้ว +1

    Why am I not surprised that the best Haskell tutorial I've ever seen is done by a Slavic brother... Amazing job!

  • @ethanpaulmorgan5123
    @ethanpaulmorgan5123 6 ปีที่แล้ว

    Dad

  • @androth1502
    @androth1502 5 ปีที่แล้ว +6

    i'll go with "you just switch to a good language."

  • @boku00
    @boku00 4 ปีที่แล้ว +1

    This is so illegal.

  • @venustheplanet8208
    @venustheplanet8208 3 ปีที่แล้ว

    I wuv yu

  • @nincako
    @nincako 5 หลายเดือนก่อน

    What is side effect? Since it is not stated, I am stopping this explanation. downvote!

  • @tahamagdy4932
    @tahamagdy4932 5 ปีที่แล้ว +2

    Emacs Craches! Try Vim :D

  • @SteinGauslaaStrindhaug
    @SteinGauslaaStrindhaug 4 ปีที่แล้ว

    This seems rather perverse...

  • @jlf1964
    @jlf1964 4 ปีที่แล้ว

    masturbation intellectuelle