ndmitchell / hoogle

Haskell API search engine
http://hoogle.haskell.org/
Other
738 stars 134 forks source link

Record non-unary class constraints #268

Open matt-noonan opened 5 years ago

matt-noonan commented 5 years ago

The current type search applies a cost to any non-concrete constraints (e.g. a penalty is applied for Monad m, but not Monad Maybe, which may appear when specializing a type to match the query). We may want to add costs for non-unary constraints as well, such as Coercible a b or Partial, but at the moment these are not reflected in the types as stored in the db.

ndmitchell commented 5 years ago

In Hoogle 4 I split Coercible a b into Coercible1 a, Coercible2 b - it isn't a perfect match, but it's somewhat close. Nullary constraints are special, and rare, so I ignoring them entirely is probably fine (Partial is really an annotation). The way Monad Maybe should be dealt with is by checking the list of instances, which I think Hoogle does record. One that has an instance would have a penalty of 0, one that isn't would be pretty hard.