I understand that this can potentially be considered as a subjective or, perhaps, an off-topic question, so I hope that instead of closing it, it will be transferred, possibly to programmers.
I am starting to learn Haskell, mainly for my own edification, and I like a lot of ideas and principles that support the language. I became fascinated by functional languages ββafter taking the language theory class where we played with Lisp, and I heard a lot of good things about how productive Haskell can be, so I decided that I would research it myself. So far I have liked this language, with the exception of one thing that I canβt just get away from: these signatures are functions of the mother operation.
My professional background mainly does OO, especially in Java. Most of the places I worked in have scored a lot of standard modern dogma; Agile, Clean Code, TDD, etc. After several years working this way, he definitely became my comfort zone; especially the idea that "good" code should be self-documenting. I'm used to working in an IDE where long and verbose method names with very descriptive signatures are not an issue with smart auto-completion and a huge set of analytic tools for navigating packages and characters; if I can press Ctrl + Space in Eclipse, then output what the method does by looking at its name and the locally restricted variables associated with its arguments, instead of raising JavaDocs, I am as happy as a pig in the feed.
This, of course, is not part of the Haskell community best practices. I read a lot of different opinions on this issue, and I understand that the Haskell community considers its conciseness "pro." I went through How to read Haskell , and I understand the rationale for many decisions, but that does not mean that I like them; variable names in one letter, etc., I'm not interested. I admit that I will have to get used to this if I want to continue to crack my tongue.
But I can not get function labels. Take this example, as pulled from the Learn about the Haskell section [...] about function syntax:
bmiTell :: (RealFloat a) => a -> a -> String bmiTell weight height | weight / height ^ 2 <= 18.5 = "You're underweight, you emo, you!" | weight / height ^ 2 <= 25.0 = "You're supposedly normal. Pffft, I bet you're ugly!" | weight / height ^ 2 <= 30.0 = "You're fat! Lose some weight, fatty!" | otherwise = "You're a whale, congratulations!"
I understand that this is a stupid example that was created only to explain the guards and class restrictions, but if you only looked at the signature of this function, you would not understand which of its arguments were intended to be weight or height. Even if you used Float or Double instead of any type, it still would not be immediately distinguishable.
At first, I thought I would be cute, smart, and brilliant, and try to fake it using longer variable type names with a few class restrictions:
bmiTell :: (RealFloat weight, RealFloat height) => weight -> height -> String
This spat out an error (aside, if anyone could explain the error to me, I would be grateful):
Could not deduce (height ~ weight) from the context (RealFloat weight, RealFloat height) bound by the type signature for bmiTell :: (RealFloat weight, RealFloat height) => weight -> height -> String at example.hs:(25,1)-(27,27) `height' is a rigid type variable bound by the type signature for bmiTell :: (RealFloat weight, RealFloat height) => weight -> height -> String at example.hs:25:1 `weight' is a rigid type variable bound by the type signature for bmiTell :: (RealFloat weight, RealFloat height) => weight -> height -> String at example.hs:25:1 In the first argument of `(^)', namely `height' In the second argument of `(/)', namely `height ^ 2' In the first argument of `(<=)', namely `weight / height ^ 2'
Not fully understanding why this did not work, I started Googling and I even found this little post that offers named parameters, in particular spoofing named parameters via newtype , but that seems a bit big.
Is there an acceptable way to handle signatures of information functions? Is "Haskell's Way" just to get the shit out of everything?