Hacker News new | ask | show | jobs
by eru 5972 days ago
So as a summary: In dynamic languages the compiler does not enforce the monad laws.

I add: They aren't enforced completely in Haskell, either.

(And you can't even express every monad in Haskell. E.g. you can't even make Set a functor in Haskell.)

1 comments

you can't even make Set a functor in Haskell

Well sure, because map on a set is only defined over functions that return values that can be compared for equality, whereas the generic functor map is defined over all functions.

Exactly. (However Data.Set is only defined for comparable values, i.e. the Ord typeclass, not Eq.)
That is an efficiency hack to make it O(n log n) instead of O(n^2) rather than an intrinsic property of sets, functors, or Haskell :)
Indeed. But Hindley-Milner [1] type systems have trouble expressing commutative stuff in general.

[1] I hope I got the names correct.