classy-prelude 0.5.3 → 0.5.4
raw patch · 10 files changed
+234/−30 lines, 10 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ ClassyPrelude: unzip :: CanUnzip c1 i1 c2 i2 t => t (i1, i2) -> (c1, c2)
+ ClassyPrelude: unzip3 :: CanUnzip3 c1 i1 c2 i2 c3 i3 t => t (i1, i2, i3) -> (c1, c2, c3)
+ ClassyPrelude: unzip4 :: CanUnzip4 c1 i1 c2 i2 c3 i3 c4 i4 t => t (i1, i2, i3, i4) -> (c1, c2, c3, c4)
+ ClassyPrelude: unzip5 :: CanUnzip5 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 t => t (i1, i2, i3, i4, i5) -> (c1, c2, c3, c4, c5)
+ ClassyPrelude: unzip6 :: CanUnzip6 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 t => t (i1, i2, i3, i4, i5, i6) -> (c1, c2, c3, c4, c5, c6)
+ ClassyPrelude: unzip7 :: CanUnzip7 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 t => t (i1, i2, i3, i4, i5, i6, i7) -> (c1, c2, c3, c4, c5, c6, c7)
+ ClassyPrelude: zip :: CanZip c1 i1 c2 i2 t => c1 -> c2 -> t (i1, i2)
+ ClassyPrelude: zip3 :: CanZip3 c1 i1 c2 i2 c3 i3 t => c1 -> c2 -> c3 -> t (i1, i2, i3)
+ ClassyPrelude: zip4 :: CanZip4 c1 i1 c2 i2 c3 i3 c4 i4 t => c1 -> c2 -> c3 -> c4 -> t (i1, i2, i3, i4)
+ ClassyPrelude: zip5 :: CanZip5 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 t => c1 -> c2 -> c3 -> c4 -> c5 -> t (i1, i2, i3, i4, i5)
+ ClassyPrelude: zip6 :: CanZip6 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 t => c1 -> c2 -> c3 -> c4 -> c5 -> c6 -> t (i1, i2, i3, i4, i5, i6)
+ ClassyPrelude: zip7 :: CanZip7 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 t => c1 -> c2 -> c3 -> c4 -> c5 -> c6 -> c7 -> t (i1, i2, i3, i4, i5, i6, i7)
+ ClassyPrelude: zipWith :: CanZipWith c1 i1 c2 i2 c3 i3 => (i1 -> i2 -> i3) -> c1 -> c2 -> c3
+ ClassyPrelude: zipWith3 :: CanZipWith3 c1 i1 c2 i2 c3 i3 c4 i4 => (i1 -> i2 -> i3 -> i4) -> c1 -> c2 -> c3 -> c4
+ ClassyPrelude: zipWith4 :: CanZipWith4 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 => (i1 -> i2 -> i3 -> i4 -> i5) -> c1 -> c2 -> c3 -> c4 -> c5
+ ClassyPrelude: zipWith5 :: CanZipWith5 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 => (i1 -> i2 -> i3 -> i4 -> i5 -> i6) -> c1 -> c2 -> c3 -> c4 -> c5 -> c6
+ ClassyPrelude: zipWith6 :: CanZipWith6 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 => (i1 -> i2 -> i3 -> i4 -> i5 -> i6 -> i7) -> c1 -> c2 -> c3 -> c4 -> c5 -> c6 -> c7
+ ClassyPrelude: zipWith7 :: CanZipWith7 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 c8 i8 => (i1 -> i2 -> i3 -> i4 -> i5 -> i6 -> i7 -> i8) -> c1 -> c2 -> c3 -> c4 -> c5 -> c6 -> c7 -> c8
+ ClassyPrelude.Classes: class CanUnzip c1 i1 c2 i2 t | c1 -> i1, c2 -> i2
+ ClassyPrelude.Classes: class CanUnzip3 c1 i1 c2 i2 c3 i3 t | c1 -> i1, c2 -> i2, c3 -> i3
+ ClassyPrelude.Classes: class CanUnzip4 c1 i1 c2 i2 c3 i3 c4 i4 t | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4
+ ClassyPrelude.Classes: class CanUnzip5 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 t | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5
+ ClassyPrelude.Classes: class CanUnzip6 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 t | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5, c6 -> i6
+ ClassyPrelude.Classes: class CanUnzip7 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 t | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5, c6 -> i6, c7 -> i7
+ ClassyPrelude.Classes: class CanZip c1 i1 c2 i2 t | c1 -> i1, c2 -> i2
+ ClassyPrelude.Classes: class CanZip3 c1 i1 c2 i2 c3 i3 t | c1 -> i1, c2 -> i2, c3 -> i3
+ ClassyPrelude.Classes: class CanZip4 c1 i1 c2 i2 c3 i3 c4 i4 t | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4
+ ClassyPrelude.Classes: class CanZip5 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 t | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5
+ ClassyPrelude.Classes: class CanZip6 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 t | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5, c6 -> i6
+ ClassyPrelude.Classes: class CanZip7 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 t | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5, c6 -> i6, c7 -> i7
+ ClassyPrelude.Classes: class CanZipWith c1 i1 c2 i2 c3 i3 | c1 -> i1, c2 -> i2, c3 -> i3
+ ClassyPrelude.Classes: class CanZipWith3 c1 i1 c2 i2 c3 i3 c4 i4 | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4
+ ClassyPrelude.Classes: class CanZipWith4 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5
+ ClassyPrelude.Classes: class CanZipWith5 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5, c6 -> i6
+ ClassyPrelude.Classes: class CanZipWith6 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5, c6 -> i6, c7 -> i7
+ ClassyPrelude.Classes: class CanZipWith7 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 c8 i8 | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5, c6 -> i6, c7 -> i7, c8 -> i8
+ ClassyPrelude.Classes: unzip :: CanUnzip c1 i1 c2 i2 t => t (i1, i2) -> (c1, c2)
+ ClassyPrelude.Classes: unzip3 :: CanUnzip3 c1 i1 c2 i2 c3 i3 t => t (i1, i2, i3) -> (c1, c2, c3)
+ ClassyPrelude.Classes: unzip4 :: CanUnzip4 c1 i1 c2 i2 c3 i3 c4 i4 t => t (i1, i2, i3, i4) -> (c1, c2, c3, c4)
+ ClassyPrelude.Classes: unzip5 :: CanUnzip5 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 t => t (i1, i2, i3, i4, i5) -> (c1, c2, c3, c4, c5)
+ ClassyPrelude.Classes: unzip6 :: CanUnzip6 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 t => t (i1, i2, i3, i4, i5, i6) -> (c1, c2, c3, c4, c5, c6)
+ ClassyPrelude.Classes: unzip7 :: CanUnzip7 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 t => t (i1, i2, i3, i4, i5, i6, i7) -> (c1, c2, c3, c4, c5, c6, c7)
+ ClassyPrelude.Classes: zip :: CanZip c1 i1 c2 i2 t => c1 -> c2 -> t (i1, i2)
+ ClassyPrelude.Classes: zip3 :: CanZip3 c1 i1 c2 i2 c3 i3 t => c1 -> c2 -> c3 -> t (i1, i2, i3)
+ ClassyPrelude.Classes: zip4 :: CanZip4 c1 i1 c2 i2 c3 i3 c4 i4 t => c1 -> c2 -> c3 -> c4 -> t (i1, i2, i3, i4)
+ ClassyPrelude.Classes: zip5 :: CanZip5 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 t => c1 -> c2 -> c3 -> c4 -> c5 -> t (i1, i2, i3, i4, i5)
+ ClassyPrelude.Classes: zip6 :: CanZip6 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 t => c1 -> c2 -> c3 -> c4 -> c5 -> c6 -> t (i1, i2, i3, i4, i5, i6)
+ ClassyPrelude.Classes: zip7 :: CanZip7 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 t => c1 -> c2 -> c3 -> c4 -> c5 -> c6 -> c7 -> t (i1, i2, i3, i4, i5, i6, i7)
+ ClassyPrelude.Classes: zipWith :: CanZipWith c1 i1 c2 i2 c3 i3 => (i1 -> i2 -> i3) -> c1 -> c2 -> c3
+ ClassyPrelude.Classes: zipWith3 :: CanZipWith3 c1 i1 c2 i2 c3 i3 c4 i4 => (i1 -> i2 -> i3 -> i4) -> c1 -> c2 -> c3 -> c4
+ ClassyPrelude.Classes: zipWith4 :: CanZipWith4 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 => (i1 -> i2 -> i3 -> i4 -> i5) -> c1 -> c2 -> c3 -> c4 -> c5
+ ClassyPrelude.Classes: zipWith5 :: CanZipWith5 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 => (i1 -> i2 -> i3 -> i4 -> i5 -> i6) -> c1 -> c2 -> c3 -> c4 -> c5 -> c6
+ ClassyPrelude.Classes: zipWith6 :: CanZipWith6 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 => (i1 -> i2 -> i3 -> i4 -> i5 -> i6 -> i7) -> c1 -> c2 -> c3 -> c4 -> c5 -> c6 -> c7
+ ClassyPrelude.Classes: zipWith7 :: CanZipWith7 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 c8 i8 => (i1 -> i2 -> i3 -> i4 -> i5 -> i6 -> i7 -> i8) -> c1 -> c2 -> c3 -> c4 -> c5 -> c6 -> c7 -> c8
Files
- ClassyPrelude.hs +3/−0
- ClassyPrelude/ByteString.hs +9/−0
- ClassyPrelude/Classes.hs +54/−0
- ClassyPrelude/LByteString.hs +9/−0
- ClassyPrelude/LText.hs +6/−0
- ClassyPrelude/List.hs +54/−0
- ClassyPrelude/Sequence.hs +47/−29
- ClassyPrelude/Text.hs +6/−0
- ClassyPrelude/Vector.hs +45/−0
- classy-prelude.cabal +1/−1
ClassyPrelude.hs view
@@ -65,6 +65,9 @@ , subsequences , permutations , partition+ , zip, zip3, zip4, zip5, zip6, zip7+ , unzip, unzip3, unzip4, unzip5, unzip6, unzip7+ , zipWith, zipWith3, zipWith4, zipWith5, zipWith6, zipWith7 , nub , nubBy , sort
ClassyPrelude/ByteString.hs view
@@ -98,3 +98,12 @@ instance CanGroup ByteString Word8 where group = ByteString.group++instance CanZipWith ByteString Word8 ByteString Word8 [a] a where+ zipWith = ByteString.zipWith++instance CanZip ByteString Word8 ByteString Word8 [] where+ zip = ByteString.zip++instance CanUnzip ByteString Word8 ByteString Word8 [] where+ unzip = ByteString.unzip
ClassyPrelude/Classes.hs view
@@ -214,3 +214,57 @@ class CanRepeat c a | c -> a where repeat :: a -> c++class CanZipWith c1 i1 c2 i2 c3 i3 | c1 -> i1, c2 -> i2, c3 -> i3 where+ zipWith :: (i1 -> i2 -> i3) -> c1 -> c2 -> c3++class CanZipWith3 c1 i1 c2 i2 c3 i3 c4 i4 | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4 where+ zipWith3 :: (i1 -> i2 -> i3 -> i4) -> c1 -> c2 -> c3 -> c4++class CanZipWith4 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5 where+ zipWith4 :: (i1 -> i2 -> i3 -> i4 -> i5) -> c1 -> c2 -> c3 -> c4 -> c5++class CanZipWith5 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5, c6 -> i6 where+ zipWith5 :: (i1 -> i2 -> i3 -> i4 -> i5 -> i6) -> c1 -> c2 -> c3 -> c4 -> c5 -> c6++class CanZipWith6 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5, c6 -> i6, c7 -> i7 where+ zipWith6 :: (i1 -> i2 -> i3 -> i4 -> i5 -> i6 -> i7) -> c1 -> c2 -> c3 -> c4 -> c5 -> c6 -> c7++class CanZipWith7 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 c8 i8 | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5, c6 -> i6, c7 -> i7, c8 -> i8 where+ zipWith7 :: (i1 -> i2 -> i3 -> i4 -> i5 -> i6 -> i7 -> i8) -> c1 -> c2 -> c3 -> c4 -> c5 -> c6 -> c7 -> c8++class CanZip c1 i1 c2 i2 t | c1 -> i1, c2 -> i2 where+ zip :: c1 -> c2 -> t (i1, i2)++class CanZip3 c1 i1 c2 i2 c3 i3 t | c1 -> i1, c2 -> i2, c3 -> i3 where+ zip3 :: c1 -> c2 -> c3 -> t (i1, i2, i3)++class CanZip4 c1 i1 c2 i2 c3 i3 c4 i4 t | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4 where+ zip4 :: c1 -> c2 -> c3 -> c4 -> t (i1, i2, i3, i4)++class CanZip5 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 t | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5 where+ zip5 :: c1 -> c2 -> c3 -> c4 -> c5 -> t (i1, i2, i3, i4, i5)++class CanZip6 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 t | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5, c6 -> i6 where+ zip6 :: c1 -> c2 -> c3 -> c4 -> c5 -> c6 -> t (i1, i2, i3, i4, i5, i6)++class CanZip7 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 t | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5, c6 -> i6, c7 -> i7 where+ zip7 :: c1 -> c2 -> c3 -> c4 -> c5 -> c6 -> c7 -> t (i1, i2, i3, i4, i5, i6, i7)++class CanUnzip c1 i1 c2 i2 t | c1 -> i1, c2 -> i2 where+ unzip :: t (i1, i2) -> (c1, c2)++class CanUnzip3 c1 i1 c2 i2 c3 i3 t | c1 -> i1, c2 -> i2, c3 -> i3 where+ unzip3 :: t (i1, i2, i3) -> (c1, c2, c3)++class CanUnzip4 c1 i1 c2 i2 c3 i3 c4 i4 t | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4 where+ unzip4 :: t (i1, i2, i3, i4) -> (c1, c2, c3, c4)++class CanUnzip5 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 t | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5 where+ unzip5 :: t (i1, i2, i3, i4, i5) -> (c1, c2, c3, c4, c5)++class CanUnzip6 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 t | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5, c6 -> i6 where+ unzip6 :: t (i1, i2, i3, i4, i5, i6) -> (c1, c2, c3, c4, c5, c6)++class CanUnzip7 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 t | c1 -> i1, c2 -> i2, c3 -> i3, c4 -> i4, c5 -> i5, c6 -> i6, c7 -> i7 where+ unzip7 :: t (i1, i2, i3, i4, i5, i6, i7) -> (c1, c2, c3, c4, c5, c6, c7)
ClassyPrelude/LByteString.hs view
@@ -104,3 +104,12 @@ instance CanRepeat LByteString Word8 where repeat = LByteString.repeat++instance CanZipWith LByteString Word8 LByteString Word8 [a] a where+ zipWith = LByteString.zipWith++instance CanZip LByteString Word8 LByteString Word8 [] where+ zip = LByteString.zip++instance CanUnzip LByteString Word8 LByteString Word8 [] where+ unzip = LByteString.unzip
ClassyPrelude/LText.hs view
@@ -131,3 +131,9 @@ instance CanGroup LText Char where group = LText.group++instance CanZipWith LText Char LText Char LText Char where+ zipWith = LText.zipWith++instance CanZip LText Char LText Char [] where+ zip = LText.zip
ClassyPrelude/List.hs view
@@ -157,3 +157,57 @@ instance CanRepeat [a] a where repeat = List.repeat++instance CanZipWith [a] a [b] b [c] c where+ zipWith = List.zipWith++instance CanZipWith3 [a] a [b] b [c] c [d] d where+ zipWith3 = List.zipWith3++instance CanZipWith4 [a] a [b] b [c] c [d] d [e] e where+ zipWith4 = List.zipWith4++instance CanZipWith5 [a] a [b] b [c] c [d] d [e] e [f] f where+ zipWith5 = List.zipWith5++instance CanZipWith6 [a] a [b] b [c] c [d] d [e] e [f] f [g] g where+ zipWith6 = List.zipWith6++instance CanZipWith7 [a] a [b] b [c] c [d] d [e] e [f] f [g] g [h] h where+ zipWith7 = List.zipWith7++instance CanZip ([] a) a ([] b) b [] where+ zip = List.zip++instance CanZip3 ([] a) a ([] b) b ([] c) c [] where+ zip3 = List.zip3++instance CanZip4 ([] a) a ([] b) b ([] c) c ([] d) d [] where+ zip4 = List.zip4++instance CanZip5 ([] a) a ([] b) b ([] c) c ([] d) d ([] e) e [] where+ zip5 = List.zip5++instance CanZip6 ([] a) a ([] b) b ([] c) c ([] d) d ([] e) e ([] f) f [] where+ zip6 = List.zip6++instance CanZip7 ([] a) a ([] b) b ([] c) c ([] d) d ([] e) e ([] f) f ([] g) g [] where+ zip7 = List.zip7++instance CanUnzip ([] a) a ([] b) b [] where+ unzip = List.unzip++instance CanUnzip3 ([] a) a ([] b) b ([] c) c [] where+ unzip3 = List.unzip3++instance CanUnzip4 ([] a) a ([] b) b ([] c) c ([] d) d [] where+ unzip4 = List.unzip4++instance CanUnzip5 ([] a) a ([] b) b ([] c) c ([] d) d ([] e) e [] where+ unzip5 = List.unzip5++instance CanUnzip6 ([] a) a ([] b) b ([] c) c ([] d) d ([] e) e ([] f) f [] where+ unzip6 = List.unzip6++instance CanUnzip7 ([] a) a ([] b) b ([] c) c ([] d) d ([] e) e ([] f) f ([] g) g [] where+ unzip7 = List.unzip7
ClassyPrelude/Sequence.hs view
@@ -12,7 +12,7 @@ import qualified Control.Monad as Monad import qualified Data.Foldable as Foldable import qualified Data.Traversable as Traversable-import qualified Data.Sequence as Sequence+import qualified Data.Sequence as Seq import Data.Sequence (Seq, (<|), (|>), ViewL(..), viewl, ViewR(..), viewr) @@ -23,34 +23,34 @@ concatMap = (Monad.=<<) instance CanFilter (Seq a) a where- filter = Sequence.filter+ filter = Seq.filter instance CanFilterM (Seq a) a where filterM p = Foldable.foldlM (\ xs x -> do res <- p x; return $ if res then xs |> x else xs)- Sequence.empty+ Seq.empty instance CanLength (Seq a) Int where- length = Sequence.length+ length = Seq.length instance CanSingleton (Seq a) a where- singleton = Sequence.singleton+ singleton = Seq.singleton instance CanNull (Seq a) where- null = Sequence.null+ null = Seq.null instance CanPack (Seq a) a where- pack = Sequence.fromList+ pack = Seq.fromList unpack = Foldable.toList instance CanIntersperse (Seq a) a where intersperse sep xs = case viewl xs of- EmptyL -> Sequence.empty+ EmptyL -> Seq.empty (h :< t) -> h <| prependToAll sep t where prependToAll sep xs = case viewl xs of- EmptyL -> Sequence.empty+ EmptyL -> Seq.empty (h :< t) -> sep <| (h <| prependToAll sep t) instance Eq a => CanStripPrefix (Seq a) where@@ -58,20 +58,20 @@ | x == y1 = Just y2 | otherwise = Nothing where- (y1, y2) = Sequence.splitAt (Sequence.length x) y- isPrefixOf x y = Sequence.take (Sequence.length x) y == x+ (y1, y2) = Seq.splitAt (Seq.length x) y+ isPrefixOf x y = Seq.take (Seq.length x) y == x instance Eq a => CanStripSuffix (Seq a) where stripSuffix x y | x == y2 = Just y1 | otherwise = Nothing where- (y1, y2) = Sequence.splitAt (Sequence.length y - Sequence.length x) y- isSuffixOf x y = takeRR (Sequence.length x) y == x+ (y1, y2) = Seq.splitAt (Seq.length y - Seq.length x) y+ isSuffixOf x y = takeRR (Seq.length x) y == x where- takeRR 0 _ = Sequence.empty+ takeRR 0 _ = Seq.empty takeRR n xs = case viewr xs of- EmptyR -> Sequence.empty+ EmptyR -> Seq.empty xs' :> x -> takeRR (n-1) xs' |> x instance Monad m => CanMapM (Seq i) (m (Seq o)) m i o where@@ -84,33 +84,33 @@ member x = any (== x) instance CanBreak (Seq a) a where- break = Sequence.breakl- span = Sequence.spanl- dropWhile = Sequence.dropWhileL- takeWhile = Sequence.takeWhileL+ break = Seq.breakl+ span = Seq.spanl+ dropWhile = Seq.dropWhileL+ takeWhile = Seq.takeWhileL instance CanAny (Seq a) a where any = Foldable.any all = Foldable.all instance CanSplitAt (Seq a) Int where- splitAt = Sequence.splitAt+ splitAt = Seq.splitAt instance CanFold (Seq a) a accum where fold = Foldable.foldl' instance CanReverse (Seq a) where- reverse = Sequence.reverse+ reverse = Seq.reverse instance CanReplicate (Seq a) a Int where- replicate = Sequence.replicate+ replicate = Seq.replicate instance CanReplicateM (Seq a) a Int where- replicateM = Sequence.replicateM+ replicateM = Seq.replicateM instance CanFind (Seq a) a where- find p s = case Sequence.breakl p s of- (_, s') -> case Sequence.viewl s' of+ find p s = case Seq.breakl p s of+ (_, s') -> case Seq.viewl s' of a :< _ -> Just a _ -> Nothing @@ -118,18 +118,36 @@ concat = Foldable.fold instance CanPartition (Seq a) a where- partition = Sequence.partition+ partition = Seq.partition instance CanSortBy (Seq a) a where- sortBy = Sequence.sortBy+ sortBy = Seq.sortBy instance Ord a => CanSort (Seq a) a where- sort = Sequence.sort+ sort = Seq.sort instance CanCons (Seq a) a where cons = (<|) instance CanUncons (Seq a) a where- uncons s = case Sequence.viewl s of+ uncons s = case Seq.viewl s of EmptyL -> Nothing a :< s' -> Just (a, s')++instance CanZipWith (Seq a) a (Seq b) b (Seq c) c where+ zipWith = Seq.zipWith++instance CanZipWith3 (Seq a) a (Seq b) b (Seq c) c (Seq d) d where+ zipWith3 = Seq.zipWith3++instance CanZipWith4 (Seq a) a (Seq b) b (Seq c) c (Seq d) d (Seq e) e where+ zipWith4 = Seq.zipWith4++instance CanZip (Seq a) a (Seq b) b Seq where+ zip = Seq.zip++instance CanZip3 (Seq a) a (Seq b) b (Seq c) c Seq where+ zip3 = Seq.zip3++instance CanZip4 (Seq a) a (Seq b) b (Seq c) c (Seq d) d Seq where+ zip4 = Seq.zip4
ClassyPrelude/Text.hs view
@@ -123,3 +123,9 @@ instance CanGroup Text Char where group = Text.group++instance CanZipWith Text Char Text Char Text Char where+ zipWith = Text.zipWith++instance CanZip Text Char Text Char [] where+ zip = Text.zip
ClassyPrelude/Vector.hs view
@@ -137,3 +137,48 @@ then n else j (Vector.unsafeHead x) (Vector.unsafeTail x) ++instance CanZipWith (Vector a) a (Vector b) b (Vector c) c where+ zipWith = Vector.zipWith++instance CanZipWith3 (Vector a) a (Vector b) b (Vector c) c (Vector d) d where+ zipWith3 = Vector.zipWith3++instance CanZipWith4 (Vector a) a (Vector b) b (Vector c) c (Vector d) d (Vector e) e where+ zipWith4 = Vector.zipWith4++instance CanZipWith5 (Vector a) a (Vector b) b (Vector c) c (Vector d) d (Vector e) e (Vector f) f where+ zipWith5 = Vector.zipWith5++instance CanZipWith6 (Vector a) a (Vector b) b (Vector c) c (Vector d) d (Vector e) e (Vector f) f (Vector g) g where+ zipWith6 = Vector.zipWith6++instance CanZip (Vector a) a (Vector b) b Vector where+ zip = Vector.zip++instance CanZip3 (Vector a) a (Vector b) b (Vector c) c Vector where+ zip3 = Vector.zip3++instance CanZip4 (Vector a) a (Vector b) b (Vector c) c (Vector d) d Vector where+ zip4 = Vector.zip4++instance CanZip5 (Vector a) a (Vector b) b (Vector c) c (Vector d) d (Vector e) e Vector where+ zip5 = Vector.zip5++instance CanZip6 (Vector a) a (Vector b) b (Vector c) c (Vector d) d (Vector e) e (Vector f) f Vector where+ zip6 = Vector.zip6++instance CanUnzip (Vector a) a (Vector b) b Vector where+ unzip = Vector.unzip++instance CanUnzip3 (Vector a) a (Vector b) b (Vector c) c Vector where+ unzip3 = Vector.unzip3++instance CanUnzip4 (Vector a) a (Vector b) b (Vector c) c (Vector d) d Vector where+ unzip4 = Vector.unzip4++instance CanUnzip5 (Vector a) a (Vector b) b (Vector c) c (Vector d) d (Vector e) e Vector where+ unzip5 = Vector.unzip5++instance CanUnzip6 (Vector a) a (Vector b) b (Vector c) c (Vector d) d (Vector e) e (Vector f) f Vector where+ unzip6 = Vector.unzip6
classy-prelude.cabal view
@@ -1,5 +1,5 @@ name: classy-prelude-version: 0.5.3+version: 0.5.4 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