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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:10:01+00:00 2026-06-03T17:10:01+00:00

Given i have the type: type NewsMessage(identifier:string, headline:string) and this record: type NewsMessageParams =

  • 0

Given i have the type:

type NewsMessage(identifier:string, headline:string)

and this record:

type NewsMessageParams = { 
    identifier:string
    headline:string 
}

Is there an implicit way to adapt the record into the class constructor?

Something like so:

let newsMessageParmas = {identifier=""; headline=""}
new NewsMessage(newsMessageParams) //this is where i need help

You can do this with tuples using the ||> syntax. I would like to do this with a record.

  • 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-03T17:10:02+00:00Added an answer on June 3, 2026 at 5:10 pm

    Something like this would work:

    let toClass {identifier = i; headline = h} = NewsMessage(i, h)
    
    // Usage
    let newsMessageParams = {identifier = ""; headline = ""}
    let newsMessage = newsMessageParams |> toClass
    

    Note that object constructor isn’t first-class in F#, so you have more chances of using pipe operators if declaring NewsMessage as discriminated unions:

    type NewsMessage = NewsMessage of string * string
    let toTuple {identifier = i; headline = h} = i, h
    
    let newsMessageParams = {identifier = ""; headline = ""}
    let newsMessage = newsMessageParams |> toTuple |> NewsMessage
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, given that I have some type of data structure like this within a
I have read the documentation that states that "given the type of the enum,
Given I have a long phrase, say, in line :12 , as this example:
Given i have the IO function: // this can either be IO or some
Given this example: abstract class Base { type Value } case object Foo extends
This seems to be quite a common theme and a few people have given
Scala doesn't have type-safe enum s like Java has. Given a set of related
I have an application in PHP that is a simplified MVC type structure. This
I have given a tree like this: http://www.seqan.de/dddoc/html/streePreorder.png http://www.seqan.de/dddoc/html/streePreorder.png i can acces each node
Given I have code like the following: void foo() { String str = hello;

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.