← Back to Blog

F# Records

My previous post F# - Refactoring to Functional - Part 1 garnered some attention for my use of the struct data type.

Tobias Burger pointed me at the correct implementation of F# records for my data passing. He suggested using ordinary records as my data type instead of structs since they are a more idiomatic approach to F#. It's taken me a little while to get back to the code, but I modified my data types to be records. The code is below:


type Endpoint =
    { Name: string
      Url: string
      Body: string
      Verb: string }
	  
let endpoint =
    { Name = "Google Test"
      Url = "https://www.google.com"
      Body = ""
      Verb = "GET" }

I have to say "Thank you" to Tobias. His criticism helped me better understand F# records, and it made my code shorter and cleaner!

← Back to Blog