Skip to content

‘show’ is not a (visible) method of class ‘Show’ #481

@ghost

Description

I think I am trying to do something relatively innocent, but relude is
not having it. Here is a minimal example.

My Cabal file:

cabal-version:    3.4
name:               dev
Version:            1.0
build-type:         Simple
author:             Henry Laxen
maintainer:         nadine.and.henry@pobox.com

library
  default-language:    GHC2024
  hs-source-dirs:      .
  build-depends:       base, relude
  exposed-modules:     Dev
  default-extensions:
  mixins:   base hiding (Prelude)
          , relude (Relude as Prelude)
          , relude

my Code:

module Dev where
import Prelude hiding (show)

newtype A = A Int

instance Show A where
  show (A x) = "A " <> show x

when i compile it, I get:

/home/henry/haskell/dev/Dev.hs:7:3-6: error: [GHC-54721] …
‘show’ is not a (visible) method of class ‘Show’

Compilation failed.

Now you may ask, why do I want this. Elsewhere I have a large data
type that contains

connection :: Network.WebSocket.Connection
I wanted to make a Show instance of this so I defined

newtype Conn = Conn Network.WebSocket.Connection

instance Show Conn where
  show _ = "Conn"

to wrap the Network.WebSocket.Connection
which led me to this problem

I did the same thing with plain Prelude (no relude mixin) and it worked as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions