• squaresinger@lemmy.world
    link
    fedilink
    arrow-up
    51
    arrow-down
    1
    ·
    3 days ago

    Why do programs written in Haskell not have side effects?

    To have side effects someone would have to run the programs.

    • ultimate_worrier@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      8 hours ago

      Of course, they have side effects. Side effects are what the computation does. Otherwise, they would simply make the box hot.

      The difference between Haskell and most languages is that Haskell forces one to keep that impurity at the outer edges. It enforces that constantly, making programs easier to reason about.

      I heard it explained succinctly lately: types are all of the possible inputs and outputs of a program while functions encapsulate the mutation. Excel, for example, is a purely functional language.

      • squaresinger@lemmy.world
        link
        fedilink
        arrow-up
        5
        arrow-down
        3
        ·
        2 days ago

        Yeah, there’s like two projects that use Haskell. Doesn’t change the fact that it’s the language that most people know and will never write anything productive in it.