packages feed

classy-prelude 0.2.0.1 → 1.5.0.3

raw patch · 18 files changed

Files

+ ChangeLog.md view
@@ -0,0 +1,132 @@+# ChangeLog for classy-prelude++## 1.5.0.3++* Don't import Data.Functor.unzip [#215](https://github.com/snoyberg/mono-traversable/pull/215)++## 1.5.0.2++* Fix building with time >= 1.10 [#207](https://github.com/snoyberg/mono-traversable/pull/207).++## 1.5.0.1++* Export a compatibility shim for `parseTime` as it has been removed in `time-1.10`.+  See <https://hackage.haskell.org/package/time-1.12/changelog>++## 1.5.0++* Removed `alwaysSTM` and `alwaysSucceedsSTM`. See+  <https://github.com/ghc-proposals/ghc-proposals/pull/77>++## 1.4.0++* Switch to `MonadUnliftIO`++## 1.3.1++* Add terminal IO functions++## 1.3.0++* Tracing functions leave warnings when used++## 1.2.0.1++* Use `HasCallStack` in `undefined`++## 1.2.0++* Don't generalize I/O functions to `IOData`, instead specialize to+  `ByteString`. See:+  http://www.snoyman.com/blog/2016/12/beware-of-readfile#real-world-failures++## 1.0.2++* Export `parseTimeM` for `time >= 1.5`++## 1.0.1++* Add the `say` package reexports+* Add the `stm-chans` package reexports++## 1.0.0.2++* Allow basic-prelude 0.6++## 1.0.0.1++* Support for safe-exceptions-0.1.4.0++## 1.0.0++* Support for mono-traversable-1.0.0+* Switch to safe-exceptions+* Add monad-unlift and lifted-async++## 0.12.8++* Add (<&&>),(<||>) [#125](https://github.com/snoyberg/classy-prelude/pull/125)++## 0.12.7++* Concurrency: reexport `Control.Concurrent.Lifted` and provide `yieldThread`++## 0.12.6++* Regeneralize intercalate [#119](https://github.com/snoyberg/classy-prelude/pull/119)+* Add missing exports for `traverse_` and `for_`+* Generalize `mapM_` and `forM_` for GHC 7.10++## 0.12.5.1++* Support for QuickCheck 2.8.2++## 0.12.5++* Expose `Alternative` and `optional`++## 0.12.4++* Expose `traverse_` and `for_`++## 0.12.3++* mono-traversable-0.9.3 support++## 0.12.2++add `errorM`, `terrorM`, and `terror`++## 0.12.0++* Drop system-filepath++## 0.11.1.1++* Compatibility with time >= 1.5 [#100](https://github.com/snoyberg/classy-prelude/pull/100)++## 0.11.1++* Fix deprecation warnings for `elem`++## 0.11.0++* Upgrade to mutable-containers 0.3+* Include dlist support++## 0.10.5++* Export `Data.Mutable`++## 0.10.4++* Expose all of Data.Functor++## 0.10.3++* Expose `liftA` functions and `<**>` [#94](https://github.com/snoyberg/classy-prelude/pull/94)++## 0.10.2++* Provide `foldMap` and `fold` as synonyms for `concatMap` and `concat`.+* Switch to more general `Traversable`-based functions (`sequence_` in particular).
− ClassyPrelude.hs
@@ -1,101 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE TypeFamilies #-}-module ClassyPrelude-    ( -- * CorePrelude-      module CorePrelude-      -- * Non-standard-      -- ** List-like classes-    , map-    , concatMap-    , filter-    , length-    , singleton-    , null-    , pack-    , unpack-    , repack-    , fromList-    , toList-    , mapM-    , mapM_-    , stripPrefix-    , isPrefixOf-    , stripSuffix-    , isSuffixOf-    , isInfixOf-    , break-    , span-    , dropWhile-    , takeWhile-    , any-    , all-    , splitAt, take, drop-    , fold-    , words-    , unwords-    , lines-    , unlines-    , split-    , reverse-    , readMay-    , replicate-      -- ** Map-like-    , lookup-    , insert-    , delete-      -- ** Set-like-    , member-      -- ** Text-like-    , show-      -- ** Files-    , readFile-    , writeFile-    ) where--import qualified Prelude-import qualified Data.Maybe--import CorePrelude-import ClassyPrelude.Classes--import ClassyPrelude.ByteString ()-import ClassyPrelude.Classes ()-import ClassyPrelude.FilePath ()-import ClassyPrelude.HashMap ()-import ClassyPrelude.HashSet ()-import ClassyPrelude.LByteString ()-import ClassyPrelude.LText ()-import ClassyPrelude.List ()-import ClassyPrelude.Map ()-import ClassyPrelude.Set ()-import ClassyPrelude.Text ()-import ClassyPrelude.Vector ()--show :: (Prelude.Show a, CanPack c Char) => a -> c-show = pack . Prelude.show--fromList :: CanPack c i => [i] -> c-fromList = pack--toList :: CanPack c i => c -> [i]-toList = unpack---- Misc instances-instance CanPack (Prelude.Maybe a) a where-    pack = Data.Maybe.listToMaybe-    unpack = Data.Maybe.maybeToList--readMay :: (Prelude.Read b, CanPack a Char) => a -> Maybe b-readMay a =-    case [x | (x, t) <- Prelude.reads (unpack a), null t] of-        [x] -> Just x-        _ -> Nothing---- | Repack from one type to another, dropping to a list in the middle.------ @repack = pack . unpack@.-repack :: (CanPack a i, CanPack b i) => a -> b-repack = pack . unpack
− ClassyPrelude/ByteString.hs
@@ -1,55 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE TypeFamilies #-}-module ClassyPrelude.ByteString-    ( ByteString-    ) where--import qualified Prelude-import Prelude ((.))-import ClassyPrelude.Classes-import qualified Data.ByteString as S-import Data.ByteString (ByteString)-import Control.Monad.IO.Class (MonadIO, liftIO)-import qualified Filesystem.Path.CurrentOS as F-import Data.Word (Word8)--instance CanMapFunc ByteString ByteString Word8 Word8 where-    mapFunc = S.map-instance CanConcatMapFunc ByteString ByteString Word8 ByteString where-    concatMapFunc = S.concatMap-instance CanFilterFunc ByteString ByteString Word8 where-    filterFunc = S.filter-instance CanLength ByteString Prelude.Int where-    length = S.length-instance CanSingleton ByteString Word8 where-    singleton = S.singleton-instance CanNull ByteString where-    null = S.null-instance CanPack ByteString Word8 where-    pack = S.pack-    unpack = S.unpack-instance MonadIO m => CanReadFile (m ByteString) where-    readFile = liftIO . S.readFile . F.encodeString-instance CanWriteFileFunc ByteString where-    writeFileFunc fp = liftIO . S.writeFile (F.encodeString fp)-instance CanBreak ByteString Word8 where-    break = S.break-    span = S.span-    dropWhile = S.dropWhile-    takeWhile = S.takeWhile-instance CanAny ByteString Word8 where-    any = S.any-    all = S.all-instance CanSplitAt ByteString Prelude.Int where-    splitAt = S.splitAt--instance CanReverse ByteString where-    reverse = S.reverse--instance CanFoldFunc ByteString Word8 accum where-    foldFunc = S.foldl'--instance CanReplicate ByteString Word8 Prelude.Int where-    replicate = S.replicate
− ClassyPrelude/Classes.hs
@@ -1,138 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE TypeFamilies #-}-module ClassyPrelude.Classes where--import qualified Prelude-import Prelude (Monad)-import qualified Filesystem.Path.CurrentOS as F-import Control.Monad.IO.Class (MonadIO)--class CanMap f i o where-    map :: (i -> o) -> f-class CanMapFunc ci co i o | ci -> i, co -> o, ci o -> co, co i -> ci where-    mapFunc :: (i -> o) -> ci -> co-instance CanMapFunc ci co i o => CanMap (ci -> co) i o where-    map = mapFunc--class CanConcatMap f i o where-    concatMap :: (i -> o) -> f-class CanConcatMapFunc ci co i o | ci -> i, co -> o, ci o -> co, co i -> ci where-    concatMapFunc :: (i -> o) -> ci -> co-instance CanConcatMapFunc ci co i o => CanConcatMap (ci -> co) i o where-    concatMap = concatMapFunc--class CanFilter f i where-    filter :: (i -> Prelude.Bool) -> f-class CanFilterFunc ci co i | ci -> i co where-    filterFunc :: (i -> Prelude.Bool) -> ci -> co-instance (CanFilterFunc ci co i) => CanFilter (ci -> co) i where-    filter = filterFunc--class CanLength c len | c -> len where-    length :: c -> len--class CanSingleton c i | c -> i where-    singleton :: i -> c--class CanNull c where-    null :: c -> Prelude.Bool--class CanPack c i | c -> i where-    pack :: [i] -> c-    unpack :: c -> [i]--class Monad m => CanMapM f m i o where-    mapM :: (i -> m o) -> f-class Monad m => CanMapMFunc ci mco m i o | ci -> i, mco -> m o, ci o m -> mco, mco i -> ci where-    mapMFunc :: (i -> m o) -> ci -> mco-instance CanMapMFunc ci mco m i o => CanMapM (ci -> mco) m i o where-    mapM = mapMFunc--class Monad m => CanMapM_ f m i where-    mapM_ :: (i -> m o) -> f-class CanMapM_Func ci i | ci -> i where-    mapM_Func :: Monad m => (i -> m o) -> ci -> m ()-instance (Monad m, CanMapM_Func ci i, r ~ m ()) => CanMapM_ (ci -> r) m i where-    mapM_ = mapM_Func--class CanLookup c k v | c -> k v where-    lookup :: k -> c -> Prelude.Maybe v--class CanInsert f where-    insert :: f-class CanInsertVal c k v | c -> k v where-    insertVal :: k -> v -> c -> c-instance (CanInsertVal c' k v, c ~ c') => CanInsert (k -> v -> c -> c') where-    insert = insertVal--class CanDelete c k | c -> k where-    delete :: k -> c -> c--class CanMember c k | c -> k where-    member :: k -> c -> Prelude.Bool--class CanReadFile a where-    readFile :: F.FilePath -> a--class CanWriteFile a where-    writeFile :: F.FilePath -> a-class CanWriteFileFunc a where-    writeFileFunc :: MonadIO m => F.FilePath -> a -> m ()-instance (MonadIO m, b ~ (), CanWriteFileFunc a) => CanWriteFile (a -> m b) where-    writeFile = writeFileFunc--class CanStripPrefix a where-    stripPrefix :: a -> a -> Prelude.Maybe a-    isPrefixOf :: a -> a -> Prelude.Bool--class CanBreak c i | c -> i where-    break :: (i -> Prelude.Bool) -> c -> (c, c)-    span :: (i -> Prelude.Bool) -> c -> (c, c)-    dropWhile :: (i -> Prelude.Bool) -> c -> c-    takeWhile :: (i -> Prelude.Bool) -> c -> c--class CanAny c i | c -> i where-    any :: (i -> Prelude.Bool) -> c -> Prelude.Bool-    all :: (i -> Prelude.Bool) -> c -> Prelude.Bool--class CanSplitAt c i | c -> i where-    splitAt :: i -> c -> (c, c)--take :: CanSplitAt c i => i -> c -> c-take i c  = Prelude.fst (splitAt i c)-drop :: CanSplitAt c i => i -> c -> c-drop i c  = Prelude.snd (splitAt i c)--class CanFold f i accum where-    -- | Strict left fold.-    fold :: (accum -> i -> accum) -> accum -> f-class CanFoldFunc c i accum | c -> i where-    -- | Strict left fold.-    foldFunc :: (accum -> i -> accum) -> accum -> c -> accum-instance (CanFoldFunc c i accum, accum ~ result) => CanFold (c -> result) i accum where-    fold = foldFunc--class CanWords t where-    words :: t -> [t]-    unwords :: [t] -> t-    lines :: t -> [t]-    unlines :: [t] -> t--class CanSplit c i | c -> i where-    split :: (i -> Prelude.Bool) -> c -> [c]--class CanStripSuffix a where-    stripSuffix :: a -> a -> Prelude.Maybe a-    isSuffixOf :: a -> a -> Prelude.Bool--class CanIsInfixOf a where-    isInfixOf :: a -> a -> Prelude.Bool--class CanReverse a where-    reverse :: a -> a--class CanReplicate a i len | a -> i len where-    replicate :: len -> i -> a
− ClassyPrelude/FilePath.hs
@@ -1,20 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE TypeFamilies #-}-module ClassyPrelude.FilePath () where--import qualified Prelude-import Prelude ((.), Char)-import ClassyPrelude.Classes-import qualified Filesystem.Path.CurrentOS as F--instance CanPack F.FilePath Prelude.Char where-    pack = F.decodeString-    unpack = F.encodeString-instance CanStripPrefix F.FilePath where-    stripPrefix = F.stripPrefix-    isPrefixOf a b =-        case stripPrefix a b of-            Prelude.Nothing -> Prelude.False-            Prelude.Just{} -> Prelude.True
− ClassyPrelude/HashMap.hs
@@ -1,36 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE TypeFamilies #-}-module ClassyPrelude.HashMap-    ( HashMap-    ) where--import qualified Prelude-import Prelude ((.), Char)-import ClassyPrelude.Classes-import Data.HashMap.Strict (HashMap)-import qualified Data.HashMap.Strict as Map-import Data.Hashable (Hashable)--type Map = HashMap--instance CanMapFunc (Map k v1) (Map k v2) v1 v2 where-    mapFunc = Map.map-instance Hashable k => CanFilterFunc (Map k v) (Map k v) (k, v) where-    filterFunc = Map.filterWithKey . Prelude.curry-instance CanLength (Map k v) Prelude.Int where-    length = Map.size-instance (Prelude.Eq k, Hashable k, v' ~ v) => CanSingleton (v' -> Map k v) k where-    singleton = Map.singleton-instance CanNull (Map k v) where-    null = Map.null-instance (Prelude.Eq k, Hashable k) => CanPack (Map k v) (k, v) where-    pack = Map.fromList-    unpack = Map.toList-instance (Prelude.Eq k, Hashable k) => CanLookup (Map k v) k v where-    lookup = Map.lookup-instance (Prelude.Eq k, Hashable k) => CanInsertVal (Map k v) k v where-    insertVal = Map.insert-instance (Prelude.Eq k, Hashable k) => CanDelete (Map k v) k where-    delete = Map.delete
− ClassyPrelude/HashSet.hs
@@ -1,35 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE TypeFamilies #-}-module ClassyPrelude.HashSet-    ( HashSet-    ) where--import qualified Prelude-import Prelude ((.), Char, Eq)-import ClassyPrelude.Classes-import Data.HashSet (HashSet)-import qualified Data.HashSet as Set-import Data.Hashable (Hashable)--type Set = HashSet--instance (Eq b, Hashable b) => CanMapFunc (Set a) (Set b) a b where-    mapFunc = Set.map-instance CanLength (Set x) Prelude.Int where-    length = Set.size-instance Hashable x => CanSingleton (Set x) x where-    singleton = Set.singleton-instance CanNull (Set x) where-    null = Set.null-instance (Hashable x, Eq x) => CanPack (Set x) x where-    pack = Set.fromList-    unpack = Set.toList-instance (Eq x, Hashable x, Set x ~ s, x ~ x') => CanInsert (x' -> s -> Set x) where-    insert = Set.insert-instance (Eq x, Hashable x) => CanMember (Set x) x where-    member = Set.member--instance CanFoldFunc (Set a) a accum where-    foldFunc = Set.foldl'
− ClassyPrelude/LByteString.hs
@@ -1,57 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE TypeFamilies #-}-module ClassyPrelude.LByteString-    ( LByteString-    ) where--import qualified Prelude-import Prelude ((.))-import ClassyPrelude.Classes-import qualified Data.ByteString.Lazy as L-import Control.Monad.IO.Class (MonadIO, liftIO)-import qualified Filesystem.Path.CurrentOS as F-import Data.Word (Word8)-import Data.Int (Int64)--type LByteString = L.ByteString--instance CanMapFunc LByteString LByteString Word8 Word8 where-    mapFunc = L.map-instance CanConcatMapFunc LByteString LByteString Word8 LByteString where-    concatMapFunc = L.concatMap-instance CanFilterFunc LByteString LByteString Word8 where-    filterFunc = L.filter-instance CanLength LByteString Int64 where-    length = L.length-instance CanSingleton LByteString Word8 where-    singleton = L.singleton-instance CanNull LByteString where-    null = L.null-instance CanPack LByteString Word8 where-    pack = L.pack-    unpack = L.unpack-instance MonadIO m => CanReadFile (m LByteString) where-    readFile = liftIO . L.readFile . F.encodeString-instance CanWriteFileFunc LByteString where-    writeFileFunc fp = liftIO . L.writeFile (F.encodeString fp)-instance CanBreak LByteString Word8 where-    break = L.break-    span = L.span-    dropWhile = L.dropWhile-    takeWhile = L.takeWhile-instance CanAny LByteString Word8 where-    any = L.any-    all = L.all-instance CanSplitAt LByteString Int64 where-    splitAt = L.splitAt--instance CanReverse LByteString where-    reverse = L.reverse--instance CanFoldFunc LByteString Word8 accum where-    foldFunc = L.foldl'--instance CanReplicate LByteString Word8 Int64 where-    replicate = L.replicate
− ClassyPrelude/LText.hs
@@ -1,70 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE TypeFamilies #-}-module ClassyPrelude.LText-    ( LText-    ) where--import qualified Prelude-import Prelude ((.), Char)-import ClassyPrelude.Classes-import qualified Data.Text.Lazy as TL-import Data.Int (Int64)--type LText = TL.Text--instance CanMapFunc LText LText Char Char where-    mapFunc = TL.map-instance CanConcatMapFunc LText LText Char LText where-    concatMapFunc = TL.concatMap-instance CanFilterFunc LText LText Char where-    filterFunc = TL.filter-instance CanSingleton LText Prelude.Char where-    singleton = TL.singleton-instance CanNull LText where-    null = TL.null-instance CanPack LText Prelude.Char where-    pack = TL.pack-    unpack = TL.unpack-instance CanStripPrefix LText where-    stripPrefix = TL.stripPrefix-    isPrefixOf = TL.isPrefixOf-instance CanBreak LText Prelude.Char where-    break = TL.break-    span = TL.span-    dropWhile = TL.dropWhile-    takeWhile = TL.takeWhile-instance CanAny LText Prelude.Char where-    any = TL.any-    all = TL.all-instance CanSplitAt LText Int64 where-    splitAt = TL.splitAt--instance CanWords LText where-    words = TL.words-    unwords = TL.unwords-    lines = TL.lines-    unlines = TL.unlines--instance CanSplit LText Char where-    split = TL.split--instance CanStripSuffix LText where-    stripSuffix = TL.stripSuffix-    isSuffixOf = TL.isSuffixOf--instance CanIsInfixOf LText where-    isInfixOf = TL.isInfixOf--instance CanReverse LText where-    reverse = TL.reverse--instance CanLength LText Int64 where-    length = TL.length--instance CanFoldFunc LText Char accum where-    foldFunc = TL.foldl'--instance CanReplicate LText LText Int64 where-    replicate = TL.replicate
− ClassyPrelude/List.hs
@@ -1,68 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE TypeFamilies #-}-module ClassyPrelude.List () where--import qualified Prelude-import Prelude ((.))-import ClassyPrelude.Classes-import qualified Data.List--instance CanMapFunc [a] [b] a b where-    mapFunc = Prelude.map-instance CanConcatMapFunc [a] [b] a [b] where-    concatMapFunc = Prelude.concatMap-instance CanFilterFunc [a] [a] a where-    filterFunc = Prelude.filter-instance CanLength [a] Prelude.Int where-    length = Prelude.length-instance CanSingleton [a] a where-    singleton = Prelude.return-instance CanNull [a] where-    null = Prelude.null-instance CanPack [a] a where-    pack = Prelude.id-    unpack = Prelude.id-instance Prelude.Monad m => CanMapMFunc [i] (m [o]) m i o where-    mapMFunc = Prelude.mapM-instance CanMapM_Func [a] a where-    mapM_Func = Prelude.mapM_-instance Prelude.Eq k => CanLookup [(k, v)] k v where-    lookup = Prelude.lookup-instance Prelude.Eq k => CanInsertVal [(k, v)] k v where-    insertVal k v c = (k, v) : delete k c-instance Prelude.Eq k => CanDelete [(k, v)] k where-    delete k = filter ((Prelude./= k) . Prelude.fst)-instance Prelude.Eq x => CanMember [x] x where-    member x = Prelude.any (Prelude.== x)-instance Prelude.Eq a => CanStripPrefix [a] where-    stripPrefix = Data.List.stripPrefix-    isPrefixOf = Data.List.isPrefixOf-instance CanBreak [a] a where-    break = Prelude.break-    span = Prelude.span-    dropWhile = Prelude.dropWhile-    takeWhile = Prelude.takeWhile-instance CanAny [a] a where-    any = Prelude.any-    all = Prelude.all-instance CanSplitAt [c] Prelude.Int where-    splitAt = Prelude.splitAt-instance CanFoldFunc [a] a accum where-    foldFunc = Data.List.foldl'--instance (c ~ Prelude.Char) => CanWords [c] where-    words = Prelude.words-    unwords = Prelude.unwords-    lines = Prelude.lines-    unlines = Prelude.unlines--instance Prelude.Eq a => CanIsInfixOf [a] where-    isInfixOf = Data.List.isInfixOf--instance CanReverse [a] where-    reverse = Prelude.reverse--instance CanReplicate [i] i Prelude.Int where-    replicate = Prelude.replicate
− ClassyPrelude/Map.hs
@@ -1,33 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE TypeFamilies #-}-module ClassyPrelude.Map-    ( Map-    ) where--import qualified Prelude-import Prelude ((.), Char)-import ClassyPrelude.Classes-import Data.Map (Map)-import qualified Data.Map as Map--instance CanMapFunc (Map k v1) (Map k v2) v1 v2 where-    mapFunc = Map.map-instance Prelude.Ord k => CanFilterFunc (Map k v) (Map k v) (k, v) where-    filterFunc = Map.filterWithKey . Prelude.curry-instance CanLength (Map k v) Prelude.Int where-    length = Map.size-instance (v' ~ v) => CanSingleton (v' -> Map k v) k where-    singleton = Map.singleton-instance CanNull (Map k v) where-    null = Map.null-instance Prelude.Ord k => CanPack (Map k v) (k, v) where-    pack = Map.fromList-    unpack = Map.toList-instance Prelude.Ord k => CanLookup (Map k v) k v where-    lookup = Map.lookup-instance Prelude.Ord k => CanInsertVal (Map k v) k v where-    insertVal = Map.insert-instance Prelude.Ord k => CanDelete (Map k v) k where-    delete = Map.delete
− ClassyPrelude/Set.hs
@@ -1,32 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE TypeFamilies #-}-module ClassyPrelude.Set-    ( Set-    ) where--import qualified Prelude-import Prelude ((.), Char)-import ClassyPrelude.Classes-import Data.Set (Set)-import qualified Data.Set as Set--instance (Prelude.Ord a, Prelude.Ord b) => CanMapFunc (Set a) (Set b) a b where-    mapFunc = Set.map-instance CanLength (Set x) Prelude.Int where-    length = Set.size-instance CanSingleton (Set x) x where-    singleton = Set.singleton-instance CanNull (Set x) where-    null = Set.null-instance Prelude.Ord x => CanPack (Set x) x where-    pack = Set.fromList-    unpack = Set.toList-instance (Prelude.Ord x, Set x ~ s, x ~ x') => CanInsert (x' -> s -> Set x) where-    insert = Set.insert-instance Prelude.Ord x => CanMember (Set x) x where-    member = Set.member--instance CanFoldFunc (Set a) a accum where-    foldFunc = Set.foldl'
− ClassyPrelude/Text.hs
@@ -1,67 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE TypeFamilies #-}-module ClassyPrelude.Text-    ( Text-    ) where--import qualified Prelude-import Prelude ((.), Char)-import ClassyPrelude.Classes-import Data.Text (Text)-import qualified Data.Text as T--instance CanMapFunc Text Text Char Char where-    mapFunc = T.map-instance CanConcatMapFunc Text Text Char Text where-    concatMapFunc = T.concatMap-instance CanFilterFunc Text Text Char where-    filterFunc = T.filter-instance CanLength Text Prelude.Int where-    length = T.length-instance CanSingleton Text Prelude.Char where-    singleton = T.singleton-instance CanNull Text where-    null = T.null-instance CanPack Text Prelude.Char where-    pack = T.pack-    unpack = T.unpack-instance CanStripPrefix Text where-    stripPrefix = T.stripPrefix-    isPrefixOf = T.isPrefixOf-instance CanBreak Text Prelude.Char where-    break = T.break-    span = T.span-    dropWhile = T.dropWhile-    takeWhile = T.takeWhile-instance CanAny Text Prelude.Char where-    any = T.any-    all = T.all-instance CanSplitAt Text Prelude.Int where-    splitAt = T.splitAt--instance CanWords Text where-    words = T.words-    unwords = T.unwords-    lines = T.lines-    unlines = T.unlines--instance CanSplit Text Char where-    split = T.split--instance CanStripSuffix Text where-    stripSuffix = T.stripSuffix-    isSuffixOf = T.isSuffixOf--instance CanIsInfixOf Text where-    isInfixOf = T.isInfixOf--instance CanReverse Text where-    reverse = T.reverse--instance CanFoldFunc Text Char accum where-    foldFunc = T.foldl'--instance CanReplicate Text Text Prelude.Int where-    replicate = T.replicate
− ClassyPrelude/Vector.hs
@@ -1,53 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE TypeFamilies #-}-module ClassyPrelude.Vector-    ( Vector-    ) where--import qualified Prelude-import Prelude ((.))-import ClassyPrelude.Classes-import Data.Vector (Vector)-import qualified Data.Vector as V--instance CanMapFunc (Vector a) (Vector b) a b where-    mapFunc = V.map-instance CanConcatMapFunc (Vector a) (Vector b) a (Vector b) where-    concatMapFunc = V.concatMap-instance CanFilterFunc (Vector a) (Vector a) a where-    filterFunc = V.filter-instance CanLength (Vector a) Prelude.Int where-    length = V.length-instance CanSingleton (Vector a) a where-    singleton = V.singleton-instance CanNull (Vector a) where-    null = V.null-instance CanPack (Vector a) a where-    pack = V.fromList-    unpack = V.toList-instance Prelude.Monad m => CanMapMFunc (Vector i) (m (Vector o)) m i o where-    mapMFunc = V.mapM-instance CanMapM_Func (Vector a) a where-    mapM_Func = V.mapM_-instance Prelude.Eq x => CanMember (Vector x) x where-    member x = V.any (Prelude.== x)-instance CanBreak (Vector a) a where-    break = V.break-    span = V.span-    dropWhile = V.dropWhile-    takeWhile = V.takeWhile-instance CanAny (Vector a) a where-    any = V.any-    all = V.all-instance CanSplitAt (Vector a) Prelude.Int where-    splitAt = V.splitAt-instance CanFoldFunc (Vector a) a accum where-    foldFunc = V.foldl'--instance CanReverse (Vector a) where-    reverse = V.reverse--instance CanReplicate (Vector a) a Prelude.Int where-    replicate = V.replicate
+ README.md view
@@ -0,0 +1,57 @@+classy-prelude+==============++A better Prelude. Haskell's Prelude needs to maintain backwards compatibility and has many aspects that no longer represents best practice. The goals of classy-prelude are:++* remove all partial functions+* modernize data structures+  * generally use Text instead of String+  * encourage the use of appropriate data structures such as Vectors or HashMaps instead of always using lists and associated lists+* reduce import lists and the need for qualified imports++classy-prelude [should only be used by application developers](http://www.yesodweb.com/blog/2013/10/prelude-replacements-libraries). Library authors should consider using [mono-traversable](https://github.com/snoyberg/mono-traversable/blob/master/README.md), which classy-prelude builds upon.++It is worth noting that classy-prelude [largely front-ran changes that the community made to the base Prelude in GHC 7.10](http://www.yesodweb.com/blog/2014/10/classy-base-prelude).++mono-traversable+================++Most of this functionality is provided by [mono-traversable](https://github.com/snoyberg/mono-traversable). Please read the README over there. classy-prelude gets rid of the `o` prefix from mono-traversable functions.+++Text+====++Lots of things use `Text` instead of `String`.+Note that `show` returns a `String`.+To get back `Text`, use `tshow`.+++other functionality+===================++* exceptions package+* system-filepath convenience functions+* whenM, unlessM+* hashNub and ordNub (efficient nub implementations).+++Using classy-prelude+====================++* use the NoImplicitPrelude extension (you can place this in your cabal file) and `import ClassyPrelude`+* use [base-noprelude](https://github.com/hvr/base-noprelude) in your project and define a Prelude module that re-exports `ClassyPrelude`.+++Appendix+========++* The [mono-traversable](https://github.com/snoyberg/mono-traversable) README.+* [The transition to the modern design of classy-prelude](http://www.yesodweb.com/blog/2013/09/classy-mono).++These blog posts contain some out-dated information but might be helpful+* [So many preludes!](http://www.yesodweb.com/blog/2013/01/so-many-preludes) (January 2013)+* [ClassyPrelude: The good, the bad, and the ugly](http://www.yesodweb.com/blog/2012/08/classy-prelude-good-bad-ugly) (August 2012)+++
classy-prelude.cabal view
@@ -1,53 +1,80 @@-name:                classy-prelude-version:             0.2.0.1-synopsis:            A typeclass-based Prelude.-description:         Focuses on using common typeclasses when possible, and creating new ones to avoid name clashing. Exposes many recommended datastructures (Map, ByteString, etc) directly without requiring long import lists and qualified modules.-homepage:            https://github.com/snoyberg/classy-prelude-license:             MIT-license-file:        LICENSE-author:              Michael Snoyman-maintainer:          michael@snoyman.com-category:            Control-build-type:          Simple-cabal-version:       >=1.8+cabal-version: 1.12 -library-  exposed-modules:     ClassyPrelude-                       ClassyPrelude.Classes-  other-modules:       ClassyPrelude.List-                       ClassyPrelude.ByteString-                       ClassyPrelude.LByteString-                       ClassyPrelude.Text-                       ClassyPrelude.LText-                       ClassyPrelude.Map-                       ClassyPrelude.Set-                       ClassyPrelude.FilePath-                       ClassyPrelude.Vector-                       ClassyPrelude.HashMap-                       ClassyPrelude.HashSet-  build-depends:       base                          >= 4          && < 5-                     , basic-prelude                 >= 0.2        && < 0.3-                     , system-filepath               >= 0.4        && < 0.5-                     , transformers-                     , containers                    >= 0.4.2-                     , text-                     , bytestring-                     , vector-                     , unordered-containers-                     , hashable-  ghc-options:         -Wall -fno-warn-orphans+-- This file has been generated from package.yaml by hpack version 0.35.1.+--+-- see: https://github.com/sol/hpack -test-suite test-    hs-source-dirs: test-    main-is: main.hs-    type: exitcode-stdio-1.0-    build-depends:   classy-prelude-                   , base-                   , hspec == 1.3.*-                   , QuickCheck-                   , transformers-    ghc-options:     -Wall+name:           classy-prelude+version:        1.5.0.3+synopsis:       A typeclass-based Prelude.+description:    See docs and README at <http://www.stackage.org/package/classy-prelude>+category:       Control, Prelude+homepage:       https://github.com/snoyberg/mono-traversable#readme+bug-reports:    https://github.com/snoyberg/mono-traversable/issues+author:         Michael Snoyman+maintainer:     michael@snoyman.com+license:        MIT+license-file:   LICENSE+build-type:     Simple+extra-source-files:+    README.md+    ChangeLog.md  source-repository head-  type:     git-  location: git://github.com/snoyberg/classy-prelude.git+  type: git+  location: https://github.com/snoyberg/mono-traversable++library+  exposed-modules:+      ClassyPrelude+  other-modules:+      Paths_classy_prelude+  hs-source-dirs:+      src+  ghc-options: -Wall -fno-warn-orphans+  build-depends:+      async+    , base >=4.13 && <5+    , basic-prelude >=0.7+    , bifunctors+    , bytestring+    , chunked-data >=0.3+    , containers >=0.4.2+    , deepseq+    , dlist >=0.7+    , ghc-prim+    , hashable+    , mono-traversable >=1.0+    , mono-traversable-instances+    , mtl+    , mutable-containers ==0.3.*+    , primitive+    , say+    , stm+    , stm-chans >=3+    , text+    , time >=1.5+    , transformers+    , unliftio >=0.2.1.0+    , unordered-containers+    , vector+    , vector-instances+  default-language: Haskell2010++test-suite test+  type: exitcode-stdio-1.0+  main-is: main.hs+  other-modules:+      Paths_classy_prelude+  hs-source-dirs:+      test+  ghc-options: -Wall+  build-depends:+      QuickCheck+    , base >=4.13 && <5+    , classy-prelude+    , containers+    , hspec >=1.3+    , transformers+    , unordered-containers+  default-language: Haskell2010
+ src/ClassyPrelude.hs view
@@ -0,0 +1,641 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE TypeFamilies #-}+module ClassyPrelude+    ( -- * CorePrelude+      module CorePrelude+    , undefined+      -- * Standard+      -- ** Monoid+    , (++)+      -- ** Semigroup+    , Semigroup (..)+    , WrappedMonoid+      -- ** Functor+    , module Data.Functor+      -- ** Applicative+    , module Control.Applicative+    , (<&&>)+    , (<||>)+      -- ** Monad+    , module Control.Monad+    , whenM+    , unlessM+      -- ** UnliftIO reexports+    , module UnliftIO+      -- ** Mutable references+    , orElseSTM+    , module Data.Mutable+      -- ** STM Channels+    , module Control.Concurrent.STM.TBChan+    , module Control.Concurrent.STM.TBMChan+    , module Control.Concurrent.STM.TBMQueue+    , module Control.Concurrent.STM.TMChan+    , module Control.Concurrent.STM.TMQueue+      -- ** Primitive (exported since 0.9.4)+    , primToPrim+    , primToIO+    , primToST+    , module Data.Primitive.MutVar+      -- ** Debugging+    , trace+    , traceShow+    , traceId+    , traceM+    , traceShowId+    , traceShowM+      -- ** Time (since 0.6.1)+    , module Data.Time+#if MIN_VERSION_time(1,10,0)+    , parseTime+#endif+      -- ** Generics (since 0.8.1)+    , Generic+      -- ** Transformers (since 0.9.4)+    , Identity (..)+    , MonadReader+    , ask+    , asks+    , ReaderT (..)+    , Reader+      -- * Poly hierarchy+    , module Data.Foldable+    , module Data.Traversable+      -- ** Bifunctor (since 0.10.0)+    , module Data.Bifunctor+      -- * Mono hierarchy+    , module Data.MonoTraversable+    , module Data.MonoTraversable.Unprefixed+    , module Data.Sequences+    , module Data.Containers+    , module Data.Builder+    , module Data.NonNull+    , toByteVector+    , fromByteVector+      -- * I\/O+    , module Say+      -- * Concurrency+    , yieldThread+    , waitAsync+    , pollAsync+    , waitCatchAsync+    , linkAsync+    , link2Async+      -- * Non-standard+      -- ** List-like classes+    , map+    --, split+    , readMay+    , zip, zip3, zip4, zip5, zip6, zip7+    , unzip, unzip3, unzip4, unzip5, unzip6, unzip7+    , zipWith, zipWith3, zipWith4, zipWith5, zipWith6, zipWith7++    , hashNub+    , ordNub+    , ordNubBy++    , sortWith+    , Prelude.repeat+      -- ** Set-like+    , (\\)+    , intersect+    -- FIXME , mapSet+      -- ** Text-like+    , Show (..)+    , tshow+    , tlshow+      -- *** Case conversion+    , charToLower+    , charToUpper+      -- ** IO+    , readFile+    , readFileUtf8+    , writeFile+    , writeFileUtf8+    , hGetContents+    , hPut+    , hGetChunk+    , print+    -- Prelude IO operations+    , putChar+    , putStr+    , putStrLn+    , getChar+    , getLine+    , getContents+    , interact+      -- ** Difference lists+    , DList+    , asDList+    , applyDList+      -- ** Exceptions+    , module Control.DeepSeq+      -- ** Force types+      -- | Helper functions for situations where type inferer gets confused.+    , asByteString+    , asLByteString+    , asHashMap+    , asHashSet+    , asText+    , asLText+    , asList+    , asMap+    , asIntMap+    , asMaybe+    , asSet+    , asIntSet+    , asVector+    , asUVector+    , asSVector+    , asString+    ) where++import qualified Prelude+import Control.Applicative ((<**>),liftA,liftA2,liftA3,Alternative (..), optional)+import Data.Functor hiding (unzip)+import Control.Exception (assert)+import Control.DeepSeq (deepseq, ($!!), force, NFData (..))+import Control.Monad (when, unless, void, liftM, ap, forever, join, replicateM_, guard, MonadPlus (..), (=<<), (>=>), (<=<), liftM2, liftM3, liftM4, liftM5)+import qualified Control.Concurrent.STM as STM+import Data.Mutable+import Data.Traversable (Traversable (..), for, forM)+import Data.Foldable (Foldable)+import UnliftIO++import Data.Vector.Instances ()+import CorePrelude hiding+    ( putStr, putStrLn, print, undefined, (<>), catMaybes, first, second+    , catchIOError+    )+import Data.ChunkedZip+import qualified Data.Char as Char+import Data.Sequences+import Data.MonoTraversable+import Data.MonoTraversable.Unprefixed+import Data.MonoTraversable.Instances ()+import Data.Containers+import Data.Builder+import Data.NonNull+import qualified Data.ByteString+import qualified Data.Text.IO as TextIO+import qualified Data.Text.Lazy.IO as LTextIO+import Data.ByteString.Internal (ByteString (PS))+import Data.ByteString.Lazy.Internal (defaultChunkSize)+import Data.Vector.Storable (unsafeToForeignPtr, unsafeFromForeignPtr)++import qualified Debug.Trace as Trace+import Data.Semigroup (Semigroup (..), WrappedMonoid (..))+import Prelude (Show (..))+import Data.Time+    ( UTCTime (..)+    , Day (..)+    , toGregorian+    , fromGregorian+    , formatTime+#if !MIN_VERSION_time(1,10,0)+    , parseTime+#endif+    , parseTimeM+    , getCurrentTime+    , defaultTimeLocale+    )+import qualified Data.Time as Time++import qualified Data.Set as Set+import qualified Data.Map as Map+import qualified Data.HashSet as HashSet++import GHC.Generics (Generic)+import GHC.Stack (HasCallStack)++import Control.Monad.Primitive (primToPrim, primToIO, primToST)+import Data.Primitive.MutVar++import Data.Functor.Identity (Identity (..))+import Control.Monad.Reader (MonadReader, ask, asks, ReaderT (..), Reader)+import Data.Bifunctor+import Data.DList (DList)+import qualified Data.DList as DList+import Say+import Control.Concurrent.STM.TBChan+import Control.Concurrent.STM.TBMChan+import Control.Concurrent.STM.TBMQueue+import Control.Concurrent.STM.TMChan+import Control.Concurrent.STM.TMQueue+import qualified Control.Concurrent++tshow :: Show a => a -> Text+tshow = fromList . Prelude.show++tlshow :: Show a => a -> LText+tlshow = fromList . Prelude.show++-- | Convert a character to lower case.+--+-- Character-based case conversion is lossy in comparison to string-based 'Data.MonoTraversable.toLower'.+-- For instance, &#x130; will be converted to i, instead of i&#x307;.+charToLower :: Char -> Char+charToLower = Char.toLower++-- | Convert a character to upper case.+--+-- Character-based case conversion is lossy in comparison to string-based 'Data.MonoTraversable.toUpper'.+-- For instance, &#xdf; won't be converted to SS.+charToUpper :: Char -> Char+charToUpper = Char.toUpper++readMay :: (Element c ~ Char, MonoFoldable c, Read a) => c -> Maybe a+readMay a = -- FIXME replace with safe-failure stuff+    case [x | (x, t) <- Prelude.reads (otoList a :: String), onull t] of+        [x] -> Just x+        _ -> Nothing++map :: Functor f => (a -> b) -> f a -> f b+map = fmap++infixr 5  +++(++) :: Monoid m => m -> m -> m+(++) = mappend+{-# INLINE (++) #-}++infixl 9 \\{-This comment teaches CPP correct behaviour -}+-- | An alias for 'difference'.+(\\) :: SetContainer a => a -> a -> a+(\\) = difference+{-# INLINE (\\) #-}++-- | An alias for 'intersection'.+intersect :: SetContainer a => a -> a -> a+intersect = intersection+{-# INLINE intersect #-}++asByteString :: ByteString -> ByteString+asByteString = id++asLByteString :: LByteString -> LByteString+asLByteString = id++asHashMap :: HashMap k v -> HashMap k v+asHashMap = id++asHashSet :: HashSet a -> HashSet a+asHashSet = id++asText :: Text -> Text+asText = id++asLText :: LText -> LText+asLText = id++asList :: [a] -> [a]+asList = id++asMap :: Map k v -> Map k v+asMap = id++asIntMap :: IntMap v -> IntMap v+asIntMap = id++asMaybe :: Maybe a -> Maybe a+asMaybe = id++asSet :: Set a -> Set a+asSet = id++asIntSet :: IntSet -> IntSet+asIntSet = id++asVector :: Vector a -> Vector a+asVector = id++asUVector :: UVector a -> UVector a+asUVector = id++asSVector :: SVector a -> SVector a+asSVector = id++asString :: [Char] -> [Char]+asString = id++print :: (Show a, MonadIO m) => a -> m ()+print = liftIO . Prelude.print++-- | Sort elements using the user supplied function to project something out of+-- each element.+-- Inspired by <http://hackage.haskell.org/packages/archive/base/latest/doc/html/GHC-Exts.html#v:sortWith>.+sortWith :: (Ord a, IsSequence c) => (Element c -> a) -> c -> c+sortWith f = sortBy $ comparing f++-- | We define our own 'undefined' which is marked as deprecated. This makes it+-- useful to use during development, but lets you more easily get+-- notifications if you accidentally ship partial code in production.+--+-- The classy prelude recommendation for when you need to really have a partial+-- function in production is to use 'error' with a very descriptive message so+-- that, in case an exception is thrown, you get more information than+-- @"Prelude".'Prelude.undefined'@.+--+-- Since 0.5.5+undefined :: HasCallStack => a+undefined = error "ClassyPrelude.undefined"+{-# DEPRECATED undefined "It is highly recommended that you either avoid partial functions or provide meaningful error messages" #-}++-- | We define our own 'trace' (and also its variants) which provides a warning+-- when used. So that tracing is available during development, but the compiler+-- reminds you to not leave them in the code for production.+{-# WARNING trace "Leaving traces in the code" #-}+trace :: String -> a -> a+trace = Trace.trace++{-# WARNING traceShow "Leaving traces in the code" #-}+traceShow :: Show a => a -> b -> b+traceShow = Trace.traceShow++-- |+--+-- Since 0.5.9+{-# WARNING traceId "Leaving traces in the code" #-}+traceId :: String -> String+traceId a = Trace.trace a a++-- |+--+-- Since 0.5.9+{-# WARNING traceM "Leaving traces in the code" #-}+traceM :: (Monad m) => String -> m ()+traceM string = Trace.trace string $ return ()++-- |+--+-- Since 0.5.9+{-# WARNING traceShowId "Leaving traces in the code" #-}+traceShowId :: (Show a) => a -> a+traceShowId a = Trace.trace (show a) a++-- |+--+-- Since 0.5.9+{-# WARNING traceShowM "Leaving traces in the code" #-}+traceShowM :: (Show a, Monad m) => a -> m ()+traceShowM = traceM . show++-- | Originally 'Conc.yield'.+yieldThread :: MonadIO m => m ()+yieldThread = liftIO Control.Concurrent.yield+{-# INLINE yieldThread #-}++-- Below is a lot of coding for classy-prelude!+-- These functions are restricted to lists right now.+-- Should eventually exist in mono-foldable and be extended to MonoFoldable+-- when doing that should re-run the haskell-ordnub benchmarks++-- | same behavior as 'Data.List.nub', but requires 'Hashable' & 'Eq' and is @O(n log n)@+--+-- <https://github.com/nh2/haskell-ordnub>+hashNub :: (Hashable a, Eq a) => [a] -> [a]+hashNub = go HashSet.empty+  where+    go _ []     = []+    go s (x:xs) | x `HashSet.member` s = go s xs+                | otherwise            = x : go (HashSet.insert x s) xs++-- | same behavior as 'Data.List.nub', but requires 'Ord' and is @O(n log n)@+--+-- <https://github.com/nh2/haskell-ordnub>+ordNub :: (Ord a) => [a] -> [a]+ordNub = go Set.empty+  where+    go _ [] = []+    go s (x:xs) | x `Set.member` s = go s xs+                | otherwise        = x : go (Set.insert x s) xs++-- | same behavior as 'Data.List.nubBy', but requires 'Ord' and is @O(n log n)@+--+-- <https://github.com/nh2/haskell-ordnub>+ordNubBy :: (Ord b) => (a -> b) -> (a -> a -> Bool) -> [a] -> [a]+ordNubBy p f = go Map.empty+  -- When removing duplicates, the first function assigns the input to a bucket,+  -- the second function checks whether it is already in the bucket (linear search).+  where+    go _ []     = []+    go m (x:xs) = let b = p x in case b `Map.lookup` m of+                    Nothing     -> x : go (Map.insert b [x] m) xs+                    Just bucket+                      | elem_by f x bucket -> go m xs+                      | otherwise          -> x : go (Map.insert b (x:bucket) m) xs++    -- From the Data.List source code.+    elem_by :: (a -> a -> Bool) -> a -> [a] -> Bool+    elem_by _  _ []     = False+    elem_by eq y (x:xs) = y `eq` x || elem_by eq y xs++-- | Synonym for 'STM.orElse'.+orElseSTM :: STM a -> STM a -> STM a+orElseSTM = STM.orElse+{-# INLINE orElseSTM #-}++-- | Only perform the action if the predicate returns 'True'.+--+-- Since 0.9.2+whenM :: Monad m => m Bool -> m () -> m ()+whenM mbool action = mbool >>= flip when action++-- | Only perform the action if the predicate returns 'False'.+--+-- Since 0.9.2+unlessM :: Monad m => m Bool -> m () -> m ()+unlessM mbool action = mbool >>= flip unless action++-- | Force type to a 'DList'+--+-- Since 0.11.0+asDList :: DList a -> DList a+asDList = id+{-# INLINE asDList #-}++-- | Synonym for 'DList.apply'+--+-- Since 0.11.0+applyDList :: DList a -> [a] -> [a]+applyDList = DList.apply+{-# INLINE applyDList #-}++infixr 3 <&&>+-- | '&&' lifted to an Applicative.+--+-- @since 0.12.8+(<&&>) :: Applicative a => a Bool -> a Bool -> a Bool+(<&&>) = liftA2 (&&)+{-# INLINE (<&&>) #-}++infixr 2 <||>+-- | '||' lifted to an Applicative.+--+-- @since 0.12.8+(<||>) :: Applicative a => a Bool -> a Bool -> a Bool+(<||>) = liftA2 (||)+{-# INLINE (<||>) #-}++-- | Convert a 'ByteString' into a storable 'Vector'.+toByteVector :: ByteString -> SVector Word8+toByteVector (PS fptr offset idx) = unsafeFromForeignPtr fptr offset idx+{-# INLINE toByteVector #-}++-- | Convert a storable 'Vector' into a 'ByteString'.+fromByteVector :: SVector Word8 -> ByteString+fromByteVector v =+    PS fptr offset idx+  where+    (fptr, offset, idx) = unsafeToForeignPtr v+{-# INLINE fromByteVector #-}++-- | 'waitSTM' for any 'MonadIO'+--+-- @since 1.0.0+waitAsync :: MonadIO m => Async a -> m a+waitAsync = atomically . waitSTM++-- | 'pollSTM' for any 'MonadIO'+--+-- @since 1.0.0+pollAsync :: MonadIO m => Async a -> m (Maybe (Either SomeException a))+pollAsync = atomically . pollSTM++-- | 'waitCatchSTM' for any 'MonadIO'+--+-- @since 1.0.0+waitCatchAsync :: MonadIO m => Async a -> m (Either SomeException a)+waitCatchAsync = waitCatch++-- | 'Async.link' generalized to any 'MonadIO'+--+-- @since 1.0.0+linkAsync :: MonadIO m => Async a -> m ()+linkAsync = UnliftIO.link++-- | 'Async.link2' generalized to any 'MonadIO'+--+-- @since 1.0.0+link2Async :: MonadIO m => Async a -> Async b -> m ()+link2Async a = UnliftIO.link2 a++-- | Strictly read a file into a 'ByteString'.+--+-- @since 1.2.0+readFile :: MonadIO m => FilePath -> m ByteString+readFile = liftIO . Data.ByteString.readFile++-- | Strictly read a file into a 'Text' using a UTF-8 character+-- encoding. In the event of a character encoding error, a Unicode+-- replacement character will be used (a.k.a., @lenientDecode@).+--+-- @since 1.2.0+readFileUtf8 :: MonadIO m => FilePath -> m Text+readFileUtf8 = liftM decodeUtf8 . readFile++-- | Write a 'ByteString' to a file.+--+-- @since 1.2.0+writeFile :: MonadIO m => FilePath -> ByteString -> m ()+writeFile fp = liftIO . Data.ByteString.writeFile fp++-- | Write a 'Text' to a file using a UTF-8 character encoding.+--+-- @since 1.2.0+writeFileUtf8 :: MonadIO m => FilePath -> Text -> m ()+writeFileUtf8 fp = writeFile fp . encodeUtf8++-- | Strictly read the contents of the given 'Handle' into a+-- 'ByteString'.+--+-- @since 1.2.0+hGetContents :: MonadIO m => Handle -> m ByteString+hGetContents = liftIO . Data.ByteString.hGetContents++-- | Write a 'ByteString' to the given 'Handle'.+--+-- @since 1.2.0+hPut :: MonadIO m => Handle -> ByteString -> m ()+hPut h = liftIO . Data.ByteString.hPut h++-- | Read a single chunk of data as a 'ByteString' from the given+-- 'Handle'.+--+-- Under the surface, this uses 'Data.ByteString.hGetSome' with the+-- default chunk size.+--+-- @since 1.2.0+hGetChunk :: MonadIO m => Handle -> m ByteString+hGetChunk = liftIO . flip Data.ByteString.hGetSome defaultChunkSize++-- | Write a character to stdout+--+-- Uses system locale settings+--+-- @since 1.3.1+putChar :: MonadIO m => Char -> m ()+putChar = liftIO . Prelude.putChar++-- | Write a Text to stdout+--+-- Uses system locale settings+--+-- @since 1.3.1+putStr :: MonadIO m => Text -> m ()+putStr = liftIO . TextIO.putStr++-- | Write a Text followed by a newline to stdout+--+-- Uses system locale settings+--+-- @since 1.3.1+putStrLn :: MonadIO m => Text -> m ()+putStrLn = liftIO . TextIO.putStrLn++-- | Read a character from stdin+--+-- Uses system locale settings+--+-- @since 1.3.1+getChar :: MonadIO m => m Char+getChar = liftIO Prelude.getChar++-- | Read a line from stdin+--+-- Uses system locale settings+--+-- @since 1.3.1+getLine :: MonadIO m => m Text+getLine = liftIO TextIO.getLine++-- | Read all input from stdin into a lazy Text ('LText')+--+-- Uses system locale settings+--+-- @since 1.3.1+getContents :: MonadIO m => m LText+getContents = liftIO LTextIO.getContents++-- | Takes a function of type 'LText -> LText' and passes all input on stdin+-- to it, then prints result to stdout+--+-- Uses lazy IO+-- Uses system locale settings+--+-- @since 1.3.1+interact :: MonadIO m => (LText -> LText) -> m ()+interact = liftIO . LTextIO.interact+++#if MIN_VERSION_time(1,10,0)+parseTime +  :: Time.ParseTime t+  => Time.TimeLocale -- ^ Time locale.+  -> String -- ^ Format string.+  -> String -- ^ Input string.+  -> Maybe t -- ^ The time value, or 'Nothing' if the input could not be parsed using the given format.+parseTime = parseTimeM True+#endif++
test/main.hs view
@@ -1,106 +1,107 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE NoMonomorphismRestriction #-}+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE PatternGuards #-}+{-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-orphans #-} import Test.Hspec import Test.Hspec.QuickCheck-import ClassyPrelude-import ClassyPrelude.Classes+import ClassyPrelude hiding (undefined) import Test.QuickCheck.Arbitrary-import Prelude (asTypeOf, undefined, fromIntegral)-import qualified Prelude+import Prelude (undefined) import Control.Monad.Trans.Writer (tell, Writer, runWriter)+import qualified Data.Set as Set+import qualified Data.HashSet as HashSet  dictionaryProps-    :: ( CanInsertVal a Int Char-       , CanDelete a Int-       , Show a-       , Eq a-       , Arbitrary a-       , Monoid a-       , CanLookup a Int Char+    :: ( MapValue c ~ Char+       , ContainerKey c ~ Int+       , Arbitrary c+       , IsMap c+       , Eq c+       , Show c        )-    => a -> Spec+    => c+    -> Spec dictionaryProps dummy = do     prop "insert x y (insert x z c) == insert x y c" $ \x y z c ->-        insert x y (insert x z (c `asTypeOf` dummy)) == insert x y c-    prop "insert x y (delete x c) == insert x y c" $ \x y c ->-        insert x y (delete x (c `asTypeOf` dummy)) == insert x y c-    prop "delete x (insert x y c) == delete x c" $ \x y c ->-        delete x (insert x y (c `asTypeOf` dummy)) == delete x c-    prop "lookup k (insert k v empty) == Just v" $ \k v ->-        lookup k (insert k v empty `asTypeOf` dummy) == Just v-    prop "lookup k (delete k c) == Nothing" $ \k c ->-        lookup k (delete k c`asTypeOf` dummy) == Nothing+        insertMap x y (insertMap x z (c `asTypeOf` dummy)) == insertMap x y c+    prop "insertMap x y (deleteMap x c) == insertMap x y c" $ \x y c ->+        insertMap x y (deleteMap x (c `asTypeOf` dummy)) == insertMap x y c+    prop "deleteMap x (insertMap x y c) == deleteMap x c" $ \x y c ->+        mapFromList (mapToList $ deleteMap x (insertMap x y (c `asTypeOf` dummy))) == (mapFromList (mapToList ((deleteMap x c) `asTypeOf` dummy) :: [(Int, Char)]) `asTypeOf` dummy)+    prop "lookup k (insertMap k v empty) == Just v" $ \k v ->+        lookup k (insertMap k v mempty `asTypeOf` dummy) == Just v+    prop "lookup k (deleteMap k c) == Nothing" $ \k c ->+        lookup k (deleteMap k c`asTypeOf` dummy) == Nothing -mapProps :: ( CanPack a i-            , CanPack b j-            , Eq a+mapProps :: ( i ~ Element c+            , MonoFoldable c             , Eq c-            , Show a-            , Arbitrary a-            , Eq b-            , Show b-            , Arbitrary b-            , CanMapFunc a b i j-            , CanMapFunc a c i k-            , CanMapFunc b c j k+            , Arbitrary c+            , Show c             )-         => a-         -> (i -> j)-         -> (j -> k)+         => ((i -> i) -> c -> c)+         -> ([i] -> c)+         -> c+         -> (i -> i)+         -> (i -> i)          -> Spec-mapProps dummy f g = do+mapProps map' pack' dummy f g = do     prop "map f c == pack (map f (unpack c))" $ \c ->-        map f (c `asTypeOf` dummy) == pack (map f (unpack c))+        map' f (c `asTypeOf` dummy) == pack' (fmap f (unpack c))     prop "map (f . g) c == map f (map g c)" $ \c ->-        map (g . f) (c `asTypeOf` dummy) == map g (map f c)+        map' (g . f) (c `asTypeOf` dummy) == map' g (map' f c) -concatMapProps :: ( CanPack a i-            , CanPack b j-            , CanPack js j-            , Eq a-            , Show a-            , Arbitrary a-            , Eq b-            , Show b-            , Arbitrary b-            , CanMapFunc a b i j-            , CanConcatMapFunc a b i js-            )-         => a-         -> (i -> js)-         -> Spec+concatMapProps :: ( MonoFoldable c+                  , IsSequence c+                  , Eq c+                  , Arbitrary c+                  , Show c+                  )+               => c+               -> (Element c -> c)+               -> Spec concatMapProps dummy f = do     prop "concatMap f c == pack (concatMap (unpack . f) (unpack c))" $ \c ->         concatMap f (c `asTypeOf` dummy) == pack (concatMap (unpack . f) (unpack c)) -filterProps :: ( CanPack a i-               , Show a-               , Arbitrary a-               , Eq a-               , CanFilterFunc a a i+filterProps :: ( Eq c+               , Show c+               , IsSequence c+               , Arbitrary c                )-            => a-            -> (i -> Bool)+            => c+            -> (Element c -> Bool)             -> Spec filterProps dummy f = do     prop "filter f c == pack (filter f (unpack c))" $ \c ->-        filter f (c `asTypeOf` dummy) == pack (filter f (unpack c))+        (repack (filter f (c `asTypeOf` dummy)) `asTypeOf` dummy) == pack (filter f (unpack c)) -lengthProps :: ( Show a-               , Eq a-               , Arbitrary a-               , CanPack a i-               , CanLength a len-               , Prelude.Num len-               , Eq len-               , CanNull a-               , Ord len-               , Monoid a+filterMProps :: ( Eq c+                , Show c+                , IsSequence c+                , Arbitrary c+                )+             => c+             -> (Element c -> Bool)+             -> Spec+filterMProps dummy f' = do+    prop "filterM f c == fmap pack (filterM f (unpack c))" $ \c ->+        runIdentity (fmap repack (filterM f (c `asTypeOf` dummy))) `asTypeOf` dummy == runIdentity (fmap pack (filterM f (unpack c)))+  where+    f = return . f'++lengthProps :: ( Show c+               , MonoFoldable c+               , Monoid c+               , Arbitrary c                )-            => a -> Spec+            => c+            -> Spec lengthProps dummy = do     prop "length c == fromIntegral (length (unpack c))" $ \c ->         length (c `asTypeOf` dummy) == fromIntegral (length (unpack c))@@ -111,60 +112,155 @@     prop "length (x ++ y) >= max (length x) (length y)" $ \x y ->         length (x ++ y `asTypeOf` dummy) >= max (length x) (length y)     prop "length (x ++ empty) == length x" $ \x ->-        length (x ++ empty `asTypeOf` dummy) == length x-    prop "null empty" $ null (empty `asTypeOf` dummy)+        length (x ++ mempty `asTypeOf` dummy) == length x+    prop "null empty" $ null (mempty `asTypeOf` dummy) -{--mapMProps :: ( Show a-             , Arbitrary a-             , CanPack a i-             , Eq i-             , CanMapMFunc a co i i-             , CanPack co i-             , Eq co+mapMProps :: ( Eq c+             , Show c+             , IsSequence c+             , Arbitrary c+             , Element c ~ Int              )-           => a -> Spec--}+          => c+          -> Spec mapMProps dummy = do     let f :: Int -> Writer [Int] Int         f x = tell [x] >> return x-    prop "mapM_ f c == mapM_ f (toList c)" $ \c ->-        runWriter (mapM f (c `asTypeOf` dummy)) ==-            let (x, y) = runWriter (mapM f (toList c))+    prop "omapM f c == omapM f (toList c)" $ \c ->+        runWriter (omapM f (c `asTypeOf` dummy)) ==+            let (x, y) = runWriter (omapM f (toList c))              in (pack x, y) -mapM_Props :: ( Show a-              , Arbitrary a-              , CanPack a i-              , Eq i-              , CanMapM_Func a i+mapM_Props :: ( Eq (Element c)+              , Show c+              , MonoFoldable c+              , Arbitrary c               )-           => a -> Spec+           => c+           -> Spec mapM_Props dummy = do     let f x = tell [x]     prop "mapM_ f c == mapM_ f (toList c)" $ \c ->         runWriter (mapM_ f (c `asTypeOf` dummy)) == runWriter (mapM_ f (toList c)) +foldProps :: ( Eq a+             , Show c+             , MonoFoldable c+             , Arbitrary c+             )+          => c+          -> (a -> Element c -> a)+          -> a+          -> Spec foldProps dummy f accum =-    prop "fold f accum c == fold f accum (toList c)" $ \c ->-        fold f accum (c `asTypeOf` dummy) == fold f accum (toList c)+    prop "foldl' f accum c == foldl' f accum (toList c)" $ \c ->+        foldl' f accum (c `asTypeOf` dummy) == foldl' f accum (toList c) -replicateProps :: ( Show a-                  , Eq a-                  , CanReplicate a i len-                  , Integral len-                  , Show len-                  , Arbitrary len-                  , Show i-                  , Arbitrary i+replicateProps :: ( Eq a+                  , Show (Element c)+                  , IsSequence a+                  , IsSequence c+                  , Arbitrary (Element c)+                  , Element a ~ Element c                   )-               => a -> ([i] -> a) -> Spec+               => a+               -> (c -> a)+               -> Spec replicateProps dummy pack' =     prop "replicate i a == pack (replicate i a)" $ \{- takes too long i-} a ->-        (replicate i a `asTypeOf` dummy) == pack' (replicate (fromIntegral i) a)+        (replicate i a `asTypeOf` dummy) == pack' (replicate i a)   where     i = 3 +chunkProps :: ( Eq a+              , Show a+              , Arbitrary a+              , LazySequence a s+              )+           => a+           -> Spec+chunkProps dummy = do+    prop "fromChunks . toChunks == id" $ \a ->+        fromChunks (toChunks (a `asTypeOf` dummy)) == a+    prop "fromChunks . return . concat . toChunks == id" $ \a ->+        fromChunks [concat $ toChunks (a `asTypeOf` dummy)] == a++suffixProps :: ( Eq c+               , Show c+               , Arbitrary c+               , IsSequence c+               , Eq (Element c)+               )+            => c+            -> Spec+suffixProps dummy = do+    prop "y `isSuffixOf` (x ++ y)" $ \x y ->+        (y `asTypeOf` dummy) `isSuffixOf` (x ++ y)+    prop "stripSuffix y (x ++ y) == Just x" $ \x y ->+        stripSuffix y (x ++ y) == Just (x `asTypeOf` dummy)+    prop "isJust (stripSuffix x y) == isSuffixOf x y" $ \x y ->+        isJust (stripSuffix x y) == isSuffixOf x (y `asTypeOf` dummy)+    prop "dropSuffix y (x ++ y) == x" $ \x y ->+        dropSuffix y (x ++ y) == (x `asTypeOf` dummy)+    prop "dropSuffix x y == y || x `isSuffixOf` y" $ \x y ->+        dropSuffix x y == y || x `isSuffixOf` (y `asTypeOf` dummy)++replicateMProps :: ( Eq a+                   , Show (Index a)+                   , Show (Element a)+                   , IsSequence a+                   , Arbitrary (Index a)+                   , Arbitrary (Element a)+                   )+                => a+                -> Spec+replicateMProps dummy = do+    prop "runIdentity (replicateM i (return x)) == replicate i x" $ \i' x ->+        let i = i' `mod` 20+         in runIdentity (replicateM i (return x)) == (replicate i x `asTypeOf` dummy)++utf8Props :: ( Eq t+             , Show t+             , Arbitrary t+             , Textual t+             , Utf8 t b+             )+          => t+          -> Spec+utf8Props dummy = do+    prop "decodeUtf8 . encodeUtf8 == id" $ \t ->+        decodeUtf8 (encodeUtf8 t) == (t `asTypeOf` dummy)++compareLengthProps :: ( MonoFoldable c+                      , Arbitrary c+                      , Show c+                      )+                   => c+                   -> Spec+compareLengthProps dummy = do+    prop "compare (length c) i == compareLength c i" $ \i c ->+        compare (length c) i == compareLength (c `asTypeOf` dummy) i++prefixProps :: ( Eq c+               , IsSequence c+               , Eq (Element c)+               , Arbitrary c+               , Show c+               )+            => c+            -> Spec+prefixProps dummy = do+    prop "x `isPrefixOf` (x ++ y)" $ \x y ->+        (x `asTypeOf` dummy) `isPrefixOf` (x ++ y)+    prop "stripPrefix x (x ++ y) == Just y" $ \x y ->+        stripPrefix x (x ++ y) == Just (y `asTypeOf` dummy)+    prop "stripPrefix x y == Nothing || x `isPrefixOf` y" $ \x y ->+        stripPrefix x y == Nothing || x `isPrefixOf` (y `asTypeOf` dummy)+    prop "dropPrefix x (x ++ y) == y" $ \x y ->+        dropPrefix x (x ++ y) == (y `asTypeOf` dummy)+    prop "dropPrefix x y == y || x `isPrefixOf` y" $ \x y ->+        dropPrefix x y == y || x `isPrefixOf` (y `asTypeOf` dummy)+ main :: IO () main = hspec $ do     describe "dictionary" $ do@@ -172,33 +268,48 @@         describe "Data.HashMap" $ dictionaryProps (undefined :: HashMap Int Char)         describe "assoc list" $ dictionaryProps (undefined :: [(Int, Char)])     describe "map" $ do-        describe "list" $ mapProps (undefined :: [Int]) (+ 1) (+ 2)-        describe "Data.Vector" $ mapProps (undefined :: Vector Int) (+ 1) (+ 2)-        describe "Data.Set" $ mapProps (undefined :: Set Int) (+ 1) (+ 2)-        describe "Data.HashSet" $ mapProps (undefined :: HashSet Int) (+ 1) (+ 2)-        describe "Data.ByteString" $ mapProps (undefined :: ByteString) (+ 1) (+ 2)-        describe "Data.ByteString.Lazy" $ mapProps (undefined :: LByteString) (+ 1) (+ 2)-        describe "Data.Text" $ mapProps (undefined :: Text) succ succ-        describe "Data.Text.Lazy" $ mapProps (undefined :: LText) succ succ+        describe "list" $ mapProps fmap pack (undefined :: [Int]) (+ 1) (+ 2)+        describe "Data.Vector" $ mapProps fmap pack (undefined :: Vector Int) (+ 1) (+ 2)+        describe "Data.Vector.Unboxed" $ mapProps omap pack (undefined :: UVector Int) (+ 1) (+ 2)+        describe "Data.Set" $ mapProps Set.map setFromList (undefined :: Set Int) (+ 1) (+ 2)+        describe "Data.HashSet" $ mapProps HashSet.map setFromList (undefined :: HashSet Int) (+ 1) (+ 2)+        describe "Data.ByteString" $ mapProps omap pack (undefined :: ByteString) (+ 1) (+ 2)+        describe "Data.ByteString.Lazy" $ mapProps omap pack (undefined :: LByteString) (+ 1) (+ 2)+        describe "Data.Text" $ mapProps omap pack (undefined :: Text) succ succ+        describe "Data.Text.Lazy" $ mapProps omap pack (undefined :: LText) succ succ+        describe "Data.Sequence" $ mapProps fmap pack (undefined :: Seq Int) succ succ     describe "concatMap" $ do         describe "list" $ concatMapProps (undefined :: [Int]) (\i -> [i + 1, i + 2])         describe "Data.Vector" $ concatMapProps (undefined :: Vector Int) (\i -> fromList [i + 1, i + 2])+        describe "Data.Vector.Unboxed" $ concatMapProps (undefined :: UVector Int) (\i -> fromList [i + 1, i + 2])         describe "Data.ByteString" $ concatMapProps (undefined :: ByteString) (\i -> fromList [i + 1, i + 2])         describe "Data.ByteString.Lazy" $ concatMapProps (undefined :: LByteString) (\i -> fromList [i + 1, i + 2])         describe "Data.Text" $ concatMapProps (undefined :: Text) (\c -> pack [succ c, succ $ succ c])         describe "Data.Text.Lazy" $ concatMapProps (undefined :: LText) (\c -> pack [succ c, succ $ succ c])+        describe "Data.Sequence" $ concatMapProps (undefined :: Seq Int) (\i -> pack [i + 1, i + 2])     describe "filter" $ do         describe "list" $ filterProps (undefined :: [Int]) (< 20)         describe "Data.Vector" $ filterProps (undefined :: Vector Int) (< 20)+        describe "Data.Vector.Unboxed" $ filterProps (undefined :: UVector Int) (< 20)         describe "Data.ByteString" $ filterProps (undefined :: ByteString) (< 20)         describe "Data.ByteString.Lazy" $ filterProps (undefined :: LByteString) (< 20)         describe "Data.Text" $ filterProps (undefined :: Text) (< 'A')         describe "Data.Text.Lazy" $ filterProps (undefined :: LText) (< 'A')+        {- FIXME         describe "Data.Map" $ filterProps (undefined :: Map Int Char) (\(i, _) -> i < 20)         describe "Data.HashMap" $ filterProps (undefined :: HashMap Int Char) (\(i, _) -> i < 20)+        describe "Data.Set" $ filterProps (undefined :: Set Int) (< 20)+        -}+        describe "Data.Sequence" $ filterProps (undefined :: Seq Int) (< 20)+    describe "filterM" $ do+        describe "list" $ filterMProps (undefined :: [Int]) (< 20)+        describe "Data.Vector" $ filterMProps (undefined :: Vector Int) (< 20)+        describe "Data.Vector.Unboxed" $ filterMProps (undefined :: Vector Int) (< 20)+        describe "Data.Sequence" $ filterMProps (undefined :: Seq Int) (< 20)     describe "length" $ do         describe "list" $ lengthProps (undefined :: [Int])         describe "Data.Vector" $ lengthProps (undefined :: Vector Int)+        describe "Data.Vector.Unboxed" $ lengthProps (undefined :: UVector Int)         describe "Data.ByteString" $ lengthProps (undefined :: ByteString)         describe "Data.ByteString.Lazy" $ lengthProps (undefined :: LByteString)         describe "Data.Text" $ lengthProps (undefined :: Text)@@ -207,40 +318,133 @@         describe "Data.HashMap" $ lengthProps (undefined :: HashMap Int Char)         describe "Data.Set" $ lengthProps (undefined :: Set Int)         describe "Data.HashSet" $ lengthProps (undefined :: HashSet Int)+        describe "Data.Sequence" $ lengthProps (undefined :: Seq Int)     describe "mapM" $ do         describe "list" $ mapMProps (undefined :: [Int])         describe "Data.Vector" $ mapMProps (undefined :: Vector Int)+        describe "Data.Vector.Unboxed" $ mapMProps (undefined :: UVector Int)+        describe "Seq" $ mapMProps (undefined :: Seq Int)     describe "mapM_" $ do         describe "list" $ mapM_Props (undefined :: [Int])         describe "Data.Vector" $ mapM_Props (undefined :: Vector Int)+        describe "Data.Vector.Unboxed" $ mapM_Props (undefined :: UVector Int)+        describe "Set" $ mapM_Props (undefined :: Set Int)+        describe "HashSet" $ mapM_Props (undefined :: HashSet Int)+        describe "Seq" $ mapM_Props (undefined :: Seq Int)     describe "fold" $ do         let f = flip (:)         describe "list" $ foldProps (undefined :: [Int]) f []         describe "Data.Vector" $ foldProps (undefined :: Vector Int) f []+        describe "Data.Vector.Unboxed" $ foldProps (undefined :: UVector Int) f []         describe "Data.ByteString" $ foldProps (undefined :: ByteString) f []         describe "Data.ByteString.Lazy" $ foldProps (undefined :: LByteString) f []         describe "Data.Text" $ foldProps (undefined :: Text) f []         describe "Data.Text.Lazy" $ foldProps (undefined :: LText) f []         describe "Data.Set" $ foldProps (undefined :: Set Int) f []         describe "Data.HashSet" $ foldProps (undefined :: HashSet Int) f []+        describe "Data.Sequence" $ foldProps (undefined :: Seq Int) f []     describe "replicate" $ do         describe "list" $ replicateProps (undefined :: [Int]) pack         describe "Data.Vector" $ replicateProps (undefined :: Vector Int) pack+        describe "Data.Vector.Unboxed" $ replicateProps (undefined :: UVector Int) pack         describe "Data.ByteString" $ replicateProps (undefined :: ByteString) pack         describe "Data.ByteString.Lazy" $ replicateProps (undefined :: LByteString) pack-        describe "Data.Text" $ replicateProps (undefined :: Text) concat-        describe "Data.Text.Lazy" $ replicateProps (undefined :: LText) concat+        describe "Data.Text" $ replicateProps (undefined :: Text) pack+        describe "Data.Text.Lazy" $ replicateProps (undefined :: LText) pack+        describe "Data.Sequence" $ replicateProps (undefined :: Seq Int) pack+    describe "chunks" $ do+        describe "ByteString" $ chunkProps (asLByteString undefined)+        describe "Text" $ chunkProps (asLText undefined)+    describe "Suffix" $ do+        describe "list" $ suffixProps (undefined :: [Int])+        describe "Text" $ suffixProps (undefined :: Text)+        describe "LText" $ suffixProps (undefined :: LText)+        describe "ByteString" $ suffixProps (undefined :: ByteString)+        describe "LByteString" $ suffixProps (undefined :: LByteString)+        describe "Vector" $ suffixProps (undefined :: Vector Int)+        describe "UVector" $ suffixProps (undefined :: UVector Int)+        describe "Seq" $ suffixProps (undefined :: Seq Int)+    describe "replicateM" $ do+        describe "list" $ replicateMProps (undefined :: [Int])+        describe "Vector" $ replicateMProps (undefined :: Vector Int)+        describe "UVector" $ replicateMProps (undefined :: UVector Int)+        describe "Seq" $ replicateMProps (undefined :: Seq Int)+    describe "encode/decode UTF8" $ do+        describe "Text" $ utf8Props (undefined :: Text)+        describe "LText" $ utf8Props (undefined :: LText)+    describe "compareLength" $ do+        describe "list" $ compareLengthProps (undefined :: [Int])+        describe "Text" $ compareLengthProps (undefined :: Text)+        describe "LText" $ compareLengthProps (undefined :: LText)+    describe "Prefix" $ do+        describe "list" $ prefixProps (undefined :: [Int])+        describe "Text" $ prefixProps (undefined :: Text)+        describe "LText" $ prefixProps (undefined :: LText)+        describe "ByteString" $ prefixProps (undefined :: ByteString)+        describe "LByteString" $ prefixProps (undefined :: LByteString)+        describe "Vector" $ prefixProps (undefined :: Vector Int)+        describe "UVector" $ prefixProps (undefined :: UVector Int)+        describe "Seq" $ prefixProps (undefined :: Seq Int)+    {- This tests depend on timing and are unreliable. Instead, we're relying+       on the test suite in safe-exceptions itself.+    describe "any exceptions" $ do+        it "catchAny" $ do+            failed <- newIORef 0+            tid <- forkIO $ do+                catchAny+                    (threadDelay 20000)+                    (const $ writeIORef failed 1)+                writeIORef failed 2+            threadDelay 10000+            throwTo tid DummyException+            threadDelay 50000+            didFail <- readIORef failed+            liftIO $ didFail `shouldBe` (0 :: Int)+        it "tryAny" $ do+            failed <- newIORef False+            tid <- forkIO $ do+                _ <- tryAny $ threadDelay 20000+                writeIORef failed True+            threadDelay 10000+            throwTo tid DummyException+            threadDelay 50000+            didFail <- readIORef failed+            liftIO $ didFail `shouldBe` False+        it "tryAnyDeep" $ do+            eres <- tryAny $ return $!! impureThrow DummyException+            case eres of+                Left e+                    | Just DummyException <- fromException e -> return ()+                    | otherwise -> error "Expected a DummyException"+                Right () -> error "Expected an exception" :: IO ()+    -}+    it "basic DList functionality" $+        (toList $ asDList $ mconcat+            [ fromList [1, 2]+            , singleton 3+            , cons 4 mempty+            , fromList $ applyDList (singleton 5 ++ singleton 6) [7, 8]+            ]) `shouldBe` [1..8 :: Int] -instance Arbitrary (Map Int Char) where-    arbitrary = fromList <$> arbitrary+    describe "Data.ByteVector" $ do+        prop "toByteVector" $ \ws ->+            (otoList . toByteVector . fromList $ ws) `shouldBe` ws++        prop "fromByteVector" $ \ws ->+            (otoList . fromByteVector . fromList $ ws) `shouldBe` ws++data DummyException = DummyException+    deriving (Show, Typeable)+instance Exception DummyException+ instance Arbitrary (HashMap Int Char) where-    arbitrary = fromList <$> arbitrary+    arbitrary = mapFromList <$> arbitrary instance Arbitrary (Vector Int) where     arbitrary = fromList <$> arbitrary-instance Arbitrary (Set Int) where+instance Arbitrary (UVector Int) where     arbitrary = fromList <$> arbitrary instance Arbitrary (HashSet Int) where-    arbitrary = fromList <$> arbitrary+    arbitrary = setFromList <$> arbitrary instance Arbitrary ByteString where     arbitrary = fromList <$> arbitrary instance Arbitrary LByteString where@@ -249,3 +453,12 @@     arbitrary = fromList <$> arbitrary instance Arbitrary LText where     arbitrary = fromList <$> arbitrary++#if !MIN_VERSION_QuickCheck(2,8,2)+instance Arbitrary (Seq Int) where+    arbitrary = fromList <$> arbitrary+instance Arbitrary (Set Int) where+    arbitrary = setFromList <$> arbitrary+instance Arbitrary (Map Int Char) where+    arbitrary = mapFromList <$> arbitrary+#endif