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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:51:37+00:00 2026-05-12T14:51:37+00:00

( Yes , still playing with units of measure ) I’ve just started using

  • 0

(Yes, still playing with units of measure)

I’ve just started using units of measure for something other than float for the first time.

After starting off complicated, I discovered that you can re-use units of measure across multiple ‘types’.

[<Measure>] type mm

let a = 1<mm>
let b = 1.<mm>

Now I’m sitting here wondering how to update my existing mm type to reflect this possibility:

[<Measure>]
type mm =
    static member perMetre = 1000.0<mm/m>
    static member fromMetre (v:float<m>) = v * mm.perMetre
    static member toMetre (v:float<mm>) = v / mm.perMetre
    static member lift (v:float) = v * 1.0<mm>

The question: How do I write a function that can convert from mm to m (say) that can handle int<mm> -> int<m> AND float<mm> -> float<m>?

UPDATE

Thanks to Kurt, here’s the new version:

[<Measure>]
type mm =
    static member private perMetreFloat = 1000.0<mm/m>
    static member private perMetreInt = 1000<mm/m>
    [<OverloadIDAttribute("float")>]
    static member fromMetre (v:float<m>) = v * mm.perMetreFloat
    [<OverloadIDAttribute("float")>]
    static member toMetre (v:float<mm>) = v / mm.perMetreFloat
    [<OverloadIDAttribute("float")>]
    static member lift (v:float) = v * 1.0<mm>
    [<OverloadIDAttribute("int")>]
    static member fromMetre (v:int<m>) = v * mm.perMetreInt
    [<OverloadIDAttribute("int")>]
    static member toMetre (v:int<mm>) = v / mm.perMetreInt
    [<OverloadIDAttribute("int")>]
    static member lift (v:int) = v * 1<mm>
  • 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-12T14:51:38+00:00Added an answer on May 12, 2026 at 2:51 pm

    Simply overloading works sometimes (if you have an argument):

    [<Measure>]
    type MM =
        static member perMetre = 1000.0<mm/m>
        static member fromMetre (v:float<m>) = v * MM.perMetre
        static member toMetre (v:float<mm>) = v / MM.perMetre
        [<OverloadIDAttribute("0")>]
        static member lift (v:float) = v * 1.0<mm>
        [<OverloadIDAttribute("1")>]
        static member lift (v:int) = v * 1<mm>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote my first program almost fifty years ago (yes, coding is still a
Yes, I am still on Drupal 5. Don't make fun. I created a category
Yes, it's a trivial piece of code to write, but I still wonder if
Is this combination possible at all? If yes, will I still need to buy
I have a classic ASP website (yes they still exist) that needs to call
Yes i know the phrase virtual constructor makes no sense but i still see
This one could be a trivial 'yes or no' question but still could be
In this OLE DB msdn example , (yes, it is dated 1997, but still
I am playing around and trying to build a parallax website - yes, I
Well, this is quite a weird issue. (I just hope it has something to

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.