7 ms·
Here's what I do, for example: import qualified Data.List as DL import qualified Data.Map.Strict as DMS and then in code, I use DL.foldl' or DMS.foldl' as
by js8 6y ago
Here's what I do, for example:
import qualified Data.List as DL
import qualified Data.Map.Strict as DMS
and then in code, I use DL.foldl' or DMS.foldl' as needed. Not sure if that answers your question, though. (I also use classy-prelude, it's the best IMHO.)
You can also create your own functions as synonyms, if you feel like, it's easy and compiler has no issue with that. I often do that for structures (defined with "type") that I use in a module, to increase legibility.
Finally, the record dot syntax is becoming accepted to Haskell, it might help in writing IDEs that suggest methods based on types. (Peyton Jones explained somewhere that it's one of the advantages of method syntax, that it helps to show available methods.)
- sheepfleece 6y agoWhile I know it is subjective, it is still my person pet-peeve. Abbreviations like DL and DMS are really hard to read and remember. What I would have used instead is List and Map.
- js8 6y agoThat's fine. I like to use these because they are visually distinct identifiers (and short), List and Map look like the type (class) names. I know it's a different namespace, but still..
- pwm 6y agohlint rules are nice for enforcing this, eg. you put sg. like this in your .hlint.yaml: - modules: - { name: [Data.List], as: List } - { name: [Data.Map, Data.Map.Strict], as: Map } and then you get a hlint warning if you use DL/DMS instead of List/Map
- 6gvONxR4sf7o 6y ago> You can also create your own functions as synonyms, if you feel like, it's easy and compiler has no issue with that. This is specifically what was trying to suggest. I wish folks would do more of it. Write the synonym for your function and then a brief docstring about what it means for this specific case. All the generic tooling means that writing your getter or whatever might be simpler than it is in another language, but it's still worth writing. Even when it's just a synonym.