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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:58:51+00:00 2026-05-25T11:58:51+00:00

Wonderful thing about Haskell. The type of a function almost dictates its implementation. That’s

  • 0

Wonderful thing about Haskell. The type of a function almost dictates its implementation. That’s the case for this one, but… my brain just isn’t wrapping around the nested function thing here:

mkDyn :: (Typeable a) => ((a -> IO()) -> IO ()) -> ((Dynamic -> IO()) -> IO ())

The only question is how to handle error handling in the fromDynamic call that will be required, but… I can deal with that once I have the rest figured out. I’m guessing there will need to be something like the following somewhere. But I can’t seem to get the wrapper lambda stuff figured out.

case fromDynamic x of
  Just x -> f x
  Nothing -> undefined -- TODO 
  • 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-25T11:58:52+00:00Added an answer on May 25, 2026 at 11:58 am

    I think you want toDyn, not fromDynamic. So let’s do this slowly:

    mkDyn :: Typeable a =>
             ((a -> IO ()) -> IO ())
          -> (Dynamic -> IO ())
          -> IO ()
    mkDyn k f = ...
    

    Our return type should be IO () and we can obtain that either by calling k or f. Calling f doesn’t help us much, because we would somehow materialise a Dynamic, but we cannot do that (sensibly) from k. So we want to call k. k needs another function as its argument, so lets start like this:

    mkDyn k f = k (\a -> ...)
    

    So the function’s argument is Typeable a => a -> IO (). We don’t have a function of that type, but we have a function of type Dynamic -> IO (). Because of the Typeable constraint we can use toDyn to turn our a into Dynamic and get:

    mkDyn k f = k (\a -> f (toDyn a))
    

    There are simpler implementations (e.g., return () or k (\a -> return ()), but this one appears to make sense.

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

Sidebar

Related Questions

Alright guys, well, here is the thing. I used this wonderful website and found
Exceptions are wonderful things, but I sometimes worry that I throw too many. Consider
Python has this wonderful way of handling string substitutions using dictionaries: >>> 'The %(site)s
I found a wonderful open source Java program that I'm translating into C#. The
I found this wonderful NSManagedObjectID. This would be very good for referencing an Entity/NSManagedObject/NSEntityDescription,
when writing small functions I often have the case that some parameters are given
I have, for example, markup like this <div id=content> <p>Here is some wonderful text,
I have heard wonderful things about Mustache and decided to give it a try.
Hello wonderful programmers of the world! Forgive me in advance if you feel this
So I found this wonderful library called WatiN - and I've downloaded the latest

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.