Types of types: Haskell's Kind system

(thunk.blog)

21 points | by Thom2503 3 days ago

3 comments

  • adamddev1 1 hour ago
    The more of Haskell's ideas that bleed into mainstream languages, the happier the world will become. It is just so beautiful how these higher abstractions can become so useful and powerful for tying all kinds of things together.
    • thomasfromcdnjs 1 hour ago
      I've been vibe coding my own language and it's compiler is in Haskell, it's been great for the agents to be inspired by Haskell and I'm having fun just adding random language features, currently implementing prophecy ghost variables. Not really a public project but can suss it out for now at http://lsalpha.com
      • bigmadshoe 33 minutes ago
        This is super cool! You should put a clear example implementation of a feed forward network, transformer block, loss function, or something more ML specific on the homepage, assuming you're primarily targeting that domain.

        EDIT: also the links to GitHub on https://lsalpha.com/systems are 404ing for me, so I exited your site without an example of what a real implementation might look like.

  • i2talics 1 hour ago
    I've long suspected that one of the things that makes monads notoriously difficult to explain to people outside of the Haskell ecosystem is that very few other languages even have a kind system that you are allowed to manipulate in code (and in some, like C++, it's so esoteric that you basically never see it). First explaining that you can even abstract over "type->type" kinded things gets you a lot of the way towards monads without actually describing monads.
    • taolson 4 minutes ago
      That may be true for functions which operate on a generic Monad typeclass, but typeclasses (Higher kinded types) aren't required to implement concrete Functor / Applicative / Monad instances for a particular type, e.g. Maybe:

          fmap f Nothing = Nothing
          fmap f (Just x) = Just (f x)
      
          pure x = Just x
      
          Nothing >>= f = Nothing
          Just x >>= f = f x
    • caaqil 30 minutes ago
      > things that makes monads notoriously difficult to explain to people outside of the Haskell ecosystem

      Huh, I thought a monad is just a monoid in the category of endofunctors, what's the problem?

      • girvo 27 minutes ago
        And here I was convinced that they’re burritos!

        I will say that explaining functors to my coworkers was always much simpler, and then naturally led to monads

    • epolanski 22 minutes ago
      The thing that makes monads difficult is laziness and the anti math circle jerk.

      You start from a functor which is a data type that admits a map operation.

      Then you add of, or pure, to make an applicative functor, and then you add flatmap to make a monad.

      • LoganDark 19 minutes ago
        > The thing that makes monads difficult is laziness and the anti math circle jerk.

        That's quite a hateful way to describe lack of knowledge.

        There are some prerequisites that make it easier to understand monads, and a lot of programmers don't even know those. That can make learning monads difficult right off the bat.

        • epolanski 4 minutes ago
          No there's no complexity behind monads except laziness and anti math circle jerk.

          It's really basic concepts, much easier than the analysis you do in high school.

          But people would rather sit through monad as boxes or burritos cringe tutorials.

  • antonvs 29 minutes ago
    > These are the constructs we manipulate in our programs, things like 1, 2, True, "hello", etc… In functional programming contexts, they're also called "terms."

    This is not correct. Terms are syntactic expressions in a program. For example, 1+2 is a term, but it’s not a value. At runtime, it evaluates to 3. As such, some terms correspond directly to values - like 1 - but other terms represent computations that will be performed at runtime.

    tl;dr: terms are a syntactic concept, values are a runtime concept. Terms evaluate to values.