6

I saw recently that some code (Fake, specifically) uses a function @@ without defining it, presumeably it exists as part of the F# standard library, or somewhere else in .NET.

How do I search online for this type? Is there a pursuit-like or hoogle-like database I can use?


This question focuses more on how to find a particular function, and incidentally, hoogle alternatives. There are two very good answers, and the nature of the answers and comments are quite different.

Sridhar Ratnakumar
  • 81,433
  • 63
  • 146
  • 187
Arafangion
  • 11,517
  • 1
  • 40
  • 72
  • See https://learn.microsoft.com/en-us/dotnet/articles/fsharp/language-reference/symbol-and-operator-reference/ – Mankarse May 09 '17 at 03:51
  • @Mankarse: That particular function isn't there, and misses the question. – Arafangion May 09 '17 at 04:05
  • 2
    F# doesn't **yet** have anything like Pursuit or Hoogle, AFAIK. Some people have been discussing something like that (see discussion on https://github.com/fsharp/FAKE/issues/1485, for example), but nobody has done it yet. It will be a big improvement if/when it finally happens, and there are no technical reasons why it couldn't happen, just a lack of time among the many people (like me) who want to see it happen. – rmunn May 09 '17 at 04:13
  • @rmunn: That's unfortunate - thanks. – Arafangion May 09 '17 at 04:23
  • 2
    Possible duplicate of http://stackoverflow.com/questions/2253730/does-f-documentation-have-a-way-to-search-for-functions-by-their-types?rq=1 – Arafangion May 09 '17 at 04:25
  • Possible duplicate of [Does F# documentation have a way to search for functions by their types?](http://stackoverflow.com/questions/2253730/does-f-documentation-have-a-way-to-search-for-functions-by-their-types) – CaringDev May 09 '17 at 05:23
  • Note that tooling such as Visual Studio and Visual Studio Code will show the fully qualified name, type signature and documentation on mouse hover for operators. Not helpful on GitHub, though. – TheQuickBrownFox May 09 '17 at 18:21
  • @TheQuickBrownFox: And not helpful in .fsx files, either, unless I'm mistaken? – Arafangion May 09 '17 at 23:49
  • 1
    This works in FSX files too as long as the dependencies are in place. They are just as statically typed as FS. – TheQuickBrownFox May 10 '17 at 06:26

2 Answers2

6

It's defined under Fake.EnvironmentHelper module (source):

let inline (@@) path1 path2 = combinePaths path1 path2

where combinePaths is just a curried form of the BCL's Path.Combine with removal to leading path seperator in path2 (source):

let inline combinePaths path1 (path2 : string) = 
    Path.Combine(path1, path2.TrimStart [| '\\'; '/' |])

Note that Fake.EnvironmentHelper has the AutoOpenAttribute applied to it. Other modules referring to this @@ operator do not need to explicitly open the Fake.EnvironmentHelper module.

rexcfnghk
  • 14,435
  • 1
  • 30
  • 57
  • That explains it! Particularly for the AutoOpenAttribute attribute. However, if you consider the `@@` to be an example, does F# have an equivalent for pursuit, or hoogle, etc? – Arafangion May 09 '17 at 04:06
  • The only F# search engine similar to Hoogle is the MSDN, which is the link to the `AutoOpenAttribute` in my answer. – rexcfnghk May 09 '17 at 04:10
  • MSDN is a fairly... Crap search engine if comparing to hoogle or pursuit, but if that's what we have, then that's what we have (until someone fixes it). I'll accept your answer as a result - thanks. – Arafangion May 09 '17 at 04:24
  • I haven't had much experience with Haskell so I cannot compare but one thing I quite like about MSDN is they provide examples to almost all library functions, which is quite useful, especially to newcomers of functional programming. – rexcfnghk May 09 '17 at 04:26
  • The best thing about hoogle, is that you can literally search by generic types. Eg, `(a -> b) -> [a] -> [b]`, which is map. It's a great way to determine "Has someone implemented this before?", and critically, can search for weird symbols such as `https://www.haskell.org/hoogle/?hoogle=%3E%3D%3E` – Arafangion May 09 '17 at 04:30
  • Searching on type signature is less useful than in Haskell since F# is not pure (there are many possible implementations of `'a -> 'a` with different side-effects) and less generic. This may be why less effort has gone into this. – TheQuickBrownFox May 09 '17 at 18:32
  • @TheQuickBrownFox: Fair point, though I would hope that utilities, such as `@@` in the case of Fake and operators in general would be pure. – Arafangion May 10 '17 at 01:25
6

There is FSDN that allows hoogle-like searching in mscorlib, some System.* dlls and a few libraries (including FAKE).

Update 2022-06-11: FSDN seems to be offline. I don’t know an alternative.

CaringDev
  • 8,391
  • 1
  • 24
  • 43
  • This, together with rmunn's comment that there isn't actually anything like pursuit or hoogle, is the answer I was after *especially* w.r.t. FAKE #1485 which rmunnlinked. FSDN itself seems to be the closest we have today. – Arafangion May 09 '17 at 06:09
  • 1
    As of 2017/05/17 19:00 JST, FSDN has been added FAKE APIs support (thanks to FSDN guys!). So, check `FAKE.Lib` item in the Target Assemblies menu (right side of the page), input `(@@) : _`, and then you'll get the signature of the `@@` function. – yukitos May 17 '17 at 10:03