From 5c9aedaab722490077883869ae80175ee25431dd Mon Sep 17 00:00:00 2001 From: Edward Kmett Date: Wed, 5 Jun 2019 17:52:56 -0400 Subject: [PATCH] backport pattern synonym --- Data/ByteString/Internal.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Data/ByteString/Internal.hs b/Data/ByteString/Internal.hs index 7ecce7c72..c833bc17b 100644 --- a/Data/ByteString/Internal.hs +++ b/Data/ByteString/Internal.hs @@ -1,7 +1,7 @@ {-# LANGUAGE CPP, ForeignFunctionInterface, BangPatterns #-} {-# LANGUAGE UnliftedFFITypes, MagicHash, UnboxedTuples, DeriveDataTypeable #-} -#if __GLASGOW_HASKELL__ >= 806 +#if __GLASGOW_HASKELL__ >= 800 {-# LANGUAGE PatternSynonyms, ViewPatterns #-} #endif #if __GLASGOW_HASKELL__ >= 703 @@ -31,7 +31,7 @@ module Data.ByteString.Internal ( -- * The @ByteString@ type and representation ByteString ( BS -#if __GLASGOW_HASKELL__ >= 806 +#if __GLASGOW_HASKELL__ >= 800 , PS -- backwards compatibility shim #endif ), -- instances: Eq, Ord, Show, Read, Data, Typeable @@ -180,10 +180,9 @@ data ByteString = BS {-# UNPACK #-} !(ForeignPtr Word8) -- payload deriving (Typeable) -#if __GLASGOW_HASKELL__ >= 806 --- on GHC-8.0 ... 8.6: Pattern synonym definition cannot contain as-patterns (@) +#if __GLASGOW_HASKELL__ >= 800 pattern PS :: ForeignPtr Word8 -> Int -> Int -> ByteString -pattern PS fp o len <- BS fp len@(const 0 -> o) where +pattern PS fp zero len <- BS fp (((,) 0) -> (zero, len)) where PS fp o len = BS (plusForeignPtr fp o) len #endif