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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:28:22+00:00 2026-06-06T14:28:22+00:00

I have a function (in a module) that returns IO (Maybe a) where a

  • 0

I have a function (in a module) that returns IO (Maybe a) where a is an instance of the Serialize.

From my main Program I call this as follows:

 msg <- fun token
 print msg 

and get the error

Ambiguous type variable `a0' in the constraints:
      (Data.Serialize.Serialize a0) arising from a use of `foo'
                                    at test_00.hs:13:15-19
      (Show a0) arising from a use of `print' at test_00.hs:17:9-13
    Probable fix: add a type signature that fixes these type variable(s)

I know exactly what the problem is and I can fix it using -XScopedTypeVariables and some changes in how I call my library function as follows:

(msg :: Maybe String) <- cwPop token
print msg

However, I would rather like to avoid the ScopedTypeVariables and wonder where it is any way that I can test if msg is member of the show class and then print it. If not do something else .

  • 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-06-06T14:28:24+00:00Added an answer on June 6, 2026 at 2:28 pm

    You can give a type signature to the expression on the right hand side of the <- without extensions,

    msg <- fun token :: IO (Maybe String)
    print msg
    

    (I have made the indentation so that print and msg aren’t arguments to fun anymore, your indentation seemed to be broken).

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

Sidebar

Related Questions

I have a custom module that returns data from a web service call. It
I have a nodejs app, is there a module or a function that returns
I have a function in a module that looks something like this: module MyLibrary
i have created a module with this among others this function in it: <?php
I have a function in C++ that returns a vector<vector<double> > object. I have
I have a function like this function cp_module_ranks_getRank($uid){ return cp_module_ranks_pointsToRank(cp_getPoints($uid)); } It returns the
I have a module that has a function whose prototype is similar to that
Suppose I have a function f that takes a vector v and returns a
I have a function that returns Floats (or some other type). I am using
In F# i have the function: module ModuleName let X (y: int -> unit)

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.