Reputation: 7675
I've noticed difficulty in piping to/from some .NET methods. Toy example
let foo = System.String [| 'a'; 'b'; 'c' |] // works
let foo = [| 'a'; 'b'; 'c' |] |> System.String // fails
// error FS0802: Invalid use of a type name and/or object constructor.
let foo = System.String <| [| 'a'; 'b'; 'c' |] // fails the same way
let foo = [| 'a'; 'b'; 'c' |] |> new System.String // Fails
// error FS0010: Incomplete structured construct at or before this point in expression
I'm basically trying to figure out when you can combine piping with .NET objects and when not. If there's a reference out there I'd love to get the link!
Upvotes: 1
Views: 188
Reputation: 388
As for the hang-up you're having with strings, the following link shows that support for treating constructors as functions was added to F# 4.0
Another common situation that makes piping awkward from .NET libraries is that they're exposed as tupled
(as opposed to curried
) function parameters, which can make partially-applying functions to pipe through more painful. Creating curried wrappers around these clunky .NET functions is often a good work-around.
Upvotes: 2