Question

I have a problem with generating GADTs with template Haskell. The problem is that I can't get the code to compile completely. GHCI does not terminate when loading the file and a ghc process uses much memory and cpu as it can get (2.4GB, 50~70%).

I tried to make a minimal example in which it still happens. It does not matter if I use the oxford notation ([| |]) or build the function by applying the TH datatypes by hand. Consider this simple module:

{-# LANGUAGE GADTs, TemplateHaskell #-}
module Test where
$( [d| data Test a where
         T :: Test String
     |] )

I'm using GHC 7.4.2 on OSX Mountain Lion from the Haskell Platform for x64.

Does anyone have an idea why this happens? Maybe I'm using some code incorrectly?

Was it helpful?

Solution

Turns out that on my 32bit Ubuntu machine with GHC 7.4.2 32bit the code runs correctly. So my guess was that the problem lies either in the difference in OS or processor architecture.

After installing the 32bit Haskell platform the code compiles. Guess this is a bug in the compiler. I'll try to file a bug for this as well. Should this be done with GHC or template haskell?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top