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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:56:17+00:00 2026-05-25T10:56:17+00:00

I tried the following: intType = typeOf (5::Int) stringType = typeOf s dynFunc ::

  • 0

I tried the following:

intType =  typeOf (5::Int)
stringType = typeOf "s"

dynFunc :: Dynamic -> IO ()
dynFunc d =
  case dynTypeRep d of
    stringType -> polyFunc ((fromDyn d "") :: String)
    intType -> polyFunc ((fromDyn d 0) :: Int)
    _      -> error "Could not coerce dynamic value"

But it warns of overlapping pattern matches and doesn’t work right. It always goes to first pattern instead of the correct one.

  • 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-25T10:56:18+00:00Added an answer on May 25, 2026 at 10:56 am

    The left hand sides of the -> in a case expression are patterns, not expressions. The pattern stringType will match anything and bind the local name stringType to it. It will not compare for equality.

    The compiler is telling you that your patterns intType and _ will never be reached; since the stringType pattern comes first and matches anything, its right hand side will always be chosen.

    As Claudiu suggested, you’ll want to use guards instead. Something like this should do the trick:

    dynFunc d | rep == stringType = ...
              | rep == intType    = ...
              | otherwise         = error ...
              where rep = dynTypeRep d
    

    If you have many possibilities, you might want to consider making a list and using the lookup function.

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

Sidebar

Related Questions

I tried following the answer to this question , but could not get xsd.exe
I tried the following code in LINQPad and got the results given below: List<string>
I tried the following command unsuccessfully sdiff <(ping www.nato.int) <(ping www.reuters.com) Is there any
I tried following code : #include<iostream> #include<string> using namespace std; string f1(string s) {
When I tried following code, it will just print empty string. How can I
I need TextBox which will reflect changes in databound string. I tried following code:
I've tried many configurations, but I keep getting the following error upon opening eclipse:
How would I create an EntityConnection string for an SqlServerCe database? I tried following
Tried following the instructions here: How to use Google app engine with my own
I tried following the README file in Ruby 1.9.1 but I can't compile it

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.