Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,239
    • Issues 5,239
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 566
    • Merge requests 566
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #12688
Closed
Open
Issue created Oct 11, 2016 by daviddarais@trac-daviddarais

derived Show instances aren't protected from RebindableSyntax+OverloadedStrings

When using both RebindableSyntax and OverloadedStrings, deriving (Show) no longer works.

Example program:

{-# LANGUAGE RebindableSyntax, OverloadedStrings #-}

module Bug where

import Prelude (String,Show(..))

newtype Text = Text String

fromString :: String -> Text
fromString = Text

x :: Text
x = "x"

newtype Foo = Foo ()
  deriving (Show)

In this example, fromString is redefined to return a type different from [Char]. The example x typechecks due to to the RebindableSyntax and OverloadedStrings extensions. However, the generated code for the deriving (Show) instance for Foo does not typecheck, and ghc gives a code generation error:

error:
    • Couldn't match type ‘Text’ with ‘[GHC.Types.Char]’
      Expected type: String
        Actual type: Text
    • In the first argument of ‘GHC.Show.showString’, namely ‘"Foo "’
      In the first argument of ‘(GHC.Base..)’, namely
        ‘(GHC.Show.showString "Foo ")’
      In the second argument of ‘GHC.Show.showParen’, namely
        ‘((GHC.Base..) (GHC.Show.showString "Foo ") (showsPrec 11 b1))’
      When typechecking the code for ‘showsPrec’
        in a derived instance for ‘Show Foo’:
        To see the code I am typechecking, use -ddump-deriv

A solution would be to protect the code generated by deriving (Show) from OverloadedStrings and RebindableSyntax extensions.

Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking