list package:ListLike

List-like destructor (like Data.Maybe.maybe)
Generalized support for list-like structures 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 Haskell lists, Arrays, ByteStrings, and lazy ByteStrings. Custom types can easily be made ListLike instances as well. ListLike also provides for String-like types, such as String and ByteString, for types that support input and output, and for types that can handle infinite lists.
Generic operations over list-like structures Written by John Goerzen, jgoerzen@complete.org Please start with the introduction at Data.ListLike#intro.
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
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
A version of ListLike with a single type parameter, the item type is obtained using the Item type function from IsList.
An extension to ListLike for those data types that are capable of dealing with infinite lists. Some ListLike functions are capable of working with finite or infinite lists. The functions here require infinite list capability in order to work at all.
The fromList function constructs the structure l from the given list of Item l
Converts one ListLike to another. See also toList'. Default implementation is fromListLike = map id
The toList function extracts a list of Item l from the structure l. It should satisfy fromList . toList = id.
Generates the structure from a list.
Converts the structure to a list. This is logically equivolent to fromListLike, but may have a more optimized implementation. These two functions are now retired in favor of the methods of IsList, but they are retained here because some instances still use this implementation.
ListLike instances for DList
ListLike instances for FMList