Skip to content

Instantly share code, notes, and snippets.

@sjoerdvisscher
Created October 14, 2010 11:29
Show Gist options
  • Save sjoerdvisscher/626056 to your computer and use it in GitHub Desktop.
Save sjoerdvisscher/626056 to your computer and use it in GitHub Desktop.
How to make ghc loop.
{-# LANGUAGE EmptyDataDecls #-}
data Empty
data Loop = CLoop (Loop -> Empty)
loop_step :: Loop -> Empty
loop_step b@(CLoop f) = f b
loop :: Empty
loop = loop_step (CLoop loop_step)
@sjoerdvisscher
Copy link
Author

It works fine if you turn Loop into a newtype.

@hesselink
Copy link

You don't even need the EmptyDataDecls; changing Empty to () loops as well. Did you file a bug?

@sjoerdvisscher
Copy link
Author

Apparently this is a known bug of the inliner. Adding NOINLINE fixes the problem.

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