5 ms·
this is like 90% `data` and `case`. show me a language where type declaration and case statements aren't readable.
by ice109 9y ago
this is like 90% `data` and `case`. show me a language where type declaration and case statements aren't readable.
- tome 9y ago> this is like 90% `data` and `case` Welcome to the world of Haskell! Sum types aren't even available in C, C++, C#, Java, Python, Ruby, JavaScript, ..., so I think you're just proving my point for me.
- ice109 9y agono i'm not. you cherry picked. tell me how readable this module is https://github.com/databrary/databrary/blob/master/Databrary/Controller/CSV.hs https://github.com/databrary/databrary/blob/master/Databrary... with gems like https://github.com/databrary/databrary/blob/master/Databrary/Controller/CSV.hs#L60 https://github.com/databrary/databrary/blob/master/Databrary... and https://github.com/databrary/databrary/blob/master/Databrary/Controller/CSV.hs#L101 https://github.com/databrary/databrary/blob/master/Databrary... and https://github.com/databrary/databrary/blob/master/Databrary/Store/Zip.hs https://github.com/databrary/databrary/blob/master/Databrary... and https://github.com/databrary/databrary/blob/master/Databrary/Ingest/JSON.hs#L103 https://github.com/databrary/databrary/blob/master/Databrary...
- dllthomas 9y agoYou can write unreadable code in any language. "Look, here's some unreadable code in your language" doesn't tell us much of anything. That said... looking at your first example, it's really not that bad. It could probably be rewritten to be quite a bit clearer, but even knowing nothing about the library or surrounding context, it doesn't take me that much thinking to work out what's going on: We have a dictionary implemented as a sorted list of pairs, and a list of records we want to update that dictionary with (after some transformation). If there are no records, we give back the dictionary unmodified. If there is no dictionary, we build one out of the records. If there is both a dictionary and a bunch of records, we do a recursive merge of the two - compare the heads of each list, cons the smaller on the result of the appropriate recursive call.
- tome 9y ago> you cherry picked That's exactly what I was asked to do!
- tome 9y agoFor posterity, here's some very readable Haskell that has less data and case: https://hackage.haskell.org/package/turtle-1.3.6/docs/src/Turtle-Prelude.html https://hackage.haskell.org/package/turtle-1.3.6/docs/src/Tu...