Skip to content

Instantly share code, notes, and snippets.

@JustinChristensen
Last active April 5, 2021 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JustinChristensen/cdc37922ecb6eb7d385acab527fd367c to your computer and use it in GitHub Desktop.
Save JustinChristensen/cdc37922ecb6eb7d385acab527fd367c to your computer and use it in GitHub Desktop.
-- 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