In this episode, Matti and Wouter are joined by John Hughes. John is one of the authors of the original Haskell Report and talks about why functional programming matters, the origins of QuickCheck testing, and how higher order functions and lazy evaluation is the key that makes functional programming so productive, and so much fun!

  • jaror@kbin.socialOP
    link
    fedilink
    arrow-up
    0
    ·
    11 months ago

    I’m not suggesting you should never explain type classes. I simply want to avoid having to explain type classes before I can explain how to add two integers. And more importantly, I don’t want error messages to mention type classes until they have been understood.

    • Boyd Stephen Smith Jr.@hachyderm.io
      link
      fedilink
      arrow-up
      0
      ·
      11 months ago

      @jaror @dpwiz@qoto.org I think without the type of polymorphism that Haskell uses type classes for, the language can never be more than a toy.

      But, that doesn’t mean it can’t be didactically useful. A “Haskell–” with a JS-style Number for all numeric literals and replacing all numeric type classes with top-level operators on that type could be useful, for a bit.

      Once you want to do indexing (e.g. Array) you need to distinguish between numbers like sqrt 5 and suitable indexes, tho. Enter polymorphism

      • jaror@kbin.socialOP
        link
        fedilink
        arrow-up
        0
        ·
        11 months ago

        There are so many options to work around type classes. As you say, we could be looser with our types and have one general number type that includes integers and floats. (And I don’t even think array indexing is much of a problem, it could just throw an error or automatically round to an integer.)

        Another option is to just have separate number types with separate functions for addition and multiplication etc. For example OCaml has + and +..

        Perhaps more of a stepping stone towards full type classes would be a limited system where only a few pre-defined classes and instances exist. Then you’ll never run into the dreadful could not deduce Num (a -> b) error message, but you can still use a nice overloaded + for both Int and Double.

        • Boyd Stephen Smith Jr.@hachyderm.io
          link
          fedilink
          arrow-up
          0
          ·
          11 months ago

          @jaror @dpwiz@qoto.org Your first proposal is to sacrifice type safety. I reject that option; avoid success at all costs.

          Your second actually increases complexity through semantic bifurcation . I reject that as a way to make a simpler language, even for didactic purposes.

          No, discarding type classes without adopting something else worse (interface inheritance) is not easy, and may actually be impossible.

    • l'empathie mécanique@qoto.org
      link
      fedilink
      arrow-up
      0
      ·
      11 months ago

      @jaror @BoydStephenSmithJr Understandable… I’ve thought default rules made that possible.

      Anyway, I didn’t encounter much problems with type classes while teaching Haskell, not even as a first language. May all of my students were okay with some suspense 😅