ndmitchell / ndmitchell/hoogle

Find generic versions of the same function

Open
#399 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Haskell
Stars
803
Forks
152
PR merge metrics
No merged PRs in 30d

Description

I tried searching for this in Hoogle and found no matches:

Monad m => (e -> ExceptT x m a) -> ExceptT x m (Either e a) -> ExceptT x m a

I then implemented it like this:

onLeft :: Monad m => (e -> ExceptT x m a) -> ExceptT x m (Either e a) -> ExceptT x m a
onLeft h f = f >>= either h pure

Inferring the type signature I get this:

onLeft :: Monad m => (a -> m b) -> m (Either a b) -> m b
onLeft h f = f >>= either h pure

The inferred type signature is one that actually yields results:

Monad m => (a -> m b) -> m (Either a b) -> m b

fromRightM :: Monad m => (a -> m b) -> m (Either a b) -> m b
fromEitherMM :: Monad m => (e -> m a) -> m (Either e a) -> m a
fromEitherOrMM :: Monad m => m (Either e a) -> (e -> m a) -> m a

If Hoogle can somehow infer the generic type signature from the specialised one and put that in the search results, that would help a lot.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file or test entry point is identified. Start by reproducing the Hoogle search for the specialised ExceptT signature and compare it with the inferred generic signature and related variants shown in the issue; done means generic matches can appear in search results without losing useful specialised matches.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
search
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.