Suppose I have defined a unit of measure:
[<Measure>] type Blob
And I want a type that takes a value in Blobs per second as a constructor argument:
type Something(flowRate:double<Blob/s>) = ...
F# throws a wobbly on this - "double does not expect any type arguments, but here is given 1 type argument"
I understand the message. I'd have thought it was obvious what I was trying to do, though I acknowledge that the syntax probably is verifiably wrong. Question is, how do I express this relationship in code?
Yes you can pass variable no. of arguments to a function.
F Next Dusting Powder is a combination medicine used to treat various types of fungal skin infections. It minimizes symptoms of skin infection such as redness, swelling, itching, etc., by acting against the infection-causing microorganisms. 622 people viewed this recently.
Functions can accept a variable number of positional arguments by using *args in the def statement. You can use the items from a sequence as the positional arguments for a function with the * operator. Using the * operator with a generator may cause your program to run out of memory and crash.
As the message (sort of) indicates, doubles aren't measure-generic. Try float<Blob/s> instead. It's a bit strange, since float is a type synonym for type double. However, type float<[<Measure>]'t> is in some ways its own separate type. A similar problem occurs with single vs. float32, int32 vs. int, and int8 vs. byte. Section 9.7 of the spec partly covers this information.
It's especially confusing since you can't define your own types which differ only in their measure arity:
type T = class end
type T<[<Measure>]'t> = class end //' Duplicate definition of type T
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With