From 463fc49d17bfab846cceba48bccc02ef285e6cba Mon Sep 17 00:00:00 2001
From: Judah Jacobson <judah@users.noreply.github.com>
Date: Fri, 3 Jan 2020 03:23:18 -0800
Subject: [PATCH] Add a flag to disable the example executable (and test).

GHC's build currently can't handle packages with both a library and
a binary.  Help out by allowing a build to disable the executable,
which is only needed for the test.  (So disable the test as well.)

Also bump the version to 0.8.0.1.
---
 Changelog       |  3 +++
 haskeline.cabal | 18 ++++++++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index 8467aa3..e36e09d 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,6 @@
+Changed in version 0.8.0.1:
+   * Add a Cabal flag to disable the example executable as well as
+     the test that uses it.
 Changed in version 0.8.0.0:
    * Breaking changes:
      * Add a `MonadFail` instance for `InputT`.
diff --git a/haskeline.cabal b/haskeline.cabal
index 0b0ce10..d5c4419 100644
--- a/haskeline.cabal
+++ b/haskeline.cabal
@@ -1,6 +1,6 @@
 Name:           haskeline
 Cabal-Version:  >=1.10
-Version:        0.8.0.0
+Version:        0.8.0.1
 Category:       User Interfaces
 License:        BSD3
 License-File:   LICENSE
@@ -38,6 +38,13 @@ flag terminfo
     Default: True
     Manual: True
 
+-- Help the GHC build by making it possible to disable the extra binary.
+-- TODO: Make GHC handle packages with both a library and an executable.
+flag examples
+    Description: Enable executable components used for tests.
+    Default: True
+    Manual: True
+
 Library
     -- We require ghc>=7.4.1 (base>=4.5) to use the base library encodings, even
     -- though it was implemented in earlier releases, due to GHC bug #5436 which
@@ -117,8 +124,12 @@ test-suite haskeline-tests
     hs-source-dirs: tests
     Default-Language: Haskell98
 
-    if os(windows)
+    if os(windows) {
         buildable: False
+    }
+    if !flag(examples) {
+        buildable: False
+    }
     Main-Is:    Unit.hs
     Build-depends: base, containers, text, bytestring, HUnit, process, unix
     Other-Modules: RunTTY, Pty
@@ -126,6 +137,9 @@ test-suite haskeline-tests
 
 -- The following program is used by unit tests in `tests` executable
 Executable haskeline-examples-Test
+    if !flag(examples) {
+        buildable: False
+    }
     Build-depends: base, containers, haskeline
     Default-Language: Haskell2010
     hs-source-dirs: examples
-- 
GitLab