From e0bc46b891608f7e50223443d03a849fd16ac84d Mon Sep 17 00:00:00 2001
From: David Terei <code@davidterei.com>
Date: Mon, 8 Dec 2014 22:03:15 -0800
Subject: [PATCH] More fixes for Safe Haskell bounds under GHC 7.10

---
 System/Posix/ByteString/FilePath.hsc             | 5 ++++-
 System/Posix/Directory/Common.hsc                | 4 +++-
 System/Posix/DynamicLinker.hsc                   | 4 +++-
 System/Posix/DynamicLinker/ByteString.hsc        | 5 ++++-
 System/Posix/DynamicLinker/Common.hsc            | 4 +++-
 System/Posix/DynamicLinker/Module/ByteString.hsc | 5 ++++-
 System/Posix/Env/ByteString.hsc                  | 4 ++++
 System/Posix/Error.hs                            | 4 +++-
 System/Posix/Files.hsc                           | 4 +++-
 System/Posix/Files/ByteString.hsc                | 4 +++-
 System/Posix/IO/Common.hsc                       | 5 ++++-
 System/Posix/Process.hsc                         | 4 +++-
 System/Posix/Process/ByteString.hsc              | 5 ++++-
 System/Posix/Resource.hsc                        | 4 +++-
 System/Posix/Semaphore.hsc                       | 4 +++-
 System/Posix/Signals/Exts.hsc                    | 5 +++++
 System/Posix/Terminal.hsc                        | 4 +++-
 System/Posix/Terminal/ByteString.hsc             | 4 +++-
 System/Posix/Time.hsc                            | 4 +++-
 System/Posix/Unistd.hsc                          | 4 +++-
 20 files changed, 68 insertions(+), 18 deletions(-)

diff --git a/System/Posix/ByteString/FilePath.hsc b/System/Posix/ByteString/FilePath.hsc
index 2b1382d..5e3692a 100644
--- a/System/Posix/ByteString/FilePath.hsc
+++ b/System/Posix/ByteString/FilePath.hsc
@@ -1,6 +1,9 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
+
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.ByteString.FilePath
diff --git a/System/Posix/Directory/Common.hsc b/System/Posix/Directory/Common.hsc
index ea43c5c..4ea8f78 100644
--- a/System/Posix/Directory/Common.hsc
+++ b/System/Posix/Directory/Common.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 
diff --git a/System/Posix/DynamicLinker.hsc b/System/Posix/DynamicLinker.hsc
index b15f507..a2b7336 100644
--- a/System/Posix/DynamicLinker.hsc
+++ b/System/Posix/DynamicLinker.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------
diff --git a/System/Posix/DynamicLinker/ByteString.hsc b/System/Posix/DynamicLinker/ByteString.hsc
index b13c808..2111aa2 100644
--- a/System/Posix/DynamicLinker/ByteString.hsc
+++ b/System/Posix/DynamicLinker/ByteString.hsc
@@ -1,6 +1,9 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
+
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.DynamicLinker.ByteString
diff --git a/System/Posix/DynamicLinker/Common.hsc b/System/Posix/DynamicLinker/Common.hsc
index ff36a28..8a44d95 100644
--- a/System/Posix/DynamicLinker/Common.hsc
+++ b/System/Posix/DynamicLinker/Common.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------
diff --git a/System/Posix/DynamicLinker/Module/ByteString.hsc b/System/Posix/DynamicLinker/Module/ByteString.hsc
index 325dae3..d5973a8 100644
--- a/System/Posix/DynamicLinker/Module/ByteString.hsc
+++ b/System/Posix/DynamicLinker/Module/ByteString.hsc
@@ -1,6 +1,9 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
+
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.DynamicLinker.Module.ByteString
diff --git a/System/Posix/Env/ByteString.hsc b/System/Posix/Env/ByteString.hsc
index 9f69c4c..9217525 100644
--- a/System/Posix/Env/ByteString.hsc
+++ b/System/Posix/Env/ByteString.hsc
@@ -1,6 +1,10 @@
 #ifdef __GLASGOW_HASKELL__
 {-# LANGUAGE Trustworthy #-}
+#if __GLASGOW_HASKELL__ >= 709
+{-# OPTIONS_GHC -fno-warn-trustworthy-safe #-}
 #endif
+#endif
+
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.Env.ByteString
diff --git a/System/Posix/Error.hs b/System/Posix/Error.hs
index db4b5a9..d3b10a7 100644
--- a/System/Posix/Error.hs
+++ b/System/Posix/Error.hs
@@ -1,5 +1,7 @@
 {-# LANGUAGE CPP #-}
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------
diff --git a/System/Posix/Files.hsc b/System/Posix/Files.hsc
index 6aea6a9..b18a8df 100644
--- a/System/Posix/Files.hsc
+++ b/System/Posix/Files.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 {-# LANGUAGE CApiFFI #-}
diff --git a/System/Posix/Files/ByteString.hsc b/System/Posix/Files/ByteString.hsc
index 0d19ae8..3f26f73 100644
--- a/System/Posix/Files/ByteString.hsc
+++ b/System/Posix/Files/ByteString.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 {-# LANGUAGE CApiFFI #-}
diff --git a/System/Posix/IO/Common.hsc b/System/Posix/IO/Common.hsc
index 8de0ac0..198b3f1 100644
--- a/System/Posix/IO/Common.hsc
+++ b/System/Posix/IO/Common.hsc
@@ -1,7 +1,10 @@
 {-# LANGUAGE NondecreasingIndentation, RecordWildCards #-}
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
+
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.IO.Common
diff --git a/System/Posix/Process.hsc b/System/Posix/Process.hsc
index 7d356c1..42426a3 100644
--- a/System/Posix/Process.hsc
+++ b/System/Posix/Process.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------
diff --git a/System/Posix/Process/ByteString.hsc b/System/Posix/Process/ByteString.hsc
index 294970e..ee2c9cf 100644
--- a/System/Posix/Process/ByteString.hsc
+++ b/System/Posix/Process/ByteString.hsc
@@ -1,6 +1,9 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
+
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.Process.ByteString
diff --git a/System/Posix/Resource.hsc b/System/Posix/Resource.hsc
index b610f5b..4c5ca48 100644
--- a/System/Posix/Resource.hsc
+++ b/System/Posix/Resource.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------
diff --git a/System/Posix/Semaphore.hsc b/System/Posix/Semaphore.hsc
index 541bbdb..02959ae 100644
--- a/System/Posix/Semaphore.hsc
+++ b/System/Posix/Semaphore.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------
diff --git a/System/Posix/Signals/Exts.hsc b/System/Posix/Signals/Exts.hsc
index f539245..a889340 100644
--- a/System/Posix/Signals/Exts.hsc
+++ b/System/Posix/Signals/Exts.hsc
@@ -1,6 +1,11 @@
 #ifdef __GLASGOW_HASKELL__
+#if defined(SIGINFO) || defined(SIGWINCH)
 {-# LANGUAGE Trustworthy #-}
+#else
+{-# LANGUAGE Safe #-}
 #endif
+#endif
+
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.Signals.Exts
diff --git a/System/Posix/Terminal.hsc b/System/Posix/Terminal.hsc
index be2d040..c8335a6 100644
--- a/System/Posix/Terminal.hsc
+++ b/System/Posix/Terminal.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------
diff --git a/System/Posix/Terminal/ByteString.hsc b/System/Posix/Terminal/ByteString.hsc
index df851f5..fd44c85 100644
--- a/System/Posix/Terminal/ByteString.hsc
+++ b/System/Posix/Terminal/ByteString.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------
diff --git a/System/Posix/Time.hsc b/System/Posix/Time.hsc
index 91b8fad..a28050d 100644
--- a/System/Posix/Time.hsc
+++ b/System/Posix/Time.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------
diff --git a/System/Posix/Unistd.hsc b/System/Posix/Unistd.hsc
index afb8c08..2cbfaa2 100644
--- a/System/Posix/Unistd.hsc
+++ b/System/Posix/Unistd.hsc
@@ -1,6 +1,8 @@
 {-# LANGUAGE CApiFFI #-}
 {-# LANGUAGE NondecreasingIndentation #-}
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------
-- 
GitLab