It’s possible to use function composition and modify the type of value returned. Consider the following equation:
I might encode the function to calculate this like so:
let square x = x * x //Want this to be a float because if this is an int division // it will always round to 0 if x is greater than 1. let recip x = 1.0/x let myFunc = fun x -> 4* (square x) >> recip
This function composition will not work because I need to pass a float to recip. But I can make it work by doing this:
let square x = x * x let recip x = 1.0/x let myFunc = fun x -> 4* (square x) >> float >> recip
There’s a great deal more information on conversion functions in F# here.