[Haskell-cafe] Re: is there a way to pretty print a module?

Bertram Felgenhauer bertram.felgenhauer at googlemail.com
Thu Oct 30 17:39:52 EDT 2008


Jason Dagit wrote:
> Could you use haskell-src from TH and then unsafePerformIO to get the
> reading to work during compile time?  I've done something like this in
> the past with Language.Haskell and TH.  I described it here:
> http://blog.codersbase.com/2006/09/01/simple-unit-testing-in-haskell/
> 
> Maybe someone who has studied more TH knows a way to remove the unsafePerformIO.


Replace

  tests :: [String]
  tests = unsafePerformIO $

by

  tests :: Q [String]
  tests = runIO $

and

  $(mkChecks tests)

by

  $(mkChecks =<< tests)

(The Q monad should really have an MonadIO instance.)

HTH,

Bertram


More information about the Haskell-Cafe mailing list