r/haskell • • 27d ago

Monthly Hask Anything (November 2026)

16 Upvotes

This is your opportunity to ask any questions you feel don't deserve their own threads, no matter how small or simple they might be!


r/haskell • • 6h ago

announcement Experimental Dependent Types in Haskell Fork

16 Upvotes

Hey all!

Today I’m releasing my fork of GHC with -XDependentTypes. You can try it in the browser or walk through the examples.

I figured that if the slop cannon could help with the Riemann hypothesis, it could handle Dependent Haskell. And it did!

To see what the fork could do, I had Gemini 4 Neon port Programming Language Foundations in Agda to Dependent Haskell. Thanks to the GHC Wasm backend, you can work through the 25-chapter book directly in your browser. It even has an Agda mode built on my work on valid hole fits. Leave a hole in a proof and a hole-fit plugin can suggest what goes there.

There are examples of type-directed JSON encoding without type families, typed SQL schemas and joins, and Servant-style routing. You can select your monad transformer stack at runtime! The walkthrough also covers type-level case and lambdas, and linear protocols.

My goal is to build hype around dependent types in Haskell and show how much of the design is already there in the proposals. I’m releasing this as an experimental fork. I don’t plan to upstream it myself, though the GHC team is welcome to use it.

If you want to try it in your own project, there’s a dependent-base library. You can get it through dependent-hackage, an overlay along the lines of head.hackage. It also carries patches for tools like Fourmolu that need to understand the new syntax.

There’s even an observational equivalence plugin. Say you have a dependently typed implementation and a fast path written in ordinary Haskell. You can ask QuickCheck to look for inputs where the two disagree. If it finds one, you get a counterexample. If the tests pass, the result is only as strong as the generators and tests you chose.

Validation

The two main users so far have been the PLFH book and my PiTA library. The book turned up compiler bugs and showed where writing proofs was awkward. PiTA extends equality-constrained tree automata with dependent types and uses them to search for valid hole fits. Two plugins also exercise GHC’s internals: the observational equivalence plugin and a typed-hole proof helper.

I assume the implementation is full of holes (typed holes even) and bugs, but those can be fixed. I've run a sweep of Stackage and most packages compile, barring some minor shims for GHC 10.1 compatibility. Some minor compiler issues are being fixed as well.

Development notes

The initial work was done mostly by GPT-6.2 Astra managing a team of GPT-6.2 Sol agents. After I ran out of usage and resets, Gemini took over the compiler work with a team of Gemini 4 Carbon models. Both teams used their native harnesses, with some additional skills based on Well-Typed blog posts, anti-slop and humanizer skills for writing, and an internal agentic engineering plugin at DPella AB. Claude worked on PiTA and turned up several compiler issues.

I based the prompts on GHC proposal #378, the Serokell roadmap, and Richard Eisenberg’s thesis, papers, and old GHC branch.

The compiler, book, and PiTA work came to about 37.1 billion tokens in total, roughly 98% of them cache reads. At public API rates, the estimate came to around $16k. I ran it all on subscriptions, with some help from three banked resets, OpenAI’s generously timed billing bug, and Gemini’s Thanksgiving reset. So no need for a GoFundMe!

Acknowledgements

Thanks to Richard Eisenberg for proposal #378, his thesis, and the old GHC branch that gave us a place to start. Thanks to Vladislav Zavialov, Andrei Borzenkov, and the rest of the Serokell team for the roadmap and years of work on GHC, and to everyone who wrote and reviewed the other proposals we drew on.

Thanks to Philip Wadler, Wen Kokke, and Jeremy G. Siek for PLFA. Having a book full of proofs written for another language was a great way to find out where our compiler fell short.

Thanks to Cheng Shao, Norman Ramsey, and the other GHC Wasm contributors for making it possible to try this in a browser. Thanks to Jules (@analytichegel on Twitter) for the observational equivalence idea behind the QuickCheck plugin.

Thanks to Mercury for ghc-persistent-worker. With a few tweaks, it made those repeated incremental GHC builds a lot faster! And thanks to Andrea Bedini and IOG for Foliage, whose package metadata format we use in dependent-hackage.

Thanks for reading! I hope you get a chance to play around with it. If you find a bug, please file an issue on the fork. I’d love to see what people try with it, and I hope this builds some excitement for getting dependent types into GHC itself.


