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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:27:12+00:00 2026-06-15T13:27:12+00:00

So I have some Haskell code in which I’d like to work with Data.Set

  • 0

So I have some Haskell code in which I’d like to work with Data.Set.
Basically because I didn’t look into alternatives much and need a structure to store elements of Ord without duplicates.

I’ve now come to a situation where I’d like to have something like mapM for Data.Set
so that I can perform monadic operations on a sets individual elements.
I already searched Hayoo for a type like (a -> m b) -> Set a -> m (Set b) but didn’t find anything useful.

I also looked into Data.Traversable just to find out that it has instances for [], Maybe and (Map k) but not for Set.

So my questions are:

  1. Why is there no mapM for Set in Data.Set?
  2. Is there already a package that delivers something like mapM that I missed?
  3. Is it discouraged to want to mapM over Sets? (why and what are alternatives?)
  • 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-15T13:27:13+00:00Added an answer on June 15, 2026 at 1:27 pm

    The main problem is that Traversable requires Functor, and sets cannot be functors since they require an Ord constraint while functors must be unconstrained.

    However, sets are foldable so if you don’t need to collect the results, you can use mapM_ from Data.Foldable.

    If you do need the results, you can go via lists, e.g.

    fromList <$> mapM f (toList s) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some Haskell code that does work correctly on an infinite list, but
This is probably another easy Haskell question. If I have some nested data types,
I have the following Haskell code import Data.Int import System.Environment type Coord = (Int16,
After a lot of Java and some Haskell I wanted to have a look
I'm doing some homework and while I have some experience with SML, Haskell has
I have some data loaded as a np.ndarray and need to convert it to
I have some arbitrary pixel data that I want to save as a PNG.
I have some text lines like that : vt_wildshade2^508^508 vt_ailleurs2^1188^1188 ... vt_high2^13652^13652 Is it
I have some code on two systems running kernel 2.4.20 and kernel 2.4.38 .
I have some tables roughly like so: Client: id name Employee id name Email

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.