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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:18:12+00:00 2026-05-25T12:18:12+00:00

I want to access type variables in an instance, that don’t show up in

  • 0

I want to access type variables in an instance, that don’t show up in the instance’s parameters. For example,

class A a where foo :: a b
data C a
instance A C where
    foo :: forall b. C b
    foo = undefined :: C b

Of course, the above will resolve without the scoped type expression, but I have a non-toy example where I actually want it.

edit

please try your code before pasting it as an answer! The above (Daniel’s answer) results in

Test.hs:51:5: Misplaced type signature: foo :: forall b. C b
Failed, modules loaded: none.
  • 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-25T12:18:12+00:00Added an answer on May 25, 2026 at 12:18 pm

    I think to overcome the problem with Daniel’s solution that you are not allowed to provide a signature for a type class function you can simply define a top-level function and “rename” it in the instance of the type class. In your simple example the following should work.

    {-# LANGUAGE ScopedTypeVariables #-}
    
    class A a where 
        foo :: a b
    
    instance A C where
        foo = foo'
    
    foo' :: C b
    foo' = undefined :: C b
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I want to access the value in an XML feed: <entry> <ilink:operation>store</ilink:operation> <ilink:type>ondemand</ilink:type>
I have od of type OrderedDict . I want to access its most recently
I want to have possibility to access action by the following URL type: http://localhost/MyControllerName/MyActionName/Id1+Id2+Id3+Id4
I want to give access to protected properties to another class. I have been
I want to syncronize threads to access a common variable. Imagine that I have
this is a best practices type of question. I want to access the attributes
I have an interface based class that I want to have a few static
I want to access the call stack at runtime in a Native C++ application.
I want to access a UIImage programmatically... i.e. myImage.hidden = TRUE; etc. I can
I want to access my sql server database files in a INTEL SS4000-E storage.

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.