summaryrefslogtreecommitdiff
path: root/compiler/main/ErrUtils.hs
diff options
context:
space:
mode:
authorGreg Weber <greg@gregweber.info>2015-01-12 05:16:37 -0600
committerAustin Seipp <austin@well-typed.com>2015-01-13 10:10:38 -0600
commit07ace5c221adbb1675413a0fac300a9f7913c234 (patch)
treed00e7a658680ce0e2488f40ccbb4297708af1820 /compiler/main/ErrUtils.hs
parent0fa4240249058f327cfd283f9da2deb8dff664f1 (diff)
downloadhaskell-07ace5c221adbb1675413a0fac300a9f7913c234.tar.gz
add -th-file which generates a th.hs file
Summary: see Trac #8624 similar functionality is now available with -ddump-to-file -ddump-splices However, users are already accustomed to -ddump-splices having a particular format, and this format is not completely valid code The goal of -th-file is to dump valid Haskell code Additionally, the convention of -ddump-to-file is to name the file after the flag, so the file is .dump-splices Given that the goal of the new flag is to generate valid Haskell, The extension should be .hs Additionally, -ddump-to-file effects all other dump flags Test Plan: look at the output of using the -th-file flag and compare it to the output of using -ddump-to-file and -ddump-splices I want to add test cases, but just need some pointers on getting started there Reviewers: thomie, goldfire, simonpj, austin Reviewed By: simonpj, austin Subscribers: thomie, carter Differential Revision: https://phabricator.haskell.org/D518 GHC Trac Issues: #8624
Diffstat (limited to 'compiler/main/ErrUtils.hs')
-rw-r--r--compiler/main/ErrUtils.hs3
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/main/ErrUtils.hs b/compiler/main/ErrUtils.hs
index 20d628f312..82587d28bc 100644
--- a/compiler/main/ErrUtils.hs
+++ b/compiler/main/ErrUtils.hs
@@ -301,7 +301,7 @@ dumpSDoc dflags print_unqual flag hdr doc
chooseDumpFile :: DynFlags -> DumpFlag -> Maybe String
chooseDumpFile dflags flag
- | gopt Opt_DumpToFile dflags
+ | gopt Opt_DumpToFile dflags || flag == Opt_D_th_dec_file
, Just prefix <- getPrefix
= Just $ setDir (prefix ++ (beautifyDumpName flag))
@@ -325,6 +325,7 @@ chooseDumpFile dflags flag
-- | Build a nice file name from name of a GeneralFlag constructor
beautifyDumpName :: DumpFlag -> String
+beautifyDumpName Opt_D_th_dec_file = "th.hs"
beautifyDumpName flag
= let str = show flag
suff = case stripPrefix "Opt_D_" str of