Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Show comment
Hide comment
@sjoerdvisscher

sjoerdvisscher Oct 14, 2010

It works fine if you turn Loop into a newtype.

Owner

sjoerdvisscher commented Oct 14, 2010

It works fine if you turn Loop into a newtype.

@hesselink

This comment has been minimized.

Show comment
Hide comment
@hesselink

hesselink Oct 14, 2010

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

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

@sjoerdvisscher

This comment has been minimized.

Show comment
Hide comment
@sjoerdvisscher

sjoerdvisscher Oct 14, 2010

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

Owner

sjoerdvisscher commented Oct 14, 2010

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