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

  • Home
  • SEARCH
  • 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 3855594
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:48:00+00:00 2026-05-19T17:48:00+00:00

Consider next declaration: :- type wrap(T) —> wrap(T). :- inst wrap(I) —> wrap(I). :-

  • 0

Consider next declaration:

:- type wrap(T) ---> wrap(T).
:- inst wrap(I) ---> wrap(I).

:- typeclass infer_wrap(A, B) <= ((A -> B)).
:- instance infer_wrap(A, wrap(A)).

Mercury (10.04) produces:

monad.m:011: In instance declaration for `monad.infer_wrap(A, monad.wrap(A))':
monad.m:011:   the first arg is a type variable

Even without functional dependency it will not allow to declare instance with type variables.
Am I missing something or Mercury doesn’t allow instances which doesn’t end with ground instance?
Is there any way to declare instance for polymorphic type which is wrapper for any type (without constraints)? Maybe there exists some special typeclass like all_types(T)?

  • 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-19T17:48:01+00:00Added an answer on May 19, 2026 at 5:48 pm

    Short answer:

    Mercury doesn’t support type variables in instance declarations. (which is what the compiler is complaining about).

    Long answer:

    There is no way create such a typeclass instance. Since the typeclass will be valid for all values of A maybe you don’t need a typeclass at all. But it looks like you’re trying to create Monads, currently this is impossible and we have no plans to support it in the immediate future

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

Sidebar

Related Questions

Consider the next example. I have a monad MyM that is just a StateT
Consider the following example program: next :: Int -> Int next i | 0
Over the next few months, we need to consider the best technology/technique for periodically
Consider the below 2 declarations. * appears next to the datatype and not next
Consider the next example: >>> s = uбаба >>> s u'\xe1\xe0\xe1\xe0' >>> print s
Consider number 194 declared as type int Is it possible to obtain it's digits
Consider unit testing a dictionary object. The first unit tests you might write are
consider the following code:- struct mystruct { int data; struct mystruct *next; }; void
Consider the following code that automates generation of Boost.MPL type sequences (list or vector).
Lets consider next scenario: assume I have a web app, and authentication of users

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.