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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:11:52+00:00 2026-06-18T07:11:52+00:00

I have tried map show . mapMaybe fromDynamic $ [toDyn one, toDyn (\x ->

  • 0

I have tried

map show . mapMaybe fromDynamic $ [toDyn "one", toDyn (\x -> x::Integer), toDyn 3, toDyn ()]

but it returned

["()"]
  • 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-18T07:11:53+00:00Added an answer on June 18, 2026 at 7:11 am

    Your code does not do what you expect it to do. Long before the dynamic behaviour of Data.Dynamic kicks in, the Haskell type checker resolves the types. The type of the right part of the expression is

    mapMaybe fromDynamic $ [toDyn "one", toDyn (\x -> x::Integer), toDyn 3, toDyn ()] :: Typeable b => [b]
    

    and the type of the left part is

    map show :: Show a => [a] -> [String]
    

    so to combine these, the type variable b resp. a gets unified. If you were to compile this from a regular Haskell file, the compiler would give you a warning (The type variable `a' is ambigous). But in GHCi, the interpreter just defaults to ().

    But this fixes the type of fromDynamic in the expression to Dynamic -> Maybe (), effectively selecting all elements of type ().

    If you force the compiler to use a different type there, e.g. by specifying a type signature, you see that fromDynamic selects a different type:

    Prelude Data.Dynamic Data.Maybe> map (show :: Integer -> String) . mapMaybe fromDynamic $ [toDyn "one", toDyn (\x -> x::Integer), toDyn 3, toDyn ()]
    ["3"]
    

    Unfortunately, there is no way to achieve what you want: Select all elements whose type support a show instance, as that information is not available to fromDynamic.

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

Sidebar

Related Questions

I am trying to map a drive using a batch file. I have tried:
I have tried searching over the internet about this problem but not able to
I have tried many permutations but they all don't seems to work well. Am
I have tried following many tutorials on here and on Google, but it seems
I am stuck with a problem. I have tried a lot options but could
I am trying to implement map function in VB.NET and I have tried the
Have tried to find solutions for this and can't really come up with anything.
I have tried to go through the jungle (really, PayPal, why don't you weed
I have tried this: #define format(f, ...) \ int size = strlen(f) + (sizeof((int[]){__VA_ARGS__})/sizeof(int))
I have tried a variety of different solutions found on stack and other places

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.