Full Hoogle-style type search #23

Open
opened 2026-01-05 21:17:05 +00:00 by mprihoda · 0 comments
mprihoda commented 2026-01-05 21:17:05 +00:00 (Migrated from github.com)

Problem

Simplified type search (#17) handles basic cases, but advanced queries need:

  • Polymorphic matching: `(A => B) => List[A] => List[B]` finds `map`
  • Fuzzy matching: `F[A] => A` finds `unsafeRunSync`, `getOrElse`, etc.
  • Curried function support
  • Higher-kinded type matching

Proposed Solution

Full Hoogle-style search engine for Scala/Java.

Enhanced `search_by_type`

{
  "name": "search_by_type",
  "description": "Find methods by type signature (advanced)",
  "input": {
    "signature": "Type signature query",
    "coordinates": "optional, limit to specific library",
    "projectPath": "optional, search project deps"
  }
}

Example queries:

search_by_type("(A => B) => List[A] => List[B]")
→ List.map, Vector.map, Array.map, ...

search_by_type("List[A] => NonEmptyList[A]")
→ NonEmptyList.fromList (returns Option), NonEmptyList.fromListUnsafe

search_by_type("F[Either[E, A]] => EitherT[F, E, A]")
→ EitherT.apply, EitherT.fromEither

Technical Approach

Type Signature Language

signature := type '=>' signature | type
type := name '[' type (',' type)* ']' | name | typevar
typevar := uppercase letter (A, B, F, etc.)

Matching Algorithm

  1. Parse query into type AST
  2. Match against method signatures from TASTy index
  3. Unify type variables
  4. Rank by specificity and popularity

Index Structure

  • Per-artifact index of all method signatures
  • Normalized for matching (strip package prefixes)
  • Precomputed for common libraries

Complexity

This is a significant engineering effort:

  • Type unification algorithm
  • Index storage and querying
  • Cross-artifact search
  • Performance optimization

Consider: Start with #17 (simplified) and evolve based on usage patterns.

Value for Agent

  • "How do I transform X to Y?" answered for any types
  • Discovers non-obvious conversions
  • Finds correct method even with complex signatures

Acceptance Criteria

  • Parse type signature queries with type variables
  • Match polymorphic signatures
  • Handle higher-kinded types (F[_])
  • Rank results by relevance
  • Sub-second query time for indexed libraries
## Problem Simplified type search (#17) handles basic cases, but advanced queries need: - Polymorphic matching: \`(A => B) => List[A] => List[B]\` finds \`map\` - Fuzzy matching: \`F[A] => A\` finds \`unsafeRunSync\`, \`getOrElse\`, etc. - Curried function support - Higher-kinded type matching ## Proposed Solution Full Hoogle-style search engine for Scala/Java. ### Enhanced \`search_by_type\` ```json { "name": "search_by_type", "description": "Find methods by type signature (advanced)", "input": { "signature": "Type signature query", "coordinates": "optional, limit to specific library", "projectPath": "optional, search project deps" } } ``` **Example queries:** ``` search_by_type("(A => B) => List[A] => List[B]") → List.map, Vector.map, Array.map, ... search_by_type("List[A] => NonEmptyList[A]") → NonEmptyList.fromList (returns Option), NonEmptyList.fromListUnsafe search_by_type("F[Either[E, A]] => EitherT[F, E, A]") → EitherT.apply, EitherT.fromEither ``` ## Technical Approach ### Type Signature Language ``` signature := type '=>' signature | type type := name '[' type (',' type)* ']' | name | typevar typevar := uppercase letter (A, B, F, etc.) ``` ### Matching Algorithm 1. Parse query into type AST 2. Match against method signatures from TASTy index 3. Unify type variables 4. Rank by specificity and popularity ### Index Structure - Per-artifact index of all method signatures - Normalized for matching (strip package prefixes) - Precomputed for common libraries ## Complexity This is a significant engineering effort: - Type unification algorithm - Index storage and querying - Cross-artifact search - Performance optimization Consider: Start with #17 (simplified) and evolve based on usage patterns. ## Value for Agent - "How do I transform X to Y?" answered for any types - Discovers non-obvious conversions - Finds correct method even with complex signatures ## Acceptance Criteria - [ ] Parse type signature queries with type variables - [ ] Match polymorphic signatures - [ ] Handle higher-kinded types (F[_]) - [ ] Rank results by relevance - [ ] Sub-second query time for indexed libraries
Sign in to join this conversation.
No description provided.