Well, in general I prefer the way that infers the most. With OO types, this can be more difficult, as you don't usually have static method to provide a type to infer, and you can't infer by fields. But if TwitterStatus was a F# record, you wouldn't need to annotate the type at all, as it'd figure it out via the field access.

It's probably best to take it on a case-by-case basis, choosing the option that looks nicest for that bit of code. Personally, in this case, I would use your first option, but rename statuses to xs, as that provides the least code. While "least code" isn't always the best, I think in this case it does remove clutter. But its still probably a toss up with the second option.

If you wanted to go pointfree like excludeSelf3, you can use _ to tell F# to infer the type:

1
2
3
 
    let excludeSelf3 : seq<TwitterStatus> -> _ =
        Seq.filter (fun s ->  s.User.ScreenName <> "markhneedham")  

I probably wouldn't use pointfree if I had to specify type annotations like that.

As a side note, this is something I've heard from other people too - since F# is pretty flexible, deciding how they want to write/format something is actually much more of a decision than in, say, C# or Java.

By on 6/23/2009 1:27 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper