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 Haskell I was used to have concise operators like not (x `elem`
Coming to Haskell from a background in various OO languages, one thing that seems
Coming from iOS I'm having a pretty hard time with web services in Android.
Coming from mootools and JAVA, mootools class implementation is a real nice way to
Coming from a Java background, I like it when I was warned that I
Coming from a javascript background, collections like dictionaries are often implemented as objects because
Coming from frameworks like Django and RoR I am used to show and handle
coming from .Net world, just want to know what is the corresponding collection to
Coming from .NET, I'm used to Ninject, that's a small simple ioc-container. Is there
Coming from Windows Forms (.net), I'm tempted to write the following code: JFrame frame

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.