r/haskell • • 18h ago

[ANN] Distributed consensus library and ecosystem with built-in DST

27 Upvotes

Hey all,

Over the past year, I have been working on an implementation of the Raft consensus algorithm in Haskell, which allows for distributed consensus. In particular, using Raft, one can create a distributed, fault-tolerant state machine. The library has been released on Hackage under the name raft-consensus. Bring your own networking and persistence layer!

Raft is tricky to get right. To ensure that the library works correctly, and respects the properties of the algorithm in practice, even under faults such as crashes and network partitions, I leveraged a technique called deterministic simulation testing (DST), using io-sim as the foundation. io-sim is pure awesomeness that should be used more.

While building out examples, I noticed other ecosystem holes that resulted in more packages. Testing the linearizability of client requests required building a simple linearizability checker: linearizable. Another piece of technology that came from this project is a generic and performant implementation of write-ahead logs via a new wal package.

Finally, in order to make it as easy as possible to build a replicated state machine in practice, I built two adapter packages:

I feel relatively confident in releasing this stuff now because, over the past week, I’ve been working on a demo: distributed software transactional memory. This program looks just like stm, but running over multiple computers.
Right now it’s just a demo, but it shows how freaking cool distributed state machines can be.

My goal, since I started helping with maintenance of Cloud Haskell, has been for Haskell to become a solid choice for distributed systems. We’re now one step closer to that reality.

If you’re interested in this stuff, I would love to get your input on this and collaborate. Development for all of this is happening here: GitHub - LaurentRDC/distributed-consensus: Haskell implementation of distributed consensus protocols with built-in support for deterministic simulation testing · GitHub


r/haskell • • 15h ago

The Bowling Game - From Imperative to Functional Programming - Part 4

Thumbnail fpilluminated.org
10 Upvotes

r/haskell • • 1d ago

blog [Well-Typed] Exception Best Practices

Thumbnail well-typed.com
46 Upvotes

r/haskell • • 2d ago

