Last active
April 5, 2021 05:22
-
-
Save JustinChristensen/cdc37922ecb6eb7d385acab527fd367c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- this works | |
λ: data Foo t a = Foo (t a) | |
λ: :set -XStandaloneDeriving | |
λ: deriving instance (Show (t a), Show a) => Show (Foo t a) | |
λ: Foo ["test"] | |
Foo ["test"] | |
-- but this doesn't | |
λ: data Bar a = Bar a deriving Show; data Foo t a = Foo (t (Bar a)) | |
λ: deriving instance (Show (t a), Show a) => Show (Foo t a) | |
<interactive>:15:1: error: | |
• Could not deduce (Show (t (Bar a))) | |
arising from a use of ‘showsPrec’ | |
from the context: (Show (t a), Show a) | |
bound by the instance declaration at <interactive>:15:1-56 | |
• In the second argument of ‘(.)’, namely ‘(showsPrec 11 b1)’ | |
In the second argument of ‘showParen’, namely | |
‘((.) (showString "Foo ") (showsPrec 11 b1))’ | |
In the expression: | |
showParen (a >= 11) ((.) (showString "Foo ") (showsPrec 11 b1)) | |
When typechecking the code for ‘showsPrec’ | |
in a derived instance for ‘Show (Foo t a)’: | |
To see the code I am typechecking, use -ddump-deriv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment