Copyright | Copyright (C) 2007 John Goerzen |
---|---|
License | BSD3 |
Maintainer | David Fox <dsf@seereason.com>, Andreas Abel |
Stability | stable |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Generic operations over list-like structures
Written by John Goerzen, jgoerzen@complete.org
Please start with the introduction at Data.ListLike.
Synopsis
- empty :: ListLike full item => full
- singleton :: ListLike full item => item -> full
- cons :: ListLike full item => item -> full -> full
- snoc :: ListLike full item => full -> item -> full
- append :: ListLike full item => full -> full -> full
- uncons :: ListLike full item => full -> Maybe (item, full)
- head :: ListLike full item => full -> item
- last :: ListLike full item => full -> item
- tail :: ListLike full item => full -> full
- init :: ListLike full item => full -> full
- null :: ListLike full item => full -> Bool
- length :: ListLike full item => full -> Int
- map :: (ListLike full item, ListLike full' item') => (item -> item') -> full -> full'
- rigidMap :: ListLike full item => (item -> item) -> full -> full
- reverse :: ListLike full item => full -> full
- intersperse :: ListLike full item => item -> full -> full
- toList :: IsList l => l -> [Item l]
- fromList :: IsList l => [Item l] -> l
- fromListLike :: (ListLike full item, ListLike full' item) => full -> full'
- foldl :: FoldableLL full item => (a -> item -> a) -> a -> full -> a
- foldl' :: FoldableLL full item => (a -> item -> a) -> a -> full -> a
- foldl1 :: FoldableLL full item => (item -> item -> item) -> full -> item
- foldr :: FoldableLL full item => (item -> b -> b) -> b -> full -> b
- foldr' :: FoldableLL full item => (item -> b -> b) -> b -> full -> b
- foldr1 :: FoldableLL full item => (item -> item -> item) -> full -> item
- concat :: (ListLike full item, ListLike full' full) => full' -> full
- concatMap :: (ListLike full item, ListLike full' item') => (item -> full') -> full -> full'
- rigidConcatMap :: ListLike full item => (item -> full) -> full -> full
- and :: ListLike full Bool => full -> Bool
- or :: ListLike full Bool => full -> Bool
- any :: ListLike full item => (item -> Bool) -> full -> Bool
- all :: ListLike full item => (item -> Bool) -> full -> Bool
- sum :: (Num a, ListLike full a) => full -> a
- product :: (Num a, ListLike full a) => full -> a
- maximum :: (ListLike full item, Ord item) => full -> item
- minimum :: (ListLike full item, Ord item) => full -> item
- fold :: (FoldableLL full item, Monoid item) => full -> item
- foldMap :: (FoldableLL full item, Monoid m) => (item -> m) -> full -> m
- iterate :: InfiniteListLike full item => (item -> item) -> item -> full
- repeat :: InfiniteListLike full item => item -> full
- replicate :: ListLike full item => Int -> item -> full
- cycle :: InfiniteListLike full item => full -> full
- take :: ListLike full item => Int -> full -> full
- drop :: ListLike full item => Int -> full -> full
- splitAt :: ListLike full item => Int -> full -> (full, full)
- takeWhile :: ListLike full item => (item -> Bool) -> full -> full
- dropWhile :: ListLike full item => (item -> Bool) -> full -> full
- dropWhileEnd :: ListLike full item => (item -> Bool) -> full -> full
- span :: ListLike full item => (item -> Bool) -> full -> (full, full)
- break :: ListLike full item => (item -> Bool) -> full -> (full, full)
- group :: (ListLike full item, ListLike full' full, Eq item) => full -> full'
- inits :: (ListLike full item, ListLike full' full) => full -> full'
- tails :: (ListLike full item, ListLike full' full) => full -> full'
- isPrefixOf :: (ListLike full item, Eq item) => full -> full -> Bool
- isSuffixOf :: (ListLike full item, Eq item) => full -> full -> Bool
- isInfixOf :: (ListLike full item, Eq item) => full -> full -> Bool
- stripPrefix :: (ListLike full item, Eq item) => full -> full -> Maybe full
- stripSuffix :: (ListLike full item, Eq item) => full -> full -> Maybe full
- elem :: (ListLike full item, Eq item) => item -> full -> Bool
- notElem :: (ListLike full item, Eq item) => item -> full -> Bool
- find :: ListLike full item => (item -> Bool) -> full -> Maybe item
- filter :: ListLike full item => (item -> Bool) -> full -> full
- partition :: ListLike full item => (item -> Bool) -> full -> (full, full)
- index :: ListLike full item => full -> Int -> item
- elemIndex :: (ListLike full item, Eq item) => item -> full -> Maybe Int
- elemIndices :: (ListLike full item, Eq item, ListLike result Int) => item -> full -> result
- findIndex :: ListLike full item => (item -> Bool) -> full -> Maybe Int
- findIndices :: (ListLike full item, ListLike result Int) => (item -> Bool) -> full -> result
- zip :: (ListLike full item, ListLike fullb itemb, ListLike result (item, itemb)) => full -> fullb -> result
- zipWith :: (ListLike full item, ListLike fullb itemb, ListLike result resultitem) => (item -> itemb -> resultitem) -> full -> fullb -> result
- unzip :: (ListLike full (itema, itemb), ListLike ra itema, ListLike rb itemb) => full -> (ra, rb)
- sequence :: (ListLike full item, Applicative m, ListLike fullinp (m item)) => fullinp -> m full
- sequence_ :: (Monad m, FoldableLL full (m item)) => full -> m ()
- mapM :: (ListLike full item, Applicative m, ListLike full' item') => (item -> m item') -> full -> m full'
- rigidMapM :: (ListLike full item, Monad m) => (item -> m item) -> full -> m full
- mapM_ :: (Monad m, FoldableLL full item) => (item -> m b) -> full -> m ()
- class ListLike full item => ListLikeIO full item | full -> item where
- hGetLine :: Handle -> IO full
- hGetContents :: Handle -> IO full
- hGet :: Handle -> Int -> IO full
- hGetNonBlocking :: Handle -> Int -> IO full
- hPutStr :: Handle -> full -> IO ()
- hPutStrLn :: Handle -> full -> IO ()
- getLine :: IO full
- getContents :: IO full
- putStr :: full -> IO ()
- putStrLn :: full -> IO ()
- interact :: (full -> full) -> IO ()
- readFile :: FilePath -> IO full
- writeFile :: FilePath -> full -> IO ()
- appendFile :: FilePath -> full -> IO ()
- toString :: StringLike s => s -> String
- fromString :: IsString a => String -> a
- lines :: (StringLike s, ListLike full s) => s -> full
- words :: (StringLike s, ListLike full s) => s -> full
- show :: (StringLike s, Show a) => a -> s
- fromStringLike :: (StringLike s, StringLike s') => s -> s'
- fromText :: (StringLike s, StringLike Text) => Text -> s
- fromLazyText :: (StringLike s, StringLike Text) => Text -> s
- nub :: (ListLike full item, Eq item) => full -> full
- delete :: (ListLike full item, Eq item) => item -> full -> full
- deleteFirsts :: (ListLike full item, Eq item) => full -> full -> full
- union :: (ListLike full item, Eq item) => full -> full -> full
- intersect :: (ListLike full item, Eq item) => full -> full -> full
- sort :: (ListLike full item, Ord item) => full -> full
- insert :: (ListLike full item, Ord item) => item -> full -> full
- nubBy :: ListLike full item => (item -> item -> Bool) -> full -> full
- deleteBy :: ListLike full item => (item -> item -> Bool) -> item -> full -> full
- deleteFirstsBy :: ListLike full item => (item -> item -> Bool) -> full -> full -> full
- unionBy :: ListLike full item => (item -> item -> Bool) -> full -> full -> full
- intersectBy :: ListLike full item => (item -> item -> Bool) -> full -> full -> full
- groupBy :: (ListLike full item, ListLike full' full, Eq item) => (item -> item -> Bool) -> full -> full'
- sortBy :: ListLike full item => (item -> item -> Ordering) -> full -> full
- insertBy :: ListLike full item => (item -> item -> Ordering) -> item -> full -> full
- genericLength :: (ListLike full item, Num a) => full -> a
- genericTake :: (ListLike full item, Integral a) => a -> full -> full
- genericDrop :: (ListLike full item, Integral a) => a -> full -> full
- genericSplitAt :: (ListLike full item, Integral a) => a -> full -> (full, full)
- genericReplicate :: (ListLike full item, Integral a) => a -> item -> full
- data Chars
- newtype CharString = CS {
- unCS :: ByteString
- newtype CharStringLazy = CSL {
- unCSL :: ByteString
- class (IsList full, item ~ Item full, FoldableLL full item, Monoid full) => ListLike full item | full -> item
- type ListOps full = ListLike full (Item full)
- class FoldableLL full item | full -> item
- class IsString s => StringLike s
- class ListLike full item => InfiniteListLike full item | full -> item
Introduction
This module provides abstractions over typical list operations. It is designed to let you freely interchange different ways to represent sequences of data. It works with lists, various types of ByteStrings, and much more.
In this module, you'll find generic versions of most of the functions you're used to using in the Prelude, Data.List, and System.IO. They carry the same names, too. Therefore, you'll want to be careful how you import the module. I suggest using:
import qualified Data.ListLike as LL
Then, you can use LL.fold, LL.map, etc. to get the generic version of the functions you want. Alternatively, you can hide the other versions from Prelude and import specific generic functions from here, such as:
import Prelude hiding (map) import Data.ListLike (map)
The module Data.ListLike actually simply re-exports the items found in a number of its sub-modules. If you want a smaller subset of Data.ListLike, look at the documentation for its sub-modules and import the relevant one.
In most cases, functions here can act as drop-in replacements for their list-specific counterparts. They will use the same underlying implementations for lists, so there should be no performance difference.
You can make your own types instances of ListLike
as well. For more
details, see the notes for the ListLike
typeclass.
Creation & Basic Functions
singleton :: ListLike full item => item -> full Source #
Creates a single-element list out of an element
cons :: ListLike full item => item -> full -> full Source #
Like (:) for lists: adds an element to the beginning of a list
snoc :: ListLike full item => full -> item -> full Source #
Adds an element to the *end* of a ListLike
.
uncons :: ListLike full item => full -> Maybe (item, full) Source #
Extract head and tail, return Nothing if empty
init :: ListLike full item => full -> full Source #
All elements of the list except the last one. See also inits
.
List transformations
rigidMap :: ListLike full item => (item -> item) -> full -> full Source #
Like map
, but without the possibility of changing the type of
the item. This can have performance benefits for things such as
ByteStrings, since it will let the ByteString use its native
low-level map implementation.
intersperse :: ListLike full item => item -> full -> full Source #
Add an item between each element in the structure
Conversions
toList :: IsList l => l -> [Item l] #
The toList
function extracts a list of Item l
from the structure l
.
It should satisfy fromList . toList = id.
fromList :: IsList l => [Item l] -> l #
The fromList
function constructs the structure l
from the given
list of Item l
fromListLike :: (ListLike full item, ListLike full' item) => full -> full' Source #
Converts one ListLike to another. See also toList'
.
Default implementation is fromListLike = map id
Reducing lists (folds), from FoldableLL
foldl :: FoldableLL full item => (a -> item -> a) -> a -> full -> a Source #
Left-associative fold
foldl' :: FoldableLL full item => (a -> item -> a) -> a -> full -> a Source #
Strict version of foldl
.
foldl1 :: FoldableLL full item => (item -> item -> item) -> full -> item Source #
A variant of foldl
with no base case. Requires at least 1
list element.
foldr :: FoldableLL full item => (item -> b -> b) -> b -> full -> b Source #
Right-associative fold
foldr' :: FoldableLL full item => (item -> b -> b) -> b -> full -> b Source #
Strict version of foldr
foldr1 :: FoldableLL full item => (item -> item -> item) -> full -> item Source #
Like foldr
, but with no starting value
Special folds
concatMap :: (ListLike full item, ListLike full' item') => (item -> full') -> full -> full' Source #
Map a function over the items and concatenate the results.
See also rigidConcatMap
.
rigidConcatMap :: ListLike full item => (item -> full) -> full -> full Source #
Like concatMap
, but without the possibility of changing
the type of the item. This can have performance benefits
for some things such as ByteString.
any :: ListLike full item => (item -> Bool) -> full -> Bool Source #
True if any items satisfy the function
all :: ListLike full item => (item -> Bool) -> full -> Bool Source #
True if all items satisfy the function
fold :: (FoldableLL full item, Monoid item) => full -> item Source #
foldMap :: (FoldableLL full item, Monoid m) => (item -> m) -> full -> m Source #
Map each element to a monoid, then combine the results
Building lists
Scans
Accumulating maps
Infinite lists
iterate :: InfiniteListLike full item => (item -> item) -> item -> full Source #
An infinite list of repeated calls of the function to args
repeat :: InfiniteListLike full item => item -> full Source #
An infinite list where each element is the same
replicate :: ListLike full item => Int -> item -> full Source #
Generate a structure with the specified length with every element
set to the item passed in. See also genericReplicate
cycle :: InfiniteListLike full item => full -> full Source #
Converts a finite list into a circular one
Unfolding
Sublists
Extracting sublists
take :: ListLike full item => Int -> full -> full Source #
Takes the first n elements of the list. See also genericTake
.
drop :: ListLike full item => Int -> full -> full Source #
Drops the first n elements of the list. See also genericDrop
splitAt :: ListLike full item => Int -> full -> (full, full) Source #
Equivalent to (
. See also take
n xs, drop
n xs)genericSplitAt
.
takeWhile :: ListLike full item => (item -> Bool) -> full -> full Source #
Returns all elements at start of list that satisfy the function.
dropWhile :: ListLike full item => (item -> Bool) -> full -> full Source #
Drops all elements from the start of the list that satisfy the function.
dropWhileEnd :: ListLike full item => (item -> Bool) -> full -> full Source #
Drops all elements from the end of the list that satisfy the function.
group :: (ListLike full item, ListLike full' full, Eq item) => full -> full' Source #
Split a list into sublists, each which contains equal arguments.
For order-preserving types, concatenating these sublists will produce
the original list. See also groupBy
.
inits :: (ListLike full item, ListLike full' full) => full -> full' Source #
All initial segments of the list, shortest first
tails :: (ListLike full item, ListLike full' full) => full -> full' Source #
All final segnemts, longest first
Predicates
isPrefixOf :: (ListLike full item, Eq item) => full -> full -> Bool Source #
True when the first list is at the beginning of the second.
isSuffixOf :: (ListLike full item, Eq item) => full -> full -> Bool Source #
True when the first list is at the beginning of the second.
isInfixOf :: (ListLike full item, Eq item) => full -> full -> Bool Source #
True when the first list is wholly containted within the second
Modify based on predicate
stripPrefix :: (ListLike full item, Eq item) => full -> full -> Maybe full Source #
Remove a prefix from a listlike if possible
stripSuffix :: (ListLike full item, Eq item) => full -> full -> Maybe full Source #
Remove a suffix from a listlike if possible
Searching lists
Searching by equality
elem :: (ListLike full item, Eq item) => item -> full -> Bool Source #
True if the item occurs in the list
notElem :: (ListLike full item, Eq item) => item -> full -> Bool Source #
True if the item does not occur in the list
Searching with a predicate
find :: ListLike full item => (item -> Bool) -> full -> Maybe item Source #
Take a function and return the first matching element, or Nothing if there is no such element.
filter :: ListLike full item => (item -> Bool) -> full -> full Source #
Returns only the elements that satisfy the function.
Indexing lists
index :: ListLike full item => full -> Int -> item Source #
The element at 0-based index i. Raises an exception if i is out of bounds. Like (!!) for lists.
elemIndex :: (ListLike full item, Eq item) => item -> full -> Maybe Int Source #
Returns the index of the element, if it exists.
elemIndices :: (ListLike full item, Eq item, ListLike result Int) => item -> full -> result Source #
Returns the indices of the matching elements. See also
findIndices
findIndex :: ListLike full item => (item -> Bool) -> full -> Maybe Int Source #
Take a function and return the index of the first matching element, or Nothing if no element matches
findIndices :: (ListLike full item, ListLike result Int) => (item -> Bool) -> full -> result Source #
Returns the indices of all elements satisfying the function
Zipping and unzipping lists
zip :: (ListLike full item, ListLike fullb itemb, ListLike result (item, itemb)) => full -> fullb -> result Source #
Takes two lists and returns a list of corresponding pairs.
zipWith :: (ListLike full item, ListLike fullb itemb, ListLike result resultitem) => (item -> itemb -> resultitem) -> full -> fullb -> result Source #
Takes two lists and combines them with a custom combining function
unzip :: (ListLike full (itema, itemb), ListLike ra itema, ListLike rb itemb) => full -> (ra, rb) Source #
Converts a list of pairs into two separate lists of elements
Monadic Operations
sequence :: (ListLike full item, Applicative m, ListLike fullinp (m item)) => fullinp -> m full Source #
Evaluate each action in the sequence and collect the results
sequence_ :: (Monad m, FoldableLL full (m item)) => full -> m () Source #
mapM :: (ListLike full item, Applicative m, ListLike full' item') => (item -> m item') -> full -> m full' Source #
rigidMapM :: (ListLike full item, Monad m) => (item -> m item) -> full -> m full Source #
Like mapM
, but without the possibility of changing the type
of the item. This can have performance benefits with some types.
mapM_ :: (Monad m, FoldableLL full item) => (item -> m b) -> full -> m () Source #
A map in monad space, discarding results.
Input and Output
class ListLike full item => ListLikeIO full item | full -> item where Source #
An extension to ListLike
for those data types that support
I/O. These functions mirror those in System.IO for the most part. They
also share the same names; see the comments in Data.ListLike for help
importing them.
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
- hGetContents
- hGet
- hGetNonBlocking
- hPutStr
hGetLine :: Handle -> IO full Source #
Reads a line from the specified handle
hGetContents :: Handle -> IO full Source #
Read entire handle contents. May be done lazily like
hGetContents
.
hGet :: Handle -> Int -> IO full Source #
Read specified number of bytes. See hGet
for
particular semantics.
hGetNonBlocking :: Handle -> Int -> IO full Source #
Non-blocking read. See hGetNonBlocking
for more.
hPutStr :: Handle -> full -> IO () Source #
Writing entire data.
hPutStrLn :: Handle -> full -> IO () Source #
Write data plus newline character.
Read one line
getContents :: IO full Source #
Read entire content from stdin. See hGetContents
.
putStr :: full -> IO () Source #
Write data to stdout.
putStrLn :: full -> IO () Source #
Write data plus newline character to stdout.
interact :: (full -> full) -> IO () Source #
Interact with stdin and stdout by using a function to transform
input to output. May be lazy. See interact
for more.
readFile :: FilePath -> IO full Source #
Read file. May be lazy.
writeFile :: FilePath -> full -> IO () Source #
Write data to file.
appendFile :: FilePath -> full -> IO () Source #
Append data to file.
Instances
Special lists
Strings
fromString :: IsString a => String -> a #
lines :: (StringLike s, ListLike full s) => s -> full Source #
Breaks a string into a list of strings
words :: (StringLike s, ListLike full s) => s -> full Source #
Breaks a string into a list of words
show :: (StringLike s, Show a) => a -> s Source #
Generalize the Show
method t return any StringLike
.
fromStringLike :: (StringLike s, StringLike s') => s -> s' Source #
Deprecated: Use fromString . toString or something more efficient using local knowledge
fromText :: (StringLike s, StringLike Text) => Text -> s Source #
Override this to avoid extra String
conversions.
fromLazyText :: (StringLike s, StringLike Text) => Text -> s Source #
Override this to avoid extra String
conversions.
"Set" operations
nub :: (ListLike full item, Eq item) => full -> full Source #
Removes duplicate elements from the list. See also nubBy
delete :: (ListLike full item, Eq item) => item -> full -> full Source #
Removes the first instance of the element from the list.
See also deleteBy
deleteFirsts :: (ListLike full item, Eq item) => full -> full -> full Source #
List difference. Removes from the first list the first instance
of each element of the second list. See (\\)
and deleteFirstsBy
union :: (ListLike full item, Eq item) => full -> full -> full Source #
List union: the set of elements that occur in either list.
Duplicate elements in the first list will remain duplicate.
See also unionBy
.
intersect :: (ListLike full item, Eq item) => full -> full -> full Source #
List intersection: the set of elements that occur in both lists.
See also intersectBy
Ordered lists
sort :: (ListLike full item, Ord item) => full -> full Source #
Sorts the list. On data types that do not preserve ordering,
or enforce their own ordering, the result may not be what
you expect. See also sortBy
.
insert :: (ListLike full item, Ord item) => item -> full -> full Source #
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
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
.
Generalized functions
The "By" operations
User-supplied equality (replacing an Eq context)
nubBy :: ListLike full item => (item -> item -> Bool) -> full -> full Source #
Generic version of nub
deleteBy :: ListLike full item => (item -> item -> Bool) -> item -> full -> full Source #
Generic version of deleteBy
deleteFirstsBy :: ListLike full item => (item -> item -> Bool) -> full -> full -> full Source #
Generic version of deleteFirsts
unionBy :: ListLike full item => (item -> item -> Bool) -> full -> full -> full Source #
Generic version of union
intersectBy :: ListLike full item => (item -> item -> Bool) -> full -> full -> full Source #
Generic version of intersect
groupBy :: (ListLike full item, ListLike full' full, Eq item) => (item -> item -> Bool) -> full -> full' Source #
Generic version of group
.
User-supplied comparison (replacing an Ord context)
sortBy :: ListLike full item => (item -> item -> Ordering) -> full -> full Source #
Sort function taking a custom comparison function
insertBy :: ListLike full item => (item -> item -> Ordering) -> item -> full -> full Source #
Like insert
, but with a custom comparison function
The "generic" operations
genericLength :: (ListLike full item, Num a) => full -> a Source #
Length of the list
genericTake :: (ListLike full item, Integral a) => a -> full -> full Source #
Generic version of take
genericDrop :: (ListLike full item, Integral a) => a -> full -> full Source #
Generic version of drop
genericSplitAt :: (ListLike full item, Integral a) => a -> full -> (full, full) Source #
Generic version of splitAt
genericReplicate :: (ListLike full item, Integral a) => a -> item -> full Source #
Generic version of replicate
Notes on specific instances
Lists
Functions for operating on regular lists almost all use the native implementations in Data.List, Prelude, or similar standard modules. The exceptions are:
mapM
uses the defaultListLike
implementationhGet
does not exist forString
in the Haskell modules. It is implemented in terms of Data.ByteString.Lazy.hGetNonBlocking
is the same way.
Arrays
Array
is an instance of ListLike
. Here are some notes about it:
- The index you use must be an integral
ListLike
functions that take an index always take a 0-based index for compatibility with otherListLike
instances. This is translated by the instance functions into the proper offset from the bounds in the Array.ListLike
functions preserve the original Array index numbers when possible. Functions such ascons
will reduce the lower bound to do their job.snoc
andappend
increase the upper bound.drop
raises the lower bound andtake
lowers the upper bound.- Functions that change the length of the array by an amount not known
in advance, such as
filter
, will generate a new array with the lower bound set to 0. Furthermore, these functions cannot operate on infinite lists because they must know their length in order to generate the array.hGetContents
and its friends will therefore require the entire file to be read into memory before processing is possible. empty
,singleton
, andfromList
also generate an array with the lower bound set to 0.- Many of these functions will generate runtime exceptions if you have not assigned a value to every slot in the array.
ByteStrings
Both strict and lazy ByteStreams can be used with ListLike
.
ByteString ListLike instances operate on Word8
elements. This is because
both Data.ByteString.ByteString and Data.ByteString.Char8.ByteString have
the same underlying type. If you wish to use the Char8 representation,
the newtype wrappers CharString
and CharStringLazy
are available.
Most ListLike
operations map directly to ByteStream options. Notable
exceptions:
map
uses theListLike
implementation.rigidMap
is more efficient. The same goes forconcatMap
vs.rigidConcatMap
.isInfixOf
,sequence
,mapM
and similar monad operations,insert
,union
,intersect
,sortBy
, and similar functions are not implemented inByteStream
and use a naive default implementation.- The lazy ByteStream module implements fewer funtions than the strict ByteStream module. In some cases, default implementations are used. In others, notably related to I/O, the lazy ByteStreams are converted back and forth to strict ones as appropriate.
Instances
newtype CharString Source #
Newtype wrapper around Data.ByteString.Char8.ByteString, this allows for ListLike instances with Char elements.
CS | |
|
Instances
newtype CharStringLazy Source #
Newtype wrapper around Data.ByteString.Lazy.Char8.ByteString, this allows for ListLike instances with Char elements.
CSL | |
|
Instances
Base Typeclasses
The ListLike class
class (IsList full, item ~ Item full, FoldableLL full item, Monoid full) => ListLike full item | full -> item Source #
The class implementing list-like functions.
It is worth noting that types such as Map
can be instances of
ListLike
. Due to their specific ways of operating, they may not behave
in the expected way in some cases. For instance, cons
may not increase
the size of a map if the key you have given is already in the map; it will
just replace the value already there.
Implementators must define at least:
- singleton
- head
- tail
- null or genericLength
singleton, uncons, null | singleton, uncons, genericLength | singleton, head, tail, null | singleton, head, tail, genericLength