Share via

Discriminated union with list of named fields in tuple

0-gravity 1 Reputation point
2021-04-27T21:12:23.187+00:00

Hi,

In C# I can create a list of tuples with named fields, such as:
new List<(Guid stageId, Guid formId)>()

Is it possible in F# to declare a Discriminated Union with list of tuples with named fields, for example:
type Assignment = Assignment of ((stageId: Guid, formId: Guid) list)* (payload: string)

Developer technologies | .NET | F#
Developer technologies | .NET | F#

A strongly typed, multi-paradigm programming language developed by the F# Software Foundation, Microsoft, and open contributors.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Max Anderson 0 Reputation points
    2026-02-12T20:28:38.37+00:00

    Yes, your syntax is valid in F#, but the idiomatic and safer print approach is to define a record type instead of relying on named tuples inside a discriminated union.

    type Assignment =

    { Items   : StageForm list
    
      Payload : string }
    

    That’s typically the most F#-idiomatic solution.

    0 comments No comments

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. Billy Anderson 1 Reputation point
    2022-01-19T03:48:21.583+00:00

    Hey VPL

    Thanks for your concern but we do not understand your question about F#.. Can you please more clear about your question.

    Regards
    Billy RP

    0 comments No comments

  4. Vancouver Photo Lab 1 Reputation point
    2021-11-16T23:16:57.79+00:00

    We tried with F# to declare but its not possible.

    Thanks
    VPL

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.