fsprojects / FSharp.UMX

F# units of measure for primitive non-numeric types
MIT License
154 stars 10 forks source link

Converting to string and performing string operation #10

Open cartermp opened 5 years ago

cartermp commented 5 years ago

There's also a more general question about conversations, but should something like this be possible?

image

Fails to build as well so it's not an Ionide quirk.

rojepp commented 5 years ago

You'd have to use let str = UMX.untag file or let str : string = %file. @eiriktsarpalis Maybe a second operator could be added specifically for untag? It should be a fairly common operation.

bartelink commented 5 years ago

While there are use cases where sprinkling % and other operators around might be appropriate, I feel having the type paired with a module of specific named conversion operators a la the normal to and of functions might be more sustainable (it also gets you out of having open FSharp.UMX all over the place).

I have some usages here that use % and just enough type hints.

eiriktsarpalis commented 5 years ago

Maybe a second operator could be added specifically for untag?

Because these operators have to be defined using SRTP magic, using a dedicated operator for untagging would not solve the problem.

cartermp commented 5 years ago

I think I prefer UMX.untag to another operator.