# Haskell Support in Maguyva: Code Graphs for Type Classes and Modules

Canonical source: https://maguyva.ai/languages/haskell

License: text under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/); code samples under [MIT-0](https://opensource.org/license/mit-0); the Maguyva name, logos, brand assets and other code are not covered. Details: [maguyva.ai/license](https://maguyva.ai/license).

Maguyva parses Haskell with AST, symbol, and graph support, so AI agents can follow functions, type class instances, and data constructors across modules.

## Support snapshot

- Tier: AST and symbol support
- Programming
- Extensions: .hs, .lhs
- Real AST parsing for syntax-aware search and structural context.
- Named symbols feed semantic lookup and cross-reference. Graph navigation is available when relationship extraction is enabled.
- This language contributes symbols and relationships to graph-aware search; supported edge types vary with its native constructs.
- AST parsing and symbol extraction are both available.

## Best fit

- Haskell services and libraries with many modules, type classes, and instances.
- Compilers, parsers, and other codebases where a change to one data type reaches far.
- Teams using AI agents to read unfamiliar Haskell before a refactor.

## Agent workflows

- Find every caller of a function before changing its type signature.
- List which types have an instance of a type class.
- Trace where a data constructor is built and which functions consume it.

## Where Haskell trips up shallow AI tools

Haskell calls functions without parentheses, composes them with operators, and dispatches through type classes. `render user` is a call, `f . g <$> xs` holds several, and `show` means whatever the instance for that type says. Text search finds the names, not the instances behind them.

Maguyva records instances and constructors as relationships, so an agent can see which types implement a class and where a value is built.

## What Maguyva extracts in Haskell

Maguyva maps `.hs` and `.lhs` files to Haskell. Functions and bindings are extracted as callables, and type classes, `data` types, and `newtype`s as types. Calls are recognised in space-separated application and through infix operators, and imports normalise `qualified`, `hiding`, and `as` clauses.

Type classes and constructors become graph relationships:

- `instance Eq Point` records that `Point` implements `Eq`.
- When a class method has a default body in the same file, an instance that defines that method records an override of the default.
- Applying a data constructor, such as `Point 1 2`, counts as instantiation.
- `error`, `undefined`, and `throw` record throws, and handlers such as `catch` record catches.

Because instance declarations can define names such as `show` or `return`, a same-file definition is not assumed to be the target of a bare call with that name.

## Example agent prompts

- "Who calls `parseConfig`, and from which modules?" (`find_symbol`, then `dependency_search` incoming)
- "Which types have a `ToJSON` instance?" (`dependency_search`)
- "Trace how a request is decoded and validated." (`get_task_context`)

## Known limits

- About 130 Prelude and base names, such as `map`, `foldr`, `fmap`, `pure`, and `>>=`, and modules such as `Data.List` and `Control.Monad`, are filtered from relationships. Use `text_pattern_search` for them.
- In the grammar, a raw function node also denotes function types, so the `functions` preset in `structural_search` returns lambdas only, and the `methods` and `variables` presets select nothing. Use `find_symbol` for named functions.
- Literate `.lhs` files are read with the Haskell grammar as a whole, so expect partial results for them.
- Haskell has no decorator syntax, so decorator relationships are marked not applicable.

## Next steps

Connect a repository with the [quickstart](/docs/quickstart), then check the support matrix on the [compatibility page](/docs/compatibility). For other functional codebases, read the [Elixir guide](/languages/elixir).

## Engine details

- Haskell support maps `.hs` and `.lhs`. Type classes, `data` types, and `newtype`s are types, and calls are recognised in space application and through infix operators.
- `instance Eq Point` records that `Point` implements `Eq`, and an instance method that replaces a same-file class default records an override.
- Data constructor application counts as instantiation, and about 130 Prelude and base names are filtered from relationships.

## Useful MCP entry points

- `find_symbol`: Use it for a function or type when you need the definition and references; structural presets return lambdas only.
- `dependency_search`: Use incoming traversal on a type class to see which types have instances.
- `get_task_context`: Use it for prompts like “trace how a request is decoded and validated.”
