-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add Maybe instance #102
Add Maybe instance #102
Conversation
I'm generally opposed to providing instances that distribute over containers. See #37 some discussion about tuples. In short, I don't think |
@tfausak makes sense. I thought about it a bit too, and weighed the pros / cons, and I agree that its not a straight forward win. I just figured there was only really one sensible implementation of Anyways, please feel free to close |
4f8a198
to
1cde6d9
Compare
Setting aside the question of if this is a desirable instance or not, I think it will trip up instance selection when ghci> :set -XTypeApplications
ghci> class From a b where from :: a -> b
ghci> instance From a a where from = id
ghci> instance From a b => From (Maybe a) (Maybe b) where from = fmap from
ghci> from @Int @Int 0
0
ghci> from @(Maybe Int) @(Maybe Int) Nothing
<interactive>:6:1: error: [GHC-43085]
• Overlapping instances for From (Maybe Int) (Maybe Int)
arising from a use of ‘from’
Matching instances:
instance [safe] From a a -- Defined at <interactive>:2:10
instance [safe] From a b => From (Maybe a) (Maybe b)
-- Defined at <interactive>:3:10
• In the expression: from @(Maybe Int) @(Maybe Int) Nothing
In an equation for ‘it’:
it = from @(Maybe Int) @(Maybe Int) Nothing |
Yeah, that makes sense. IMO |
Hmm well the tests passed, and there's a test for the identity instance: witch/source/test-suite/Main.hs Line 121 in f497644
So perhaps my minimal example was too minimal. The identity instance ( |
@tfausak I think its not triggering the error because there is no test for |
I have been convinced, and I think the |
No description provided.