5 ms·
Serious question. In the following code, what would be better function / type names? (or you can pick another bit of Haskell code that you know and/or have part
by wereHamster 9y ago
Serious question. In the following code, what would be better function / type names? (or you can pick another bit of Haskell code that you know and/or have particular trouble understanding).
class Foldable t where
foldl :: (b -> a -> b) -> b -> t a -> b
- nv-vn 9y agoI've always disliked mapM_. Something about it just looks ugly and it doesn't really hint what its for. I would like to see mapM as mapMonad and mapM_ as eachMonad. Of course, once I knew what it meant the abbreviations became rather nice.
- deleted 9y ago[deleted]
- nimih 9y agoMaybe something like: class Foldable myFoldable where foldl :: (summary -> element -> summary) -> summary -> myFoldable element -> summary This is the translation I do in my head when I read that type signature, at least.
- bjl 9y agoReally? I find the single-letter version far easier to read.
- imh 9y agoThe single letter version is far easier since I already know what foldable does. Not so much when I'm learning a new library.
- cauterize 9y agoI wonder if anyone has worked on a Prelude replacement which has these replacements (along with renaming functions where appropriate)...
- wereHamster 9y agoTo change the names you'd have to re-implement all the functions. Good luck with that, base is /large/. This is a documentation issue, not an implementation issue.
- ashark 9y agoWow. That's much better. Apparently-idiomatic Haskell reads (or, rather, doesn't) about like line-noise/code-golf style Perl to me.
- jinfiesto 9y agoThe problem with this is that there are Foldables that do not behave in the way that is implied by the above re-write of the parameters. I think this is kind of the problem when you are really high up in abstraction-land. The functions that you're using are so generic that it's hard to say that they operate on anything in particular, except that the arguments fulfill certain properties or laws.