From 20f5d12462d721c432f651bc561fd53e82e4638e Mon Sep 17 00:00:00 2001
From: David Binder <binderd@informatik.uni-tuebingen.de>
Date: Tue, 11 Oct 2022 15:05:59 +0200
Subject: [PATCH] Split executable from library

---
 app/Main.hs    |  6 ++++++
 hpc-bin.cabal  | 21 +++++++++++++++------
 src/HpcMain.hs |  1 +
 3 files changed, 22 insertions(+), 6 deletions(-)
 create mode 100644 app/Main.hs

diff --git a/app/Main.hs b/app/Main.hs
new file mode 100644
index 0000000..3624342
--- /dev/null
+++ b/app/Main.hs
@@ -0,0 +1,6 @@
+module Main where
+
+import qualified HpcMain as HPC
+
+main :: IO ()
+main = HPC.main
\ No newline at end of file
diff --git a/hpc-bin.cabal b/hpc-bin.cabal
index 2a16832..df43362 100644
--- a/hpc-bin.cabal
+++ b/hpc-bin.cabal
@@ -22,11 +22,11 @@ Flag build-tool-depends
     Description: Use build-tool-depends
     Default: True
 
-executable hpc
-    Default-Language: Haskell2010
+library
+    default-language: Haskell2010
     hs-source-dirs: src
-    Main-Is: HpcMain.hs
-    Other-Modules: HpcParser
+    exposed-modules: 
+                   HpcParser
                    HpcCombine
                    HpcDraft
                    HpcFlags
@@ -36,11 +36,12 @@ executable hpc
                    HpcReport
                    HpcShowTix
                    HpcUtils
-                   Paths_hpc_bin
+                   HpcMain
 
+    other-modules: Paths_hpc_bin
     autogen-modules: Paths_hpc_bin
 
-    Build-Depends: base       >= 4   && < 5,
+    build-depends: base       >= 4   && < 5,
                    directory  >= 1   && < 1.4,
                    filepath   >= 1   && < 1.5,
                    containers >= 0.1 && < 0.7,
@@ -49,3 +50,11 @@ executable hpc
 
     if flag(build-tool-depends)
       build-tool-depends: happy:happy >= 1.20.0
+
+executable hpc
+    default-language: Haskell2010
+    hs-source-dirs: app
+    main-is: Main.hs
+
+    build-depends: base >= 4 && < 5,
+                   hpc-bin
diff --git a/src/HpcMain.hs b/src/HpcMain.hs
index f7617ec..13069ef 100644
--- a/src/HpcMain.hs
+++ b/src/HpcMain.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE ScopedTypeVariables, TupleSections #-}
+module HpcMain ( main ) where
 -- (c) 2007 Andy Gill
 
 -- Main driver for Hpc
-- 
GitLab