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 6950241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:04:05+00:00 2026-05-27T14:04:05+00:00

I was messing around with HashMap and tried to use a Data.Bson.ObjectId as a

  • 0

I was messing around with HashMap and tried to use a Data.Bson.ObjectId as a key. I, of course, discovered that there is not a Hashable instance for that structure. That’s ok, because writing one is trivial.1

instance Hashable ObjectId where hash (Oid x y) = hash (x,y)

I typed that line into GHCi and was told “parse error on input `instance'”. This actually makes sense as the GHCi prompt operates as if the lines were being typed into a do block in the IO monad and an instance can not be defined in this context.

My question then, is there a way to define a new instance within GHCi?


1 Why this instance is not provided by the library is another matter. I would believe the answer was to limit dependencies except that the bson package already depends on everything under the sun.

  • 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-27T14:04:06+00:00Added an answer on May 27, 2026 at 2:04 pm

    The good news: Yes, there is a way to define a new instance within GHCi.

    The bad news: At the moment, the first step in doing so is “install a development snapshot of GHC”.

    This has been an obvious bit of missing functionality in GHCi for quite a while. There was no inherent reason for it to be absent, but I assume it was somewhat difficult to implement and so it got set aside.

    However, it seems that as of version 7.4.1, it’s now available:

    At the GHCi prompt you can also enter any top-level Haskell declaration, including data, type, newtype, class, instance, deriving, and foreign declarations. For example:

    Prelude> data T = A | B | C deriving (Eq, Ord, Show, Enum)
    Prelude> [A ..]
    [A,B,C]
    Prelude> :i T
    data T = A | B | C      -- Defined at <interactive>:2:6
    instance Enum T -- Defined at <interactive>:2:45
    instance Eq T -- Defined at <interactive>:2:30
    instance Ord T -- Defined at <interactive>:2:34
    instance Show T -- Defined at <interactive>:2:39
    

    Whether you think having that right now worth the hassle of installing a non-release version of GHC is up to you.

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

Sidebar

Related Questions

When messing around with Haskell using GHC, I can use various meta-commands like :i
I was just messing around with templates, when I tried to do this: template<typename
I was messing around with JavaScript, and noticed that this can never be a
Just messing around with Rails 3.1, which separates stylesheets via controllers. I'm assuming there
I'm messing around with rails 2.3 templates and want to be able to use
I was messing around with LinqToSQL and LINQPad and I noticed that SingleOrDefault() doesn't
I've been messing around with javascriptmvc. After getting data from the model, the view
Was messing around with some array stuff earlier and discovered a very peculiar caveat
I just started messing around with the lastfm API and I'm not sure why
I've been messing around with Android development. I made a simple form that has

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.