summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Wignall <brianwignall@gmail.com>2019-11-08 15:19:13 (GMT)
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-11-09 23:04:57 (GMT)
commit1f911de4c73d119be58c7868d0af060055ab447d (patch)
tree27e4cb6a4e4b9505390097d5dbb1e541282f4306
parent1f98e47df40ae84423283bf2e06ffe7a0b4a9381 (diff)
downloadghc-1f911de4c73d119be58c7868d0af060055ab447d.zip
ghc-1f911de4c73d119be58c7868d0af060055ab447d.tar.gz
ghc-1f911de4c73d119be58c7868d0af060055ab447d.tar.bz2
Add IsList instance for ZipList (closes #17433)
-rwxr-xr-xlibraries/base/GHC/Exts.hs10
1 files changed, 9 insertions, 1 deletions
diff --git a/libraries/base/GHC/Exts.hs b/libraries/base/GHC/Exts.hs
index 47392ad..45f6705 100755
--- a/libraries/base/GHC/Exts.hs
+++ b/libraries/base/GHC/Exts.hs
@@ -113,6 +113,8 @@ import Data.Ord
import Data.Version ( Version(..), makeVersion )
import qualified Debug.Trace
+import Control.Applicative (ZipList(..))
+
-- XXX This should really be in Data.Tuple, where the definitions are
maxTupleSize :: Int
maxTupleSize = 62
@@ -209,6 +211,12 @@ instance IsList [a] where
fromList = id
toList = id
+-- | @since
+instance IsList (ZipList a) where
+ type (Item (ZipList a)) = a
+ fromList = ZipList
+ toList (ZipList as) = as
+
-- | @since 4.9.0.0
instance IsList (NonEmpty a) where
type Item (NonEmpty a) = a
@@ -261,7 +269,7 @@ atomicModifyMutVar# mv f s =
-- 'SmallMutableArray#' is either the original 'SmallMutableArray#'
-- resized in-place or, if not possible, a newly allocated
-- 'SmallMutableArray#' with the original content copied over.
---
+--
-- To avoid undefined behaviour, the original 'SmallMutableArray#' shall
-- not be accessed anymore after a 'resizeSmallMutableArray#' has been
-- performed. Moreover, no reference to the old one should be kept in order