Haskell Dataframe is now in DuckDB’s `Database-like ops benchmark

40 Upvotes

https://duckdblabs.github.io/db-benchmark

Often get questions about performance. This benchmark seemed like a great place to start since other language's DataFrame implementations are well represented there. Working a follow up blog post/experience report about optimizing Haskell for data engineering in general: the architecture of the implementation, learnings from other ecosystems, and the usual gotchas of writing performant Haskell (mostly the safety/performance tradeoff).


r/haskell • • 1d ago

[ANN] pgfmt Format your hasql-th blocks (or any other SQL file)

7 Upvotes

We have been using this SQL formatter at work that we built in house. With the help of an LLM we managed to extract it from our code base and make it a proper tool for general use

pgfmt, a formatter for PostgreSQL SQL files and for the SQL inside Haskell hasql-th quasiquotes.

We've taken lots of care in making sure the formatter does not alter the meaning of the SQL it outputs. Before rewriting a statement, pgfmt parses the result with libpg_query (PostgreSQL's own parser) and compares parse trees. If they differ, the statement is left exactly as it was and pgfmt exits non-zero. We've run it over thousands of production migrations and hasql-th blocks.

The style it follows is quite arbitrarily our own preference. We never did agree in the end on what we liked, but after a while we just accepted the benefit of having a single style and the arguments were over.

For .hs files it formats the SQL inside singletonStatement, vectorStatement and the other hasql-th quoters, and leaves the Haskell alone, so it works alongside fourmolu or ormolu:

userEmails :: Statement Int64 (Vector (Text, Maybe Text))
userEmails =
    [vectorStatement|
      select u.name :: text, e.address :: text? from users u left join emails e on e.user_id = u.id where u.org_id = $1 :: int8 order by u.name
    |]

becomes

userEmails :: Statement Int64 (Vector (Text, Maybe Text))
userEmails =
    [vectorStatement|
        select
            u.name::text
          , e.address::text?
        from users u
        left join emails e
          on e.user_id = u.id
        where u.org_id = $1::int8
        order by u.name
    |]

It skips comments and string literals the way GHC's lexer does, so a quasiquote inside a string or a comment is never touched. Each quasiquote is only rewritten if it parses back to the same AST.

Other features:

  • SQL files: DDL, DML, and the SQL statements inside PL/pgSQL function bodies
  • --check for CI and pre-commit
  • --keyword-case lower|upper
  • --quoter NAME for your own quoter aliases

Try it:

nix run --accept-flake-config github:kronor-io/pgfmt -- --check src/**/*.hs

Feedback and issues are welcome: https://github.com/kronor-io/pgfmt


r/haskell • • 2d ago

blog Make the Plan a Value

Thumbnail jackkelly.name
26 Upvotes

r/haskell • • 4d ago

announcement I added Live Coding to my Haskell Game Engine!

Post image
70 Upvotes

As the title says, I've just released a new version of Mischief (my free, open source, ECS-based game engine written in Haskell). It features a new library, mischief-live, which lets you hot-reload code from a targeted library. Internally, it does some hint magic to run an interpreter in the background and cache its results.

You can find two full videos in which I play around with this here and here.

Feel free to join the official discord server to be kept up to date with updates, chat with others, and support Mischief.

Check the official documentation for more information on what Mischief is and how to use it.

Also, reminder that absolutely no LLMs or other generative AI was used when making Mischief and the community and project have a strict no-AI policy :)


r/haskell • • 4d ago

I made a toy lisp in Haskell!

Thumbnail reddit.com
19 Upvotes

r/haskell • • 4d ago

A higher-level abstraction for music, with Haskell (w/ Sandy Maguire)

Thumbnail youtu.be
37 Upvotes

Music, Haskell, FRP, abstractions, functors, Yoneda, continuation monad, Sandy Maguire. Enjoy.


r/haskell • • 4d ago

job [Hire Me] Mid-level Haskell Developer Open to Remote Opportunities

57 Upvotes

Hey everyone!

I'm a software developer with around 20 years of experience across different technologies, and I've been working professionally with Haskell on backend systems.

My most recent Haskell project involved building and maintaining backend services, working with APIs, databases, and production infrastructure.

While I have extensive experience in software engineering, I'd describe myself as a mid-level Haskell developer. I'm comfortable building real-world applications with Haskell, but I also recognize there's plenty more to learn in its ecosystem.

I'm currently looking for new opportunities where I can contribute to a team, continue growing as a Haskell developer, and work on interesting problems.

A little about me:

Strong background in backend development and software architecture

Professional experience with Haskell, including production applications

Experience with PostgreSQL, SQLite, Docker, Nix, AWS, and distributed systems

Comfortable working independently or as part of a remote team

Based in Türkiye, open to remote opportunities worldwide

You can find more about me and my work at https://emre.xyz. and my resume is in https://emre.xyz/resume.pdf

If your team is hiring, or you know someone looking for a Haskell developer, I'd be happy to chat.

Thanks, and happy hacking!


r/haskell • • 4d ago

Derivative flipping

Thumbnail blog.sigfpe.com
24 Upvotes

r/haskell • • 5d ago

What is your take on John Backus’s assertion that the FP (point-free) style is, in his view, more advantageous than the lambda calculus?

40 Upvotes

[Backus1981a] took up the lambda style (e.g., LISP [McCarthy1960] and Landin's ISWIM [Landin1964]): "In general, we suggest that the FP style offers a framework in which one can perceive and reason about program structures, truths, and transformations at a higher level of generality than that presently available for reasoning about lambda style programs." He acknowledged that using lambda abstraction one can define all of the FP program forming operations and "an infinity of others," but argued that this power would lead to undisciplined use and concluded: "Therefore perhaps it is time to begin designing a new generation of functional languages, languages that emphasize function level structure and function level reasoning."


r/haskell • • 8d ago

blog Massiv vs. Accelerate: Two Paths to High-Performance CPU Computing in Haskell

30 Upvotes

Python and C/C++ tend to get most of the attention when it comes to high-performance array processing, but Haskell has some interesting options too. We took a closer look at two Haskell libraries, Massiv and Accelerate, to see how they compare in terms of performance, memory usage, and overall trade-offs.

A few months ago, we wrote a blog about this. Here's the comparison, including benchmarks and implementation details if it's helpful for anyone: https://www.stackbuilders.com/insights/massiv-vs-accelerate-two-paths-to-high-performance-cpu-computing-in-haskell/

Has anyone here used Massiv or Accelerate in their projects? Curious to hear about your experience and whether you've seen some of the same kind of results.


r/haskell • • 8d ago

Where do I start as a mathematician?

55 Upvotes

Hello!
I am a mathematician doing heavy category (and quasi-category) theory. I want to start programming in Haskell. Since my background in programming is not that wide (Some basic courses in python) I need to study it, in some sense, as a beginner programmer. At the same time, I want to take advantage of my math background, so I would like to also study as someone who already knows category theory. But again- also as a beginner programmer. Are there any sources or books that fit to it?


r/haskell • • 9d ago

datomlite - A zero-dep, Datomic-style "DB-as-a-value" you can drop into your Haskell apps... (Looking for feedback!)

24 Upvotes

Hello! Been tinkering on datomlite for a while, and it should be about ready for trials ... would love your sharp eyes on how the "typed datalog-style" API feels and if you see any glaring performance weak seams.


r/haskell • • 9d ago

Community suggestion on Prelude replacement

18 Upvotes

I am trying to weigh options on if a Prelude replacement is needed and if so, which one.?

I see a lot prelude replacements are naintained by small companies or one or two person shops. And some preludes like classy prleude are dead and obsolete?

What is preventing the GHC maintainers from adopting the learnings from the prelude replacements? I understand backward compatibility is a big concern, but new improved functions and types cn be added to new modules and re exported?​​​


r/haskell • • 10d ago

A B compiler written in Haskell. Looking for code reviews.

28 Upvotes

This is my first ever compiler (Maybe second if I wanna consider that semi-serious assignment in Uni on a C compiler) and also my first major project with Haskell. Before this, I mainly did Hackerrank and a couple of advent of code with Haskell.

The Lexer, Parser and semantic analyser/IRGen is written in Haskell, and it targets the QBE backend.

Repo - https://github.com/SBaori/B

Looking for feedback and code reviews on good practices missed, some idiomatic patterns in compiler development and general Haskell coding standards advice.

Comment on LLMs - Every single character in the repo is thought, reasoned and written by me. LLMs were only used for summarising the original B specification, learning some compiler theory and trying to extract/query some built-in functions from Haskell.


r/haskell • • 9d ago

In this approach, `StateT` modules are treated as independent functional units, which are then composed to build business applications. This method utilizes `liftIO` to vertically integrate `IO` action functions, serving as an alternative to the commonly used `ReaderT` pattern.

0 Upvotes

I watched the following video, which discusses the issue of "Transformer Hell" (the complexity arising from nested monad transformers) and proposes the use of "Algebraic Effects" as a solution:

https://www.youtube.com/watch?v=P3FmKp4HtSo

Intrigued, I experimented with the Haskell library `Polysemy`, but it did not provide the level of flexibility I had hoped for.

Since the core of functional programming lies in function composition, I began to wonder if the practice of composing monad transformers might actually undermine modularity.

Consequently, I propose a design in which `StateT` modules—built upon `IO`—are layered atop a `main` function that is also rooted in `IO`. This approach should help prevent structural complexity, even in large-scale programs. Furthermore, by standardizing the implementation patterns across modules, one can expect improvements in productivity, safety, and reusability.

With the assistance of Google Gemini and ChatGPT (for tasks such as debugging compilation errors), I developed and executed test code. When I asked both AIs to evaluate the design philosophy and the actual code, they concluded that "this design approach could serve as a highly viable architectural option for building enterprise-grade Haskell applications." I am sharing this in the hope that it might be useful to others.

As the full codebase is quite extensive, I have included only the parts related to `StateT` here. Please note that my previous post was removed for violating the terms of service due to the inclusion of AI-generated content. I would like to take this opportunity to offer my sincere apologies to Axman6 and 1rs, who left comments on that post.

Since 1rs expressed interest in the code, I have attached the section where `StateT` is implemented. Please note that this is an excerpt, as the full text is too long to include here.

■ IOEitherTest.hs

{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DuplicateRecordFields      #-}
{-# LANGUAGE OverloadedRecordDot        #-}

import Control.Monad
import Control.Monad.State.Strict
import Control.Monad.Except
import Data.Either
import Data.Decimal
import Data.Time
import Types.MessageType
import Types.MoneyType
import Types.CustomerType
import Types.ProductType
import Types.SellType
import Text.Show.Unicode

-- ==========   売上情報生成関数   ========== --

type MainPara = (CustId,[(ProdId, Quantity)])
type SellPara =          (ProdId, Quantity)
type SldtPara = (SldtNo,  ProdId, Quantity)
type RsSell   = Either ErrMsg Sell
type RsSldt   = Either ErrMsg Selldtl
type StSell   = StateT [ Sell ] IO ErrMsg
type StSldt   = StateT [RsSldt] IO ErrMsg

-- 売上明細の作成と明細一覧への追加
makeSells :: [MainPara] -> StateT [Sell] IO ErrMsg
makeSells sellparas = do
    sellList <- get
    (emsg, newList) <- liftIO $ flip runStateT sellList $ 
        forM sellparas $ \(cid, dtls) -> addSell cid dtls
    put  newList
    pure $ fmtErrMsg $ foldr (<>) (ErrMsg "") emsg

-- 売上伝票の作成と売上一覧への追加
addSell :: CustId -> [SellPara] -> StSell
addSell cid dtls = do
    let addSldtNo :: SldtNo -> SellPara -> SldtPara
        addSldtNo sldtno (prodid, quantity) =
                 (sldtno, prodid, quantity)
        dtails  = zipWith addSldtNo [firstSldtNo ..] dtls
    sellList    <- get
    slno        <- pure   $ getSellNo sellList
    now         <- liftIO $ getCurrentTime
    customer    <- liftIO $ getCustomer cid
    (emsg, dts) <- liftIO $ (`runStateT` [])
                            (addSelldtl slno dtails)
    let sell = mkSell slno  (utctDay now) (rights dts) customer
    case sell of
        Left  ermsg -> pure (ermsg <> emsg)
        Right rsell -> do
            put (sellList <> [rsell])
            pure emsg

-- 売上明細の作成と明細一覧への追加
addSelldtl :: SellNo -> [SldtPara] -> StSldt
addSelldtl slno dtls = do
    detail <- liftIO $ forM dtls $
        \(sldtno, prodid, quantity) -> do
            product <- getProduct prodid
            pure $ mkSelldtl slno sldtno quantity product
    put  detail
    pure $ foldr (<>) (ErrMsg "") (lefts detail)

-- ==========   試験用アクション   ========== --

main :: IO ()
main = do
    let sellList = [] :: [Sell]
        keyEnt = [((CustId 1),[((ProdId 1),(Quantity  5))
                              ,((ProdId 2),(Quantity 10))
                              ])
                 ,((CustId 2),[((ProdId 2),(Quantity 10))
                              ,((ProdId 3),(Quantity  1))
                              ])
                 ,((CustId 3),[((ProdId 1),(Quantity  5))
                              ,((ProdId 3),(Quantity  1))
                              ])
                 ,((CustId 1),[])
                 ,((CustId 4),[((ProdId 2),(Quantity 10))
                              ,((ProdId 3),(Quantity  1))
                              ])
                 ]
    (errs, slist) <- (`runStateT` sellList) (makeSells keyEnt)
    uprint errs
    uprint slist

-- λ>main
-- ErrMsg "CustNm \"IBM\" Selldtl's cont is 0. ||
--         Customer not found: CustId 4"
-- [ Sell { sellNo = SellNo 1
--        , sellDt = SellDt 2026-11-16
--        , custId = CustId 1
--        , custNm = CustNm "IBM"
--        , ttlAmt = TtlAmount 170
--        , taxRt = TaxRate 10
--        , taxAmt = TaxAmount 17
--        , allAmt = AllAmount 187
--        , selDtl = [ Selldtl { sellNo = SellNo 1
--                             , sldtNo = SldtNo 1
--                             , prodId = ProdId 1
--                             , prodNm = ProdNm "pencil"
--                             , prodPr = Price 30
--                             , sldtQt = Quantity 5
--                             , amount = Amount 150
--                             }
--                   , Selldtl { sellNo = SellNo 1
--                             , sldtNo = SldtNo 2
--                             , prodId = ProdId 2
--                             , prodNm = ProdNm "Paper"
--                             , prodPr = Price 2
--                             , sldtQt = Quantity 10
--                             , amount = Amount 20
--                             }
--                    ]
--        }
-- , Sell { sellNo = SellNo 2
--        , sellDt = SellDt 2026-11-16
--        , custId = CustId 2
--        , custNm = CustNm "Apple"
--        , ttlAmt = TtlAmount 120
--        , taxRt = TaxRate 10
--        , taxAmt = TaxAmount 12
--        , allAmt = AllAmount 132
--        , selDtl = [ Selldtl { sellNo = SellNo 2
--                             , sldtNo = SldtNo 1
--                             , prodId = ProdId 2
--                             , prodNm = ProdNm "Paper"
--                             , prodPr = Price 2
--                             , sldtQt = Quantity 10
--                             , amount = Amount 20
--                             }
--                   , Selldtl { sellNo = SellNo 2
--                             , sldtNo = SldtNo 2
--                             , prodId = ProdId 3
--                             , prodNm = ProdNm "eraser"
--                              , prodPr = Price 100
--                             , sldtQt = Quantity 1
--                             , amount = Amount 100
--                             }
--                   ]
--        }
-- , Sell { sellNo = SellNo 3
--        , sellDt = SellDt 2026-11-16
--        , custId = CustId 3
--        , custNm = CustNm "Fujitsu"
--        , ttlAmt = TtlAmount 250
--        , taxRt = TaxRate 10
--        , taxAmt = TaxAmount 25
--        , allAmt = AllAmount 275
--        , selDtl = [ Selldtl { sellNo = SellNo 3
--                             , sldtNo = SldtNo 1
--                             , prodId = ProdId 1
--                             , prodNm = ProdNm "pencil"
--                             , prodPr = Price 30
--                             , sldtQt = Quantity 5
--                             , amount = Amount 150
--                             }
--                   , Selldtl { sellNo = SellNo 3
--                             , sldtNo = SldtNo 2
--                             , prodId = ProdId 3
--                             , prodNm = ProdNm "eraser"
--                             , prodPr = Price 100
--                             , sldtQt = Quantity 1
--                             , amount = Amount 100
--                             }
--                   ]
--        }
-- ]

r/haskell • • 10d ago

IDE development for a language/compiler written in Haskell

26 Upvotes

Hello everyone. So I am doing my undergraduate thesis and I have made a langauge. After our first graded defense, the panels recommended that I build an IDE. Reason because for non technical people (including CS people who's not familiar with PL) it's the best way for them to understand and appreciate the thesis. I am yet to do my research on IDE development. I already have the impression that I will create an LSP. I am wondering if there's a documented and easy but stable way of building an IDE using Haskell as well (since my compiler is in Haskell already maybe it will make it easier). I'm curious to hear opinions on people who have done this already. Thanks.


r/haskell • • 10d ago

How do you get stack to output a shared library in the project root directory.

5 Upvotes

I'm trying to write a haskell library that will be called up by a lisp script. So far I think I've gotten it to compile to a shared library (I think) but I don't know how to get it to save the shared object to where I want it. I tried using the -o option in ghc-options for the library in package.yaml but then it complains that there's no Main module.


r/haskell • • 11d ago

blog Cross-compiling Haskell: running Template Haskell on the build machine

28 Upvotes

Cross-compiling a Haskell library becomes more complicated when compiling it also means executing Haskell. A small deriveJSON splice can turn an otherwise ordinary cross build into a job that needs a target interpreter, an emulator, or access to a device.

The experiment in template-haskell-cross explores another arrangement: execute Template Haskell with a native compiler on the build machine, then pass its results to the cross compiler. The implementation combines a GHC plugin, a native worker process, a binary protocol, and Nix helpers. It has been used to build a Haskell library with generated FFI exports for an Android application.

This article follows that experiment: why the usual execution model makes cross builds difficult, how the alternative works, what broke along the way, and which parts could inform GHC itself.

https://serokell.io/blog/cross-compiling-haskell-with-template-haskell


r/haskell • • 11d ago

announcement Haskell Interlude #89: Trevis Elser

Thumbnail haskell.foundation
25 Upvotes

Matti and Farhad are joined by Trevis Elser, chairman of the Stability Working Group, to talk about the working group, Haskell in industry, and what we can learn from senior Java engineers!