• MagicShel@lemmy.zip
    link
    fedilink
    English
    arrow-up
    1
    ·
    14 hours ago

    Is Haskell the language that differentiates between pure and impure functions? I’ve never seen a single line of Haskell, but I watched a number of YouTube videos and I agree that experts explaining the language is eminently helpful to understand functional programming in general.

    • solrize@lemmy.world
      link
      fedilink
      arrow-up
      8
      ·
      13 hours ago

      Haskell doesn’t have impure functions. What you’re calling impure functions (functions that produce values in the notorious I/O monad) are actually pure functions, that produce what you could think of as programs that run in an impure interpreter that’s outside of Haskell itself. Don’t worry about understanding that in detail until you’re deeper into learning Haskell, but at that point it will help demystify what the I/O monad (a traditional stumbling block) actually is.

      The first few pages of learnyouahaskell.com will give you some sample code to show how clean the language can be.