Hacker News new | ask | show | jobs
by logicrook 3816 days ago
Interestingly, your comment can be read both as a naive "did I understand your code example", but also as "look how horrible this syntax is, and how much it obfuscates the underlying thought-process". It tells a lot about Java as a language.
3 comments

Though the right comparison is

   default <T> Extension<T> contraMap(Function<T, S> f)
   foldMap :: Monoid m => (a -> m) -> t a -> m
I also prefer the Haskell syntax, but it looks like more of a difference because the implementation is inline.
To be fair, I afterwards thought that for some people, especially when taught with OOP, would see some functional abstractions as obfuscation. Each type of abstraction (objects, higher-order functions or continuations) work best with specifically designed syntax. I didn't like Scala too much for this reason, as it seemed a too bizarre combination (from a syntactic POV), as a contrast with Ocaml.

Anyway, tastes and education play a role there, but to me the arrow notation is way easier to read, as it is what I would write on paper.

I agree - I really had to deobfuscate / parse the signature first before even being able to start comprehending what it is about.

Not saying that there are no monster type signatures in Haskell (just recovering from one such instance in purescript-halogen), but it's really the most leightweight syntax for annotating types out there.

I often use Haskell signatures in comments when writing JS or whatever, just to keep the types straight.

It's just that OP quoted a multi-line function signature plus implementation in one line, which obfuscates things. Looking at just the comparable signature is pretty clear.

    <T> Extension<T> contraMap(Function<T, S> f);