# Julia sure looks like it needs a version of Hoogle

**URL:** https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098
**Category:** General Usage
**Created:** [August 9, 2021, 10:56pm UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098 "2021-08-09T22:56:07Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![banksiaboy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/banksiaboy/32/27032_2.png) [@banksiaboy](https://discourse.julialang.org/u/banksiaboy)
#### Post date: [August 9, 2021, 10:56pm UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/1 "2021-08-09T22:56:08Z")

</div>

I’m new to Julia. Finding functions seems more difficult than I’d hoped.

Smalltalk lets me find references to Classes and implementors of method selector Symbols. I can also inspect instances of a class and browse the network of code attached.

Haskell has [Hoogle](https://hoogle.haskell.org/) which allows me to search Haskell libraries, external to my current environment, by type signature: [FilePath → String](https://hoogle.haskell.org/?hoogle=FilePath%20-%3E%20String). As you can see, it works pretty well.

As much as I love Smalltalk, I prefer the Haskell facility.

I tried to find a type conversion function for `PosixPath -> AbstractString`. People answered from experience and memory. Which is helpful, but not a general solution.

Julia has a lot of wonderful type information. it seems a shame not to use it in search.

Here’s what the interpreter/compiler (?) is trying to do when I try to convert a `::FilePathsBase.PosixPath` to a String so I can use it as the second argument to `download()`

```julia
MethodError: no method matching String(::PosixPath)
Closest candidates are:
  String(::String) at boot.jl:350
  String(::Vector{UInt8}) at strings/string.jl:53
  String(::Symbol) at strings/string.jl:83
  ...

```

I have an answer to my specific conversion exercise. I want a solution to _how do I find all the functions which transform a particular signature of types_.

How and where do I propose such a thing - if it doesn’t already exist?

---

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [August 9, 2021, 11:17pm UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/2 "2021-08-09T23:17:08Z")

</div>

A proof of concept might start with downloading the General Registry and using `methodswith`.

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [August 9, 2021, 11:18pm UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/3 "2021-08-09T23:18:22Z")

</div>

Julia functions are often so generic and polymorphic that it’s hard to determine function input-output without running type inference (and sometimes not even that is enough). You can get an enormous amount of hits, because people often write code that is completely generic, with only an inkling of an idea about what input/output it will take and produce.

When I replied to your question I didn’t just rely on memory and experience, I used the perspective shift I recommended. Don’t ask about types, ask about functionality. You want to convert? Search for convert! That’s pretty straightforward.

I don’t oppose your suggestion, but I’m not sure if it will be quite as useful as in Haskell, where it seems like input/output types of functions are more common and available.

---

<div class="post-metadata">

### Author: ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)
#### Post date: [August 9, 2021, 11:27pm UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/4 "2021-08-09T23:27:37Z")

</div>

To build on this, some sort of conglomeration of `methodswith`, `@which`, `apropos`, [https://github.com/JuliaLang/julia/pull/38791](https://github.com/JuliaLang/julia/pull/38791) and [JuliaHub](https://juliahub.com/ui/Search?type=symbols) (which itself is a great resource) removes the need to go to memory for everything.

As @DNF mentioned though, something like Hoogle really relies on pervasive, constrained type declarations. In contrast, writing Julia is more like writing Template Haskell: many declarations can’t be evaluated without lugging the compiler around with you, and the potential surface area for instantiations is unbounded. That’s not to say such a system wouldn’t be useful, but it’d take a heck of a lot more effort and careful design than Hoogle because of all the aforementioned reasons.

---

<div class="post-metadata">

### Author: ![banksiaboy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/banksiaboy/32/27032_2.png) [@banksiaboy](https://discourse.julialang.org/u/banksiaboy)
#### Post date: [August 9, 2021, 11:31pm UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/5 "2021-08-09T23:31:26Z")

</div>

Haskell has a a lot of inferred typing. But it search seems to work to some reasonable degree I cant argue the specifics.

I don’t think `convert` is a good example, it was just what I was looking for at the time. Without knowing - as you do, the particular vocabulary, I wasted a huge amount of time trying to do a trivial operation.

Both Google and Hoogle get a lot of hits but they rank them.

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [August 9, 2021, 11:37pm UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/6 "2021-08-09T23:37:21Z")

</div>

How does hoogle rank them? I’m having a hard time thinking of a meaningful ranking.

---

<div class="post-metadata">

### Author: ![banksiaboy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/banksiaboy/32/27032_2.png) [@banksiaboy](https://discourse.julialang.org/u/banksiaboy)
#### Post date: [August 9, 2021, 11:43pm UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/7 "2021-08-09T23:43:36Z")

</div>

OK Thanks - what I needed to know. I dabbled a little in Haskell - I don’t know enough to be dangerous.

I am really so incredibly unproductive if I waste hours looking for such a trivial function, in what I’d is a fairly high-traffic area. I’ve got much more difficult stuff to find.

`ZipFile.ReadableFile` in its documentation has `seek(z,0)` which I cannot for the life of me find how to access. Once I read the stream, it is at its end. I cant re-read it, without seek(z,0) which`0` is the only allowed argument value. I’d have called that `reset`

All the answers to my question came from people who already knew the answer, along with many hopeful attempts.

I haven’t found any way of browsing Julia source. Was string(::PosixPath) → ::String something I could have found?

---

<div class="post-metadata">

### Author: ![banksiaboy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/banksiaboy/32/27032_2.png) [@banksiaboy](https://discourse.julialang.org/u/banksiaboy)
#### Post date: [August 9, 2021, 11:46pm UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/8 "2021-08-09T23:46:31Z")

</div>

By closeness of match I think… Relaxing the types somehow. Like Google I don’t know how it works.  
My example of a naive search, by a beginner:

[FilePath → String](https://hoogle.haskell.org/?hoogle=FilePath%20-%3E%20String).

---

<div class="post-metadata">

### Author: ![banksiaboy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/banksiaboy/32/27032_2.png) [@banksiaboy](https://discourse.julialang.org/u/banksiaboy)
#### Post date: [August 9, 2021, 11:54pm UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/9 "2021-08-09T23:54:08Z")

</div>

Search answers included some generic Typeclass parameters too `a=>a -> String` I think. It’s a few years since I did the lessons.

I really liked this dynamic book format:  
[Using Typeclasses](http://book.realworldhaskell.org/read/using-typeclasses.html)

---

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [August 9, 2021, 11:59pm UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/10 "2021-08-09T23:59:21Z")

</div>

Julia does know the answer to your question:

```julia
julia> @code_typed string(PosixPath())
CodeInfo(
1 ─ %1 = Core.getfield(xs, 1)::PosixPath
│ %2 = invoke Base.print_to_string(%1::PosixPath)::String
└── return %2
) => String

```

Is it possible to query the type of `string(x::PosixPath)` without actually instantiating `PosixPath`?

---

<div class="post-metadata">

### Author: ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)
#### Post date: [August 10, 2021, 12:05am UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/11 "2021-08-10T00:05:05Z")

</div>

Generally you can’t search by return types because that requires the compiler get involved (this is why I drew the Template Haskell comparison). However, the existing tools can get you partway there:

```julia
julia> methodswith(PosixPath; supertypes=true)
...
[110] print(io::IO, fp::AbstractPath) in FilePathsBase at /home/brianc/.julia/packages/FilePathsBase
...

```

Of course this requires knowing that `string` calls `print` under the hood, but that’s an issue in a Hoogle-like system as well.

I think one actionable insight from this thread is that packages ought to provide a full API reference in their docs. For example, searching for “print” in the FilePathsBase docs turns up nothing. It’s unfortunate that Documenter.jl does not provide this by default. [https://github.com/MichaelHatherly/Publish.jl](https://github.com/MichaelHatherly/Publish.jl) kind of does, but hasn’t been adopted very broadly. As one HN commenter [mentioned](https://news.ycombinator.com/item?id=27967476) (and I mostly agree with), having auto-generated docs even for parts of the API the maintainers haven’t written more curated documentation for is really nice in other language ecosystems, especially if e.g. externally defined methods are being overloaded.

---

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [August 10, 2021, 12:08am UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/12 "2021-08-10T00:08:46Z")

</div>

> [@ToucheSir](#):
>
> Generally you can’t search by return types because that requires the compiler get involved

Getting the compiler involved may be possible though. I wonder if JET can do it [API · JET.jl](https://aviatesk.github.io/JET.jl/dev/generated-plugin-api/)

---

<div class="post-metadata">

### Author: ![banksiaboy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/banksiaboy/32/27032_2.png) [@banksiaboy](https://discourse.julialang.org/u/banksiaboy)
#### Post date: [August 10, 2021, 12:20am UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/13 "2021-08-10T00:20:53Z")

</div>

Thank-you all so much!

Complete documentation of the Libraries concerned would have left me in a much better place. Should I raise a PR?

Do I have to raise a PR on a library to ask a specific question?

Maybe there needs to be some sort of `request for review` process on docs.

Was there any way of discovering `string()` was the method I needed? I assume it was already in my activated environment.

There’s nothing wrong with making discoverability part of a language/environment design 🙂

---

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [August 10, 2021, 12:28am UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/14 "2021-08-10T00:28:39Z")

</div>

> [@banksiaboy](#):
>
> Was there any way of discovering `string()` was the method I needed? I assume it was already in my activated environment.

1. Find a list of methods that take `PosixPath` instances. I’m not seeing `string` in `methodswith(PosixPath, supertypes=true)`, don’t know why.
2. For each one, check its return type on a `PosixPath` instance. ` julia> code_typed(string, PosixPath())[1][2]` returns `String`.
3. Filter to ones that return `AbstractString` subtypes.

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [August 10, 2021, 12:31am UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/15 "2021-08-10T00:31:30Z")

</div>

In fairness, `string` is a bit of a special function. This should be documented somewhere but `string` is defined for every type. It’s always possible to get a `string` representation of a struct because julia needs to be able to print every struct.

It probably doesn’t show up in docuementation because it is kind of knowledge, which definitely isn’t fair. I think this information should be added to the `String` documentation.

---

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [August 10, 2021, 12:34am UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/16 "2021-08-10T00:34:53Z")

</div>

I wouldn’t add to the documented contract of stringification functions, IMHO they are messed up and Julia needs the flexibility to fix them without breaking contract.

---

<div class="post-metadata">

### Author: ![banksiaboy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/banksiaboy/32/27032_2.png) [@banksiaboy](https://discourse.julialang.org/u/banksiaboy)
#### Post date: [August 10, 2021, 12:35am UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/17 "2021-08-10T00:35:05Z")

</div>

Publish looks pretty interesting

---

<div class="post-metadata">

### Author: ![banksiaboy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/banksiaboy/32/27032_2.png) [@banksiaboy](https://discourse.julialang.org/u/banksiaboy)
#### Post date: [August 10, 2021, 12:44am UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/18 "2021-08-10T00:44:42Z")

</div>

Most environments do something similar with Strings.  
In the Smalltalk we used to build we generally had two variants which usually delegated to one.

There were methods with selector: `#printString`, implemented as `#printOn: aStream` which gave a fairly standard printable representation of an object. What we really liked was a `printString` which when you fed it to the compiler, returned an object which was at least equal to the original. so if you printed a Point `1@2` it printed itself as `1@2` which was its literal.

it was easy to find though `Point allImplementors: #printString` which would give all implementations up the hierarchy.

I digress…

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [August 10, 2021, 12:47am UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/19 "2021-08-10T00:47:04Z")

</div>

I think the Julia developers are aware that method discovery could use some work. But as many have mentioned in this thread, there is work underway to improve this tooling.

---

<div class="post-metadata">

### Author: ![banksiaboy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/banksiaboy/32/27032_2.png) [@banksiaboy](https://discourse.julialang.org/u/banksiaboy)
#### Post date: [August 10, 2021, 12:48am UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098/20 "2021-08-10T00:48:38Z")

</div>

Sure - thanks… I can see from some of the tools mentioned that people care. It takes a lot of effort.  
I am really enjoying Julia.

[Next page](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098.md?page=2)
