ListLike 4.6 → 4.6.2
raw patch · 13 files changed
+61/−63 lines, 13 filesdep ~utf8-stringPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: utf8-string
API changes (from Hackage documentation)
- Data.ListLike.CharString: instance Data.Semigroup.Semigroup Data.ListLike.CharString.CharString
- Data.ListLike.CharString: instance Data.Semigroup.Semigroup Data.ListLike.CharString.CharStringLazy
- Data.ListLike.Chars: instance Data.Semigroup.Semigroup Data.ListLike.Chars.Chars
- Data.ListLike.Instances: instance (GHC.Real.Integral i, GHC.Arr.Ix i) => Data.Semigroup.Semigroup (GHC.Arr.Array i e)
- Data.ListLike.UTF8: instance Codec.Binary.UTF8.Generic.UTF8Bytes string index => Data.String.IsString (Data.String.UTF8.UTF8 string)
- Data.ListLike.UTF8: instance Data.Semigroup.Semigroup (Data.String.UTF8.UTF8 Data.ByteString.Internal.ByteString)
- Data.ListLike.UTF8: instance Data.Semigroup.Semigroup (Data.String.UTF8.UTF8 Data.ByteString.Lazy.Internal.ByteString)
+ Data.ListLike.CharString: instance GHC.Base.Semigroup Data.ListLike.CharString.CharString
+ Data.ListLike.CharString: instance GHC.Base.Semigroup Data.ListLike.CharString.CharStringLazy
+ Data.ListLike.Chars: instance GHC.Base.Semigroup Data.ListLike.Chars.Chars
+ Data.ListLike.Instances: instance (GHC.Real.Integral i, GHC.Arr.Ix i) => GHC.Base.Semigroup (GHC.Arr.Array i e)
+ Data.ListLike.UTF8: instance GHC.Base.Semigroup (Data.String.UTF8.UTF8 Data.ByteString.Internal.ByteString)
+ Data.ListLike.UTF8: instance GHC.Base.Semigroup (Data.String.UTF8.UTF8 Data.ByteString.Lazy.Internal.ByteString)
- Data.ListLike: concatMap :: (ListLike full item, (ListLike full' item')) => (item -> full') -> full -> full'
+ Data.ListLike: concatMap :: (ListLike full item, ListLike full' item') => (item -> full') -> full -> full'
- Data.ListLike: findIndices :: (ListLike full item, (ListLike result Int)) => (item -> Bool) -> full -> result
+ Data.ListLike: findIndices :: (ListLike full item, ListLike result Int) => (item -> Bool) -> full -> result
- Data.ListLike: inits :: (ListLike full item, (ListLike full' full)) => full -> full'
+ Data.ListLike: inits :: (ListLike full item, ListLike full' full) => full -> full'
- Data.ListLike: lines :: (StringLike s, (ListLike full s)) => s -> full
+ Data.ListLike: lines :: (StringLike s, ListLike full s) => s -> full
- Data.ListLike.Base: concatMap :: (ListLike full item, (ListLike full' item')) => (item -> full') -> full -> full'
+ Data.ListLike.Base: concatMap :: (ListLike full item, ListLike full' item') => (item -> full') -> full -> full'
- Data.ListLike.Base: findIndices :: (ListLike full item, (ListLike result Int)) => (item -> Bool) -> full -> result
+ Data.ListLike.Base: findIndices :: (ListLike full item, ListLike result Int) => (item -> Bool) -> full -> result
- Data.ListLike.Base: inits :: (ListLike full item, (ListLike full' full)) => full -> full'
+ Data.ListLike.Base: inits :: (ListLike full item, ListLike full' full) => full -> full'
- Data.ListLike.String: lines :: (StringLike s, (ListLike full s)) => s -> full
+ Data.ListLike.String: lines :: (StringLike s, ListLike full s) => s -> full
Files
- COPYRIGHT +1/−0
- ListLike.cabal +8/−8
- src/Data/ListLike/Base.hs +25/−25
- src/Data/ListLike/CharString.hs +1/−1
- src/Data/ListLike/FoldableLL.hs +3/−3
- src/Data/ListLike/IO.hs +3/−3
- src/Data/ListLike/Instances.hs +9/−9
- src/Data/ListLike/String.hs +3/−3
- src/Data/ListLike/UTF8.hs +0/−3
- src/Data/ListLike/Vector/Generic.hs +2/−2
- src/Data/ListLike/Vector/Storable.hs +2/−2
- src/Data/ListLike/Vector/Unboxed.hs +2/−2
- src/Data/ListLike/Vector/Vector.hs +2/−2
COPYRIGHT view
@@ -1,4 +1,5 @@ Copyright (c) 2007-2010 John Goerzon and John Lato. +Copyright (c) 2018 David Fox All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
ListLike.cabal view
@@ -1,17 +1,17 @@ Name: ListLike-Version: 4.6+Version: 4.6.2 License: BSD3-Maintainer: John Lato <jwlato@gmail.com>+Maintainer: David Fox <dsf@seereason.com> Author: John Goerzen Copyright: Copyright (c) 2007-2008 John Goerzen license-file: COPYRIGHT extra-source-files: COPYRIGHT, README.md-Category: Generics+Category: list, string, text, bytestring, vector Cabal-Version: >= 1.8 Build-Type: Simple homepage: http://github.com/JohnLato/listlike-synopsis: Generic support for list-like structures-Description: Generic support for list-like structures in Haskell.+synopsis: Generalized support for list-like structures+Description: Generalized support for list-like structures in Haskell. . The ListLike module provides a common interface to the various Haskell types that are list-like. Predefined interfaces include standard@@ -50,7 +50,7 @@ Data.ListLike.FMList -- Other-Modules: Data.ConfigFile.Lexer Build-Depends: base >= 4.6 && < 5- ,containers >= 0.3 && < 0.6+ ,containers >= 0.3 && < 0.7 ,bytestring >= 0.9.1 && < 0.11 ,array >= 0.3 && < 0.6 ,text >= 0.11 && < 1.3@@ -61,7 +61,7 @@ ,deepseq If !impl(ghc >= 8.4)- Build-Depends: semigroups >= 0.16 && < 0.19+ Build-Depends: semigroups >= 0.16 && < 0.20 Test-suite listlike-tests GHC-Options: -O2@@ -84,7 +84,7 @@ ,vector ,utf8-string If !impl(ghc >= 8.4)- Build-Depends: semigroups >= 0.16 && < 0.19+ Build-Depends: semigroups >= 0.16 && < 0.20 source-repository head type: git
src/Data/ListLike/Base.hs view
@@ -29,7 +29,7 @@ Written by John Goerzen, jgoerzen\@complete.org -} -module Data.ListLike.Base +module Data.ListLike.Base ( ListLike(..), InfiniteListLike(..),@@ -89,7 +89,7 @@ snoc l item = append l (singleton item) {- | Combines two lists. Like (++). -}- append :: full -> full -> full + append :: full -> full -> full append = mappend {- | Extracts the first element of a 'ListLike'. -}@@ -134,7 +134,7 @@ as fast, if not faster, than this function and is recommended if it will work for your purposes. See also 'mapM'. -} map :: ListLike full' item' => (item -> item') -> full -> full'- map func inp + map func inp | null inp = empty | otherwise = cons (func (head inp)) (map func (tail inp)) @@ -146,7 +146,7 @@ rigidMap = map {- | Reverse the elements in a list. -}- reverse :: full -> full + reverse :: full -> full reverse l = rev l empty where rev rl a | null rl = a@@ -217,7 +217,7 @@ {- | Returns all elements at start of list that satisfy the function. -} takeWhile :: (item -> Bool) -> full -> full- takeWhile func l + takeWhile func l | null l = empty | func x = cons x (takeWhile func (tail l)) | otherwise = empty@@ -240,7 +240,7 @@ span :: (item -> Bool) -> full -> (full, full) span func l | null l = (empty, empty)- | func x = (cons x ys, zs) + | func x = (cons x ys, zs) | otherwise = (empty, l) where (ys, zs) = span func (tail l) x = head l@@ -275,7 +275,7 @@ isPrefixOf needle haystack | null needle = True | null haystack = False- | otherwise = (head needle) == (head haystack) && + | otherwise = (head needle) == (head haystack) && isPrefixOf (tail needle) (tail haystack) {- | True when the first list is at the beginning of the second. -}@@ -284,7 +284,7 @@ {- | True when the first list is wholly containted within the second -} isInfixOf :: Eq item => full -> full -> Bool- isInfixOf needle haystack = + isInfixOf needle haystack = any (isPrefixOf needle) thetails where thetails = asTypeOf (tails haystack) [haystack] @@ -318,8 +318,8 @@ Just x -> Just (index l x) {- | Returns only the elements that satisfy the function. -}- filter :: (item -> Bool) -> full -> full - filter func l + filter :: (item -> Bool) -> full -> full+ filter func l | null l = empty | func (head l) = cons (head l) (filter func (tail l)) | otherwise = filter func (tail l)@@ -333,7 +333,7 @@ {- | The element at 0-based index i. Raises an exception if i is out of bounds. Like (!!) for lists. -} index :: full -> Int -> item- index l i + index l i | null l = error "index: index not found" | i < 0 = error "index: index must be >= 0" | i == 0 = head l@@ -343,7 +343,7 @@ elemIndex :: Eq item => item -> full -> Maybe Int elemIndex e l = findIndex (== e) l - {- | Returns the indices of the matching elements. See also + {- | Returns the indices of the matching elements. See also 'findIndices' -} elemIndices :: (Eq item, ListLike result Int) => item -> full -> result elemIndices i l = findIndices (== i) l@@ -363,15 +363,15 @@ sequence :: (Monad m, ListLike fullinp (m item)) => fullinp -> m full sequence l = foldr func (return empty) l- where func litem results = + where func litem results = do x <- litem xs <- results return (cons x xs) - {- | A map in monad space. Same as @'sequence' . 'map'@ - + {- | A map in monad space. Same as @'sequence' . 'map'@+ See also 'rigidMapM' -}- mapM :: (Monad m, ListLike full' item') => + mapM :: (Monad m, ListLike full' item') => (item -> m item') -> full -> m full' mapM func l = sequence mapresult where mapresult = asTypeOf (map func l) []@@ -416,11 +416,11 @@ sort = sortBy compare {- | Inserts the element at the last place where it is still less than or- equal to the next element. On data types that do not preserve + equal to the next element. On data types that do not preserve ordering, or enforce their own ordering, the result may not be what you expect. On types such as maps, this may result in changing an existing item. See also 'insertBy'. -}- insert :: Ord item => item -> full -> full + insert :: Ord item => item -> full -> full insert = insertBy compare ------------------------------ Conversions@@ -431,7 +431,7 @@ toList = fromListLike {- | Generates the structure from a list. -}- fromList :: [item] -> full + fromList :: [item] -> full fromList [] = empty fromList (x:xs) = cons x (fromList xs) @@ -481,7 +481,7 @@ intersectBy func xs ys = filter (\x -> any (func x) ys) xs {- | Generic version of 'group'. -}- groupBy :: (ListLike full' full, Eq item) => + groupBy :: (ListLike full' full, Eq item) => (item -> item -> Bool) -> full -> full' groupBy eq l | null l = empty@@ -491,12 +491,12 @@ xs = tail l {- | Sort function taking a custom comparison function -}- sortBy :: (item -> item -> Ordering) -> full -> full + sortBy :: (item -> item -> Ordering) -> full -> full sortBy cmp = foldr (insertBy cmp) empty {- | Like 'insert', but with a custom comparison function -} insertBy :: (item -> item -> Ordering) -> item ->- full -> full + full -> full insertBy cmp x ys | null ys = singleton x | otherwise = case cmp x (head ys) of@@ -521,7 +521,7 @@ {- | Generic version of 'drop' -} genericDrop :: Integral a => a -> full -> full- genericDrop n l + genericDrop n l | n <= 0 = l | null l = l | otherwise = genericDrop (n - 1) (tail l)@@ -532,7 +532,7 @@ {- | Generic version of 'replicate' -} genericReplicate :: Integral a => a -> item -> full- genericReplicate count x + genericReplicate count x | count <= 0 = empty | otherwise = map (\_ -> x) [1..count] @@ -571,7 +571,7 @@ {- | Converts a finite list into a circular one -} cycle :: full -> full- cycle xs + cycle xs | null xs = error "ListLike.cycle: empty list" | otherwise = xs' where xs' = append xs xs'
src/Data/ListLike/CharString.hs view
@@ -34,7 +34,7 @@ where -import Prelude hiding (length, head, last, null, tail, map, filter, concat, +import Prelude hiding (length, head, last, null, tail, map, filter, concat, any, lookup, init, all, foldl, foldr, foldl1, foldr1, maximum, minimum, iterate, span, break, takeWhile, dropWhile, reverse, zip, zipWith, sequence,
src/Data/ListLike/FoldableLL.hs view
@@ -24,19 +24,19 @@ Written by John Goerzen, jgoerzen\@complete.org -}-module Data.ListLike.FoldableLL +module Data.ListLike.FoldableLL (-- * FoldableLL Class FoldableLL(..), -- * Utilities fold, foldMap, foldM, sequence_, mapM_- ) where + ) where import Prelude hiding (foldl, foldr, foldr1, sequence_, mapM_, foldMap) import qualified Data.Foldable as F import Data.Monoid import Data.Maybe import qualified Data.List as L -{- | This is the primary class for structures that are to be considered +{- | This is the primary class for structures that are to be considered foldable. A minimum complete definition provides 'foldl' and 'foldr'. Instances of 'FoldableLL' can be folded, and can be many and varied.
src/Data/ListLike/IO.hs view
@@ -29,7 +29,7 @@ ( ListLikeIO(..) ) where-import Prelude hiding (length, head, last, null, tail, map, filter, concat, +import Prelude hiding (length, head, last, null, tail, map, filter, concat, any, lookup, init, all, foldl, foldr, foldl1, foldr1, maximum, minimum, iterate, span, break, takeWhile, dropWhile, reverse, zip, zipWith, sequence,@@ -48,7 +48,7 @@ Note that some types may not be capable of lazy reading or writing. Therefore, the usual semantics of "System.IO" functions regarding laziness may or may not be available from a particular implementation.- + Minimal complete definition: * hGetLine@@ -104,7 +104,7 @@ -- | Interact with stdin and stdout by using a function to transform -- input to output. May be lazy. See 'System.IO.interact' for more. interact :: (full -> full) -> IO ()- interact func = + interact func = do c <- getContents putStr (func c)
src/Data/ListLike/Instances.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE MultiParamTypeClasses +{-# LANGUAGE MultiParamTypeClasses ,FlexibleInstances ,TypeSynonymInstances #-} @@ -28,7 +28,7 @@ -} module Data.ListLike.Instances () where-import Prelude hiding (length, head, last, null, tail, map, filter, concat, +import Prelude hiding (length, head, last, null, tail, map, filter, concat, any, lookup, init, all, foldl, foldr, foldl1, foldr1, maximum, minimum, iterate, span, break, takeWhile, dropWhile, reverse, zip, zipWith, sequence,@@ -262,7 +262,7 @@ filter = BSL.filter --partition = BSL.partition index l i = BSL.index l (fromIntegral i)- elemIndex i = mi64toi . BSL.elemIndex i + elemIndex i = mi64toi . BSL.elemIndex i --elemIndices x = fromList . L.map fromIntegral . BSL.elemIndices x findIndex f = mi64toi . BSL.findIndex f --findIndices x = fromList . L.map fromIntegral . BSL.findIndices x@@ -356,12 +356,12 @@ instance (Integral i, Ix i) => ListLike (A.Array i e) e where empty = mempty singleton i = A.listArray (0, 0) [i]- cons i l = + cons i l = -- To add something to the beginning of an array, we must -- change the bounds and set the first element. (A.ixmap (blow - 1, bhigh) id l) // [(blow - 1, i)] where (blow, bhigh) = A.bounds l- snoc l i = + snoc l i = -- Here we must change the bounds and set the last element (A.ixmap (blow, bhigh + 1) id l) // [(bhigh + 1, i)] where (blow, bhigh) = A.bounds l@@ -376,7 +376,7 @@ length = genericLength -- map rigidMap = A.amap- reverse l = A.listArray (A.bounds l) (L.reverse (A.elems l)) + reverse l = A.listArray (A.bounds l) (L.reverse (A.elems l)) -- intersperse -- concat -- concatMap@@ -432,7 +432,7 @@ -- insertBy genericLength l = fromIntegral (bhigh - blow + 1) where (blow, bhigh) = A.bounds l- genericTake count l + genericTake count l | count > genericLength l = l | count <= 0 = empty | otherwise = A.listArray (blow, blow + (fromIntegral count) - 1)@@ -442,7 +442,7 @@ (L.genericDrop count (A.elems l)) where (blow, bhigh) = A.bounds l -- geneicSplitAt- genericReplicate count i = A.listArray (0, (fromIntegral count) - 1) + genericReplicate count i = A.listArray (0, (fromIntegral count) - 1) (L.genericReplicate count i) @@ -516,7 +516,7 @@ reverse = S.reverse --intersperse = --concat =- --concatMap = + --concatMap = --rigidConcatMap = any = F.any all = F.all
src/Data/ListLike/String.hs view
@@ -25,7 +25,7 @@ ( StringLike(..) ) where-import Prelude hiding (length, head, last, null, tail, map, filter, concat, +import Prelude hiding (length, head, last, null, tail, map, filter, concat, any, lookup, init, all, foldl, foldr, foldl1, foldr1, maximum, minimum, iterate, span, break, takeWhile, dropWhile, reverse, zip, zipWith, sequence,@@ -42,13 +42,13 @@ class StringLike s where {- | Converts the structure to a 'String' -} toString :: s -> String- + {- | Converts a 'String' to a list -} fromString :: String -> s {- | Breaks a string into a list of strings -} lines :: (ListLike full s) => s -> full- --lines = map fromString . L.lines . toString + --lines = map fromString . L.lines . toString lines = myLines {- | Breaks a string into a list of words -}
src/Data/ListLike/UTF8.hs view
@@ -38,9 +38,6 @@ utf8rnf :: NFData a => UTF8 a -> () utf8rnf = rnf . UTF8.toRep -instance UTF8Bytes string index => IsString (UTF8 string) where- fromString = UTF8.fromString- instance FoldableLL (UTF8 BS.ByteString) Char where foldl = UTF8.foldl -- foldl' = UTF8.foldl'
src/Data/ListLike/Vector/Generic.hs view
@@ -74,11 +74,11 @@ toList = V.toList fromList = V.fromList --fromListLike = fromList . toList- --groupBy f = + --groupBy f = genericLength = fromInteger . fromIntegral . V.length genericTake i = V.take (fromIntegral i) genericDrop i = V.drop (fromIntegral i)- --genericSplitAt i = + --genericSplitAt i = genericReplicate i = V.replicate (fromIntegral i) sequence = liftM fromList . P.sequence . toList
src/Data/ListLike/Vector/Storable.hs view
@@ -67,11 +67,11 @@ toList = V.toList fromList = V.fromList --fromListLike = fromList . toList- --groupBy f = + --groupBy f = genericLength = fromInteger . fromIntegral . V.length genericTake i = V.take (fromIntegral i) genericDrop i = V.drop (fromIntegral i)- --genericSplitAt i = + --genericSplitAt i = genericReplicate i = V.replicate (fromIntegral i) sequence = liftM fromList . P.sequence . toList
src/Data/ListLike/Vector/Unboxed.hs view
@@ -66,11 +66,11 @@ toList = V.toList fromList = V.fromList --fromListLike = fromList . toList- --groupBy f = + --groupBy f = genericLength = fromInteger . fromIntegral . V.length genericTake i = V.take (fromIntegral i) genericDrop i = V.drop (fromIntegral i)- --genericSplitAt i = + --genericSplitAt i = genericReplicate i = V.replicate (fromIntegral i) sequence = liftM fromList . P.sequence . toList
src/Data/ListLike/Vector/Vector.hs view
@@ -65,11 +65,11 @@ toList = V.toList fromList = V.fromList --fromListLike = fromList . toList- --groupBy f = + --groupBy f = genericLength = fromInteger . fromIntegral . V.length genericTake i = V.take (fromIntegral i) genericDrop i = V.drop (fromIntegral i)- --genericSplitAt i = + --genericSplitAt i = genericReplicate i = V.replicate (fromIntegral i) sequence = liftM fromList . P.sequence . toList