Skip to content

Commit

Permalink
backport pattern synonym
Browse files Browse the repository at this point in the history
  • Loading branch information
ekmett committed Jun 5, 2019
1 parent d42e197 commit 5c9aeda
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Data/ByteString/Internal.hs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 5c9aeda

Please sign in to comment.