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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:04:31+00:00 2026-05-25T00:04:31+00:00

Coming from Haskell, I’d like to know if there is a way to avoid

  • 0

Coming from Haskell, I’d like to know if there is a way to avoid having to write the full List.map every time I want to use a map.

Is there anything such as Java’s static imports, so that I can only write map?

To recap:

I currently have to write:

List.map (fun -> 3*x) [1..10]

yet, I’d like to be able to write

map (fun -> 3*x) [1..10]

Thanks

  • 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-25T00:04:32+00:00Added an answer on May 25, 2026 at 12:04 am

    In Java, given a class mypackage.MyClass you can “statically import” all static members within that class using the declaration import static mypackage.MyClass.*. In F#, given the module MyNamespace.MyModule you can similarly make all functions within that module available without qualification using the declaration open MyNamespace.MyModule. But as Daniel pointed out, certain module are marked with the RequireQualifiedAccess attribute which forbids this.

    However, you can still alias specific functions within a module similar to how you can statically import specific static members of a class in Java. For example, in Java, you can do something like static import mypackage.MyClass.myMethod and in F# you can do let map = List.map.

    Except, there is a good reason collection modules like List, Seq, and Array all require qualified access: they all have a similar set of functions which only act on their types and F# uses this information for its type inference. I’m not sure of the details but Haskell has some feature in its type system which allows map, for example, to be used on several different types without breaking type inference. Note that Seq is a bit special though in F# (and .NET), since it works on all types implementing the interface IEnumerable<'a> including lists and arrays. So you could alias let map = Seq.map and be able to work with map on all those collection types but you would lose features of those concrete implementations since IEnumerable<'a> is the lowest common denominator among them.

    So in the end, in F#, the best thing to do is just use the fully qualified map functions in each collection module. It’s a small price to pay for the type inference you get in return (I sometimes wonder if I save in typing through type inference what I lose having to qualify all those collection functions, but I believe you win in the end through type inference savings especially when considering complex generic signatures and perhaps more importantly having to reason through all those type calculations).

    One more option for saving key strokes is through module aliases. You can do something like module L = List. I wouldn’t do this for short, common module names like List, but I might do it for ResizeArray or perhaps my own sometimes long-winded module names.

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

Sidebar

Related Questions

Coming from TFS and using TeamCity in a customer project.... ...is there a way
Coming to Haskell from a background in various OO languages, one thing that seems
Coming from Win32, I am having bit of an issue or a problem trying
Coming from C# it was quite common for me to write a class that
coming from the Ocaml community, I'm trying to learn a bit of Haskell. The
Coming from C++ & MFC background, is there any better (maintainability/customization) platform in developing
Coming from IDEs with full-blown svn support such as Eclipse and Netbeans, I'm wondering
I'm relatively new to Haskell with main programming background coming from OO languages. I
Coming from a C/C++ background. What is the proper way to link a D
Coming from the ruby on rails world, I'm looking for an efficient way to

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.