Re:Functors and Monads for People Who Have Read Too Many “Tu...
by creata on Saturday June 26, 2021 @11:01AM
(#27642438)
The one-letter variables are all type parameters, and pretty much every programming language uses one-letter variables for type parameters. And I can't think of a better syntax for "functions from a to b" than (a → b). In a Java-ish syntax it'd look like:
interface Functor {
<T, U> Self<U> fmap(Self<T>, Function<T, U>);
}
which is just torture. What would it look like in your ideal syntax?
Re:Functors and Monads for People Who Have Read Too Many “Tu...
by one_comment on Saturday June 26, 2021 @12:13PM
(#27643099)
Give the types useful names, like everything else. Recently I did a review for a new peer and was pleasantly surprised that they used proper names for generic arguments. At first I stumbled of course, because I wasn't used to generic arguments being longer than a few characters but I think it helped the readability a lot.
interface Functor {
<Source, Target> Self<Target> fmap(Self<Source>, Function<Source, Target>);
}
Same code, but you get an additional hint of what's going on.
Re:Functors and Monads for People Who Have Read Too Many “Tu...
by creata on Saturday June 26, 2021 @12:16PM
(#27643143)
Alright, that's fine, but the person I replied to was complaining that "Haskell folks love arrows and one letter variable names", and my point was that most programmers love one letter variable names in this context.
Haskell folks love arrows and one letter variable names.
I don't know why, I guess it's the algebra background of most Haskell folks.
When I wrote some things in Haskell, I tried to use full words for function names and variable names, but it felt I am the only one. People just love to name stuff `a` `b` `m` `f` `k`