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

  • Home
  • SEARCH
  • 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 7968149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:01:53+00:00 2026-06-04T07:01:53+00:00

I’m learning F# and finding I’m writing things that work but which I don’t

  • 0

I’m learning F# and finding I’m writing things that work but which I don’t entirely understand. Here’s an example

let processArgs args =
    match args with
    | null
    | [||]          -> [fun() -> getCredentials(); home 20; mentions 20; messages 20]
    | [|"-h"|] 
    | [|"-?"|]      -> [showHelp]
    | [|"-reset"|]  -> [clearAllSettings]
    | _             -> [fun() -> printfn "%s" (String.Join(" ", args))]

[<EntryPoint>]
    let main (args:string[]) =
    try
        let actions = processArgs args
        List.iter (fun action -> action()) actions
        0
    finally
        Console.ResetColor()
        Console.CursorVisible <- true

The methods getCredentials, home, mentions, messages, showHelp, and clearAllSettings are all simple functions and do what you expect. (Yes, it’s a twitter client, isn’t that the new ‘Hello World’ demo?)

The line:

[fun() -> getCredentials(); home 20; mentions 20; messages 20]

works like I want. It calls getCredentials, then home, then mentions, then messages

From my perspective, the semicolon is acting like a statement separator. I haven’t seen this described before. Is that what is going on here?

Is there a more idiomatic way of writing this (in other words, would a seasoned F# programmer roll on the floor laughing when he/she saw this)?

Further information: My original intent was to have a list of actions and then add actions as I discover options. In C# I would typically do this with List< Action >(). The semicolon thing surprised me because originally I tried to write it like:

[getCredentials; home 20; mentions 20; messages 20]

But the compiler didn’t like it.

  • 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-04T07:01:54+00:00Added an answer on June 4, 2026 at 7:01 am

    When you write:

    [fun() -> getCredentials(); home 20; mentions 20; messages 20]
    

    the compiler creates a list with only one element which is a function of type unit -> unit. S1 ; S2 is sequence composition when S1 has type of unit, and S1 and S2 are executed in order and S2’s result is returned. Therefore, three functions home, mentions and messages actually have the signature int -> unit.

    If you want to create a list of 4 different functions, it should be:

    [ getCredentials; // ; is optional
      fun () -> home 20; 
      fun () -> mentions 20; 
      fun () -> messages 20 ]
    

    These functions are separated by whitespace to avoid confusion of using ; as list delimiter and sequence composition.

    Since your example has all lists with only one elements, it could be simplified a lot:

    let processArgs = function
        | [||]          -> getCredentials(); home 20; mentions 20; messages 20
        | [|"-h"|] 
        | [|"-?"|]      -> showHelp()
        | [|"-reset"|]  -> clearAllSettings()
        | args          -> printfn "%s" (String.Join(" ", args))
    
    [<EntryPoint>]
    let main (args:string[]) =
      try
        processArgs args
        0
      finally
        Console.ResetColor()
        Console.CursorVisible <- true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a

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.