-
Notifications
You must be signed in to change notification settings - Fork 7
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
Requiring Show1 for Show, Eq1 for Eq, etc., is inconvenient #4
Comments
I’m pretty sure we can’t do this with class Apply (c :: (* -> *) -> Constraint) (fs :: [* -> *]) where
apply :: (forall g . c g => g a -> b) -> Sum fs a -> b |
We could maybe use another typeclass as a trampoline? class Up1 (c :: * -> Constraint) f where
up1 :: c a => (forall g . c (g a) => g a -> b) -> f a -> b
instance (Apply (Up1 Show) fs, Show a) => Show (Sum fs a) where
showsPrec d = apply @(Up1 Show) (up1 @Show (showsPrec d)) That’s kind of a way of simulating quantified class constraints, I suppose. Specifically, we’re simulating this:
and this works out fine because we actually don’t have to prove that for all Worth a shot I suppose. |
That much works, but the problem appears to be that we can’t actually define an instance of instance Up1 c f where
up1 f g = f g won’t typecheck because it can’t prove |
Maybe just wait for quantified constraints? |
@ocharles: I think quantified constraints will help, but not solve the problem completely—we’ll still need to define an |
Once upon a time,
fastsum
had separateApply
andApply1
typeclasses s.t. we could useApply
forShow
andApply1
forFunctor
. We eventually got rid of the former because compile times were already far too high, and instead usedShow1
to provide ourShow
instance.However, while it’s easy to derive
Show
instances,Show1
is not derivable, so you have to do a bunch of extra work just to show yourSum
s.The text was updated successfully, but these errors were encountered: