Skip to content

Instantly share code, notes, and snippets.

@ramirez7
Created May 6, 2024 19:36
Show Gist options
  • Save ramirez7/3f671cb455310c5c3d41ab0c9f3a0eab to your computer and use it in GitHub Desktop.
Save ramirez7/3f671cb455310c5c3d41ab0c9f3a0eab to your computer and use it in GitHub Desktop.
Make an arbitrarily large Haskell error message (and make your computer very warm)
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -freduction-depth-0 #-}
import GHC.TypeLits
data N = Z | S N
type F :: Nat -> N
type family F n where
F 0 = Z
F n = S (F (n - 1))
data P a = P
x :: P Z
x = P @(F 10000)
@ramirez7
Copy link
Author

ramirez7 commented May 6, 2024

  • spew-error.hs is 311 + the length of the typelit
  • 10000 results in a 40202 character error message for a 316 character file. Ratio = 127.2.
  • 100000 results in a 400276 character error message for a 317 character file (and took hours to finish). Ratio = 1262.7.
  • So we can drive the ratio up as much as we want if we are willing to wait.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment