9

Is there a way to search for instances of a typeclass on Hoogle (or Stackage)?

For instance, I want to know which package defines an instance of Lift for Text.

I was able to find it in the package th-lift-instances, but it took about 10 minutes of manual searching. It seems like there should be some functionality of Hoogle that allows searching for instances.

Erik Kaplun
  • 37,128
  • 15
  • 99
  • 111
illabout
  • 3,517
  • 1
  • 18
  • 39

2 Answers2

5

For now, no. However, a feature was recently added to haddock to allow instances to link to their source, and all new documentation built on Hackage has that turned on. So in the next release of the th-lift package, you should see a "Source" link next to the Lift Text instance that will tell you what you need to know.

Daniel Wagner
  • 145,880
  • 9
  • 220
  • 380
  • 3
    I believe this can only work if the package can see the source. If it's an orphan, all bets are off. I see the orphan instance problem as Haskell's biggest scaling problem. – dfeuer Oct 06 '15 at 17:21
  • 1
    @dfeuer The haddocks already include the `Text` instance in the list of instances for `Lift`; isn't that good evidence that they can see the source? – Daniel Wagner Oct 06 '15 at 18:39
  • @DanielWagner, I don't think my original question was specific enough. There are two packages, `th-lift` and `th-lift-instances`. `th-lift` defines the `Lift` type class. `th-lift-instances` defines the `Lift Text` instance. If you want an instance of `Lift` for `Text` and all you know about is the `Lift` typeclass (in the `th-lift` package), then there is no good way to find out about the `th-lift-instances` package, save from googling for it like @Kolmar suggests. – illabout Oct 06 '15 at 23:39
2

Expanding on Kolmar's comment, some Google techniques do go a long way towards finding instances.

Examples:

-inurl: is used to clean up superfluous results from where the typeclass was defined.

Community
  • 1
  • 1
Wizek
  • 4,854
  • 2
  • 25
  • 52