Fair enough - what did I miss in my (nasty) bit of code? Doesn't it expose exactly the fact that global uniqueness is not guaranteed by ghc? Who's got the bigger type class implementation is another debate entirely and not at all the point I was making, sorry if it was unclear
-
-
The argument is practical Write Haskell; never use orphan instances. This is achievable with little/no penalty Write Scala; never use orphan instances. With this commitment, it's difficult & there's no sweet spot Scala does not have type-classes in any general practical sense
2 replies 0 retweets 0 likes -
That is entirely besides the point though. My point is: GHC doesn't enforce global instance uniqueness. This is demonstrably true, but exhibiting a program in which global instance uniquess is violated. Whether or not it's easy to avoid is another discussion
2 replies 0 retweets 1 like -
Whether or not it's easy to avoid is the *practical* discussion. GHC doesn't enforce it; Haskell does. Neither of these are particularly interesting to me, but I thought we were talking about practical application.
1 reply 0 retweets 0 likes -
But it's impossible to avoid if you use GHC and have external dependencies though, right? Isn't that practical?
2 replies 0 retweets 0 likes -
Replying to @NicolasRinaudo @dibblego and
Sorry - it's impossible to guarantee, not to avoid. I do not need to be convinced that it doesn't happen often in practice, my point is just that you can't guarantee it, just observe it.
1 reply 0 retweets 0 likes -
If a Haskell library implements orphan instances, I typically put it in the "not useful" basket and get on with it. This is a satisfactory optimisation. If a Scala library does it, and it is increasingly the case, I roll me eyes, get over it and accept all the penalties.
1 reply 0 retweets 0 likes -
This assumes that you have access to the code and are willing to audit it. If the instances aren't exposed explicitly but do nasty things like my ins and ins' example, you won't observe the problem until runtime, when your code does impossible things.
2 replies 0 retweets 0 likes -
Nah the compiler will tell me immediately.
1 reply 0 retweets 0 likes -
Wait - this is news to me. The compiler can audit binary dependencies and tell you that it uses multiple instances of a given type class for a given type? I was not aware of this.
1 reply 0 retweets 0 likes
I mean when compiling from source. The compile says something like this: "orphan instance: you probably want to forget this code exists"
-
-
Right. But if you have binary dependencies (I'm assuming this is a thing although to be honest I wouldn't know how to do it), then by definition the compiler can't help you - it won't have code to compile.
0 replies 0 retweets 0 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.