Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6837877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:31:45+00:00 2026-05-26T23:31:45+00:00

I have a installed module with data type Card. I make it instance of

  • 0

I have a installed module with data type Card. I make it instance of class Show but something go wrong in the ghci:

 module Poker where

 data Card = Card Int 

 ...

 instance Show Card where
 show card = ...

 ...

I open the ghci and type:

>:m + Poker
>Card 0
..
..
..
(Nothing) => I stop the execution
>Poker.show (Card 0)
> "Ace of Hearts"

It seem that my data type is not an instance of the class Show, why?


Thanks all! It works! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:31:46+00:00Added an answer on May 26, 2026 at 11:31 pm

    Indentation matters. The body of an instance declaration needs to be indented, otherwise it interprets your definition of show as just another top-level function, which is why Poker.show works.

    instance Show Card where
        show card = ...
    

    The general indentation rule in Haskell is that if two consecutive lines are indented the same, they are two distinct definitions, whereas if a line is more indented than the one before it, it is considered to be part of the preceding definition or expression, which is what you want in this case.

    The reason why this causes an infinite loop, is that since you didn’t provide an implementation of show in the type class, it uses the default implementation which indirectly calls showsPrec. Since you didn’t provide that one either, it uses the default implementation which calls show. Thus, you get an infinite loop. Several type classes have default implementations implemented in terms of each other like that, so that you only have to implement a subset of them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Python module installed on my system and I'd like to be
I have just installed the ACL and Content Access module. Imedietly after enabling them
I have installed Sphinx in order to document some Python modules and class I'm
I have installed RDFlib 3.0 and everything that is needed, but when I run
We have a server application that has one module installed on a separate server,
I have a python module which generates large data files which I want to
I have compiled and installed python 2.7 on my ubuntu lucid. But I am
I have a custom module in Drupal that outputs a serialized dump of data.
I have a module that sits in a namespace. Should tests and data the
I have a multi-module maven project with an installer sub-project. The installer will be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.