-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove most instances #20
Comments
I find zero to be a relatively sane default and for the rare record type cases where it's not applicable, overriding the derived Doesn't the argument against |
@moll First just to clarify - are you a maintainer of this package or just throwing in your 2c? |
Not the maintainer. A mere user. |
Ah, gotcha. Well, to elaborate a bit, lawless type classes are already suspicious. The only benefit is reusing a symbol name. One example of a decent lawless type class is
A frustrating (and somewhat uncommon) occurrence is using
But there is a decent middle-ground: just have the type class exist on Hackage, as a public good, but let users define their own instances in their applications, since it's a useful name for a default blob of optional arguments. The danger of accidentally resolving to a /different/, /unintended/ default blob of optional arguments during a refactoring is low, but crucially, this relies on @ndmitchell since an old issue of yours was brought up, I would love to hear your thoughts on this :) |
To me a type class assigns a reusable name to a concept. Some concepts have laws, some have intuition, some have both. Of course, we'd like both, but I find those with only intuition better than those with only laws. I think the term "lawless typeclass" is banded about in Haskell like an insult, when "conceptless typeclass" should be the real insult. I think There is a standard problem with type classes that you might think of a specific behaviour and get a general one - very true. In fact, at previous $COMPANY I worked at we banned show, because people were doing show on Int to write an on-wire representation, then a refactoring made it a Maybe Int, and oh dear we have If you add I do think the dependencies of |
I would rather not have to learn any special cases about Conversely, it does not seem to make sense to remove Default from anything that is a Monoid, because whatever trouble a user can get into with |
That's exactly the idea - that Equipping a community type class with an instance is just such an important thing to get right in Haskell, every single one deserves much deliberation. Just today I was puzzling over why So back to the concept of "default" - it exists in many other languages, but is it actually a useful concept to attach to a type? I have a "verbose" flag, okay the correct default is The only time I've ever wanted to use the "default" concept is for large, cumbersome records of options, for power users to modify if they want, and actually writing the In Haskell, given we don't have row types nor optional arguments, this type class is one of the cleanest ways of passing a default options blob in a consistent and intuitive way. The problem is all of these pesky instances for simple (Btw, I know our experiences differ, since you said the very instances I want to eliminate are the ones you find most useful about this type class. I respect that, I'm just elaborating more on my point). |
My opinion probably shouldn't hold too much weight, but I don't really see the need to have a |
As of today, |
I have often needed |
(I’m a C# programmer in my day job so I feel qualified to chime in here.) C#’s To the extent that we can agree that |
To those who are saying they value |
@ocramz Another notable reverse dependency is diagrams, which relies on it for its |
I feel this discussion might benefit from concrete examples. Illustrations of how you folks have been using |
@duplode Sure, I can try, but I think the Github 👍 have spoken, this was just a bad take and I am happy to yield. My argument against To give a concrete example, consider some function like foo :: Int -> IO () Later, I refactor foo :: (Int -> IO ()) -> IO () and code that was prevously written as foo def will continue to compile and run, but I would rather have been forced to hunt down all uses of The exact same thing could happen using any polymorphic function like The difference between
The one use I find Using All that said, clearly there is disagreement, just because I don't see a good reason to use So since we only have the one type class, and we all have to share it and get along, perhaps it shouldn't be violently refactored unless everyone is in complete agreement that it'd be a good idea :) |
@duplode And to respond to your other comment, diagrams use of |
@mitchellwrosen Thanks. This comment dug up from an old r/haskell thread is similar in spirit, being about the surprises |
While I too find the function instance of |
I agree with @mitchellwrosen about relying on type classes - but I think it's more harmful for things like As an example of where I use I would be very happy if Haskell copied Rust, moved Default into the base library, and provided instances for everything. Then we could really know that def is always the default set of options. See https://doc.rust-lang.org/std/default/trait.Default.html |
I think this is the core issue for me, because I disagree with this sentiment. I want a trade-off. If it's likely that there is an error during refactoring, I want the compiler to tell me. If it's highly unlikely, I don't want the compiler to bother. I use To me, this is yet another tool in the toolbox, with some trade-offs. If I need to edit 500 places in the code anyways, because I have used specific initializers, I'll use (though #17 should be fixed for |
@mitchellwrosen, you may be interested in |
My opinion:
def
is a useful concept for blobs of optional parameters, configs, and perhaps other domain-specific things, but not for numeric types, lists, Maybe, etc.The situation today is, from my vantage point: either people avoid this type class entirely (e.g. google/proto-lens#194), or they use it with some caveats like, try not to abuse it.
I propose we try to correct this by making a major version bump to 2.0 and removing most instances. The only ones I believe belong are the derived tuple instances like
What do you think? Is this a feasible or wanted change? Thanks :)
The text was updated successfully, but these errors were encountered: