# Allow units of measure in sequence ranges #535

Open
opened this Issue Feb 9, 2017 · 2 comments

None yet

### 2 participants

commented Feb 9, 2017

# Allow units of measure in sequence ranges

I propose we extend sequence expressions to handle ranges involving units of measure. Currently we cannot do the following:

``````let maximumDistance = 3<km>
let minimumDistance = 1<km>
let trials = [ minimumDistance .. maximumDistance ]
``````

The existing way of approaching this problem in F# is to generate a range from bare integers and then map a multiplication to add the dimension

## Pros and Cons

• An improvement to the safety of code by removing error potential in dropping the units and then adding them back

• None that I can think of

## Extra informtion

Estimated cost (XS, S, M, L, XL, XXL):
M? (because of the added complication of `min .. step .. max`)

Related suggestions: (put links to reated suggestions here)
Allow units of measure in for loops #534

Please tick this by placing a cross in the box:

• This is not a question (e.g. like one you might ask on stackoverflow) and I have searched stackoverflow for discussions of this issue
• I have searched both open and closed suggestions on this site and believe this is not a duplicate
• This is not something which has obviously "already been decided" in previous versions of F#. If you're questioning a fundamental design decision that has obviously already been taken (e.g. "Make F# untyped") then please don't submit it.

• This is not a breaking change to the F# language design
• I would be willing to help test this
• I or my company would be willing to help crowdfund F# Software Foundation members to work on this
referenced this issue Feb 9, 2017
Open

#### Allow units of measure in for loops #534

 Looks like the problem is that units of measure don't support the `GenericOne` operator, possibly because being a measure, which is basically a multiplication, 'zero' is an absolute value but 'one' is relative to the measure. Since the `(..)` operator uses the `GenericOne` it doesn't work, of course you can write this: ``````let trials = [ minimumDistance .. 1 .. maximumDistance ] `````` Alternatively, or if this suggestion doesn't get approved, you can suggest to add `GenericOne` to a library that offers language extensions, like FSharpPlus which will redefine some generic operators, like `(..)` so the code you posted would work, but will be interesting to understand the reason why it wasn't added to F# in first place.