Hacker News new | ask | show | jobs
by mrkeen 34 days ago
Sometimes you go back and reinvent the stack (breaking everyone's code) and other times you introduce things non-breakingly.

> why isn't a Haskell monoid defined as an extension of a semigroup

  class Semigroup a => Monoid a where 
  [https://hackage-content.haskell.org/package/base-4.22.0.0/docs/Data-Monoid.html]
> If functors are as basic and fundamental as they seem, why do they get an awkward "fmap" - with most standard types re-exporting it as plain "map"?

map was in the original 1990 Haskell spec [https://www.altocumulus.org/haskell-report-1.0.pdf]. Functors & fmap came later. I guess they went with a non-breaking feature introduction.

Other times they do a breaking change. Monads didn't used to need to be Applicative Functors. Now they do. [https://wiki.haskell.org/Functor-Applicative-Monad_Proposal]

Anyway, it could be worse. You could be working in a language that can't even express the functor/map interface.

1 comments

> class Semigroup a => Monoid

Yes, hence the "at least a few years ago". But perhaps I'm misremembering and confusing it with applicative functors, it has been a few years.

> I guess they went with a non-breaking feature introduction.

Sure, but functors aren't exactly novel, are they? Although it has contributed a lot to programming language design in general, Haskell didn't exactly invent the concept of a generic "map". So why wasn't it there in the first place, and why was it - despite its obvious prominence - not deemed important enough for a (what seems to be tiny) breaking change?

> Anyway, it could be worse. You could be working in a language that can't even express the functor/map interface.

Are those still around? I thought even Go eventually started supporting generics?

"Generics" doesn't cut it. Most languages just can't functor.

Go - no. https://www.reddit.com/r/golang/comments/v1ljep/monads_and_p...

Swift - no. https://forums.swift.org/t/higher-kinded-types-monads-functo...

Rust - no. https://www.reddit.com/r/rust/comments/152bgj0/current_state...

"Awkward fmap" and "random collection of category theory concepts thrown together in a weekend" is great compared to the alternatives.