8 ms·
> You might later find that something that took you 5 lines is a standard abstraction ready to be re-used. Such a great point and perhaps one of the biggest ch
by thoradam 10y ago
> You might later find that something that took you 5 lines is a standard abstraction ready to be re-used.
Such a great point and perhaps one of the biggest challenges as languages allow increasingly reusable and powerful abstractions. I would love to have GHC tell me something like "this piece of code here has a signature that is familiar, you could probably make this fit into {list of abstractions}".
- BellsOnSunday 10y agoThat doesn't seem like something a compiler should care about, I think it would be better to add it to something like hlint.
- asib 10y agoIf you're interested in a tool like that, check out Hoogle: https://www.haskell.org/hoogle/ https://www.haskell.org/hoogle/. It allows you to search by signature, including using generic types (e.g. their front page example is (a -> b) -> [a] -> [b], which will return map as a result, among others).
- runeks 10y agoSuch a tool exists. I've had hlint tell me many times how to do something in a better way. At some point I had it hooked into my IDE, so it would mark improvable code in yellow. Especially in the first year I learned a lot of new Haskell syntax and functions just from its suggestions.
- harveywi 10y agoIf you don't mind me asking, which IDE do you use?
- runeks 10y agoOh, yeah, I should have mentioned that: IntelliJ IDEA with the Haskforce plugin. The plugin isn't maintained any longer, though, so it's not the best solution, but it was perfect when both ghc-mod and hlint worked. ghc-mod still works, because I can't go back to coding without it, speeds everything up so much to have instant compiler feedback. For example, there is this fatal, unresolved bug that no one knows how to fix: https://github.com/carymrobbins/intellij-haskforce/issues/285 https://github.com/carymrobbins/intellij-haskforce/issues/28... EDIT: It's working again (for projects that do not exhibit above bug): http://i.imgur.com/jPo4Tas.png http://i.imgur.com/jPo4Tas.png
- avindroth 10y agoIntero is amazing for this.
- thesz 10y agoDjinn: https://hackage.haskell.org/package/djinn https://hackage.haskell.org/package/djinn Does more or less what you described.