ollama-holes-plugin: A typed-hole plugin that uses LLMs via Ollama to generate valid hole-fits

[ compiler-plugin, development, library, mit ] [ Propose Tags ] [ Report a vulnerability ]

This package provides a GHC plugin that uses LLMs via Ollama to generate valid hole-fits. . The following flags are available: . To specify the model to use: . > -fplugin-opt=GHC.Plugin.OllamaHoles:model=model_name . To specify how many fits to generate (passed to the model) . > -fplugin-opt=GHC.Plugin.OllamaHoles:n=5 . To enable debug output: . > -fplugin-opt=GHC.Plugin.OllamaHoles:debug=True . Before using this plugin, make sure you have the Ollama CLI installed and the model you want to use is available. You can install the Ollama CLI by following the instructions at <a href="https://ollama.com/download">https://ollama.com/download</a>, and you can install the default model (gemma3:27b) by running `ollama pull gemma3:27b`. . Note that the speed and quality of the hole-fits generated by the plugin depends on the model you use, and the default model requires a GPU to run efficiently. For a smaller model, we suggest `gemma3:4b-it-qat`, or `deepcoder:1.5b`.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies base (>=4.18.2.1 && <4.19), ghc (>=9.6 && <9.7), ollama-haskell (>=0.1 && <0.2), text (>=2.1 && <2.2) [details]
Tested with ghc >=9.6 && <9.7
License MIT
Copyright 2025- Matthias Pall Gissurarson
Author Matthias Pall Gissurarson <mpg@mpg.is>
Maintainer Matthias Pall Gissurarson <mpg@mpg.is>
Category Development, Compiler Plugin
Home page https://github.com/Tritlo/OllamaHoles
Source repo head: git clone git://github.com/Tritlo/OllamaHoles.git
Uploaded by tritlo at 2025-04-25T09:57:02Z
Distributions
Downloads 2 total (2 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for ollama-holes-plugin-0.1.0.0

[back to package description]

Ollama Holes

image

Introduction

This is an example of a typed-hole plugin for GHC that uses the Ollama to host a local LLM to fill in holes in Haskell code.

Example

Given

{-# OPTIONS_GHC -fplugin=GHC.Plugin.OllamaHoles #-}
{-# OPTIONS_GHC -fplugin-opt=GHC.Plugin.OllamaHoles:model=gemma3:27b #-}
{-# OPTIONS_GHC -fplugin-opt=GHC.Plugin.OllamaHoles:n=5 #-}

module Main where

import Data.List


main :: IO ()
main = do let k = (_b :: [Int] -> [String])
          print (k [1,2,3])

We get the following output:

    Main.hs:12:20: error: [GHC-88464]
        • Found hole: _b :: [Int] -> [String]
        Or perhaps ‘_b’ is mis-spelled, or not in scope
        • In the expression: _b :: [Int] -> [String]
        In an equation for ‘k’: k = (_b :: [Int] -> [String])
        In the expression:
            do let k = (_b :: [Int] -> [String])
            print (k [1, 2, ....])
        • Relevant bindings include
            k :: [Int] -> [String] (bound at Main.hs:12:15)
            main :: IO () (bound at Main.hs:12:1)
        Valid hole fits include
            \x -> map show x
            map (show)
            \x -> map (\y -> "Number: " ++ show y) x
            \x -> replicate (length x) "Hello"
            []
    |
    12 | main = do let k = (_b :: [Int] -> [String])
    |                    ^^
    Error: cabal: Failed to build exe:main from OllamaHolesTest-1.0.0.

Installation

  1. Install Ollama
  2. Install the gemma3:27b model (or any other model you prefer) using the following command:

ollama pull gemma3:27b
  1. Clone this repository and navigate to the directory, and build the project using:
cabal build
  1. Run the example using:
cabal build Test
  1. Enjoy! If you want to change the underlying model, make sure to pass the model name via the plugin arguments (see example)