searchdocumentationf#types

Does F# documentation have a way to search for functions by their types?


Say I want to know if F# has a library function of type

('T -> bool) -> 'T list -> int

ie, something that counts how many items of a list that a function returns true for. (or returns the index of the first item that returns true)

I used to use the big list at the MSR site for F# before the documentation on MSDN was ready. I could just search the page for the above text because the types were listed. But now the MSDN documentation only lists types on the individual pages--the module page is a mush of descriptive text. Google kinda-sorta works, but it can't help with

// compatible interfaces
('T -> bool) -> Seq<'T> -> int
// argument-swaps
Seq<'T> -> ('T -> bool) -> int
// type-variable names
('a -> bool) -> Seq<'a> -> int
// wrappers
('a -> bool) -> 'a list -> option<int>
// uncurried versions
('T -> bool) * 'T list -> int
// .NET generic syntax
('T -> bool) -> List<'T> -> int
// methods
List<'T> member : ('T -> bool) -> int

Haskell has a standalone program for this called Hoogle. Does F# have an equivalent, like Fing or something?


Solution

  • Based on kvb's answer, I created a complete application. It's hosted on github at http://github.com/sandersn/fing.

    The code is still pretty ugly, but it works for simple cases. I took out kvb's most-general-unifier (mgu) for now because it adds a lot of non-obvious results. Fancy things like structural constraints and most-general-supertype don't work yet either.

    There's also binary for a command-line version if you don't want to build from source. (It still requires a modern version of the .NET runtime installed, though.) Eventually I will find some ASP.NET hosting, learn ASP, and wrap the whole thing in a web app so that no installation is needed at all. (I guess if there is demand I could create a client-side GUI, but I have even less experience with that kind of thing.)