basement-0.0.16: Foundation scrap box of array & string

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

Basement.Compat.IsList

Description

compat friendly version of IsList

Synopsis

- class IsList l where
  - type Item l
  - fromList :: [Item l] -> l
  - fromListN :: Int -> [Item l] -> l
  - toList :: l -> [Item l]

# Documentation

class IsList l where Source #

The `IsList` class and its methods are intended to be used in conjunction with the OverloadedLists extension.

Since: base-4.7.0.0

Minimal complete definition

fromList, toList

Associated Types

type Item l Source #

The `Item` type function returns the type of items of the structure `l`.

Methods

fromList :: [Item l] -> l Source #

The `fromList` function constructs the structure `l` from the given list of `Item l`

fromListN :: Int -> [Item l] -> l Source #

The `fromListN` function takes the input list's length and potentially uses it to construct the structure `l` more efficiently compared to `fromList`. If the given number does not equal to the input list's length the behaviour of `fromListN` is not specified.

    fromListN (length xs) xs == fromList xs

toList :: l -> [Item l] Source #

The `toList` function extracts a list of `Item l` from the structure `l`. It should satisfy fromList . toList = id.

#### Instances

Instances details

IsList Version | Since: base-4.8.0.0
Instance details Defined in GHC.IsList Associated Types type Item Version Source # Methods fromList :: [Item Version] -> Version Source # fromListN :: Int -> [Item Version] -> Version Source # toList :: Version -> [Item Version] Source #
IsList CallStack | Be aware that 'fromList . toList = id' only for unfrozen `CallStack`s, since `toList` removes frozenness information. Since: base-4.9.0.0
Instance details Defined in GHC.IsList Associated Types type Item CallStack Source # Methods fromList :: [Item CallStack] -> CallStack Source # fromListN :: Int -> [Item CallStack] -> CallStack Source # toList :: CallStack -> [Item CallStack] Source #
IsList AsciiString Source # |
Instance details Defined in Basement.Types.AsciiString Associated Types type Item AsciiString Source # Methods fromList :: [Item AsciiString] -> AsciiString Source # fromListN :: Int -> [Item AsciiString] -> AsciiString Source # toList :: AsciiString -> [Item AsciiString] Source #
IsList String Source # |
Instance details Defined in Basement.UTF8.Base Associated Types type Item String Source # Methods fromList :: [Item String] -> String Source # fromListN :: Int -> [Item String] -> String Source # toList :: String -> [Item String] Source #
IsList (ZipList a) | Since: base-4.15.0.0
Instance details Defined in GHC.IsList Associated Types type Item (ZipList a) Source # Methods fromList :: [Item (ZipList a)] -> ZipList a Source # fromListN :: Int -> [Item (ZipList a)] -> ZipList a Source # toList :: ZipList a -> [Item (ZipList a)] Source #
IsList (NonEmpty a) | Since: base-4.9.0.0
Instance details Defined in GHC.IsList Associated Types type Item (NonEmpty a) Source # Methods fromList :: [Item (NonEmpty a)] -> NonEmpty a Source # fromListN :: Int -> [Item (NonEmpty a)] -> NonEmpty a Source # toList :: NonEmpty a -> [Item (NonEmpty a)] Source #
PrimType ty => IsList (Block ty) Source # |
Instance details Defined in Basement.Block.Base Associated Types type Item (Block ty) Source # Methods fromList :: [Item (Block ty)] -> Block ty Source # fromListN :: Int -> [Item (Block ty)] -> Block ty Source # toList :: Block ty -> [Item (Block ty)] Source #
IsList (Array ty) Source # |
Instance details Defined in Basement.BoxedArray Associated Types type Item (Array ty) Source # Methods fromList :: [Item (Array ty)] -> Array ty Source # fromListN :: Int -> [Item (Array ty)] -> Array ty Source # toList :: Array ty -> [Item (Array ty)] Source #
IsList c => IsList (NonEmpty c) Source # |
Instance details Defined in Basement.NonEmpty Associated Types type Item (NonEmpty c) Source # Methods fromList :: [Item (NonEmpty c)] -> NonEmpty c Source # fromListN :: Int -> [Item (NonEmpty c)] -> NonEmpty c Source # toList :: NonEmpty c -> [Item (NonEmpty c)] Source #
PrimType ty => IsList (UArray ty) Source # |
Instance details Defined in Basement.UArray.Base Associated Types type Item (UArray ty) Source # Methods fromList :: [Item (UArray ty)] -> UArray ty Source # fromListN :: Int -> [Item (UArray ty)] -> UArray ty Source # toList :: UArray ty -> [Item (UArray ty)] Source #
IsList [a] | Since: base-4.7.0.0
Instance details Defined in GHC.IsList Associated Types type Item [a] Source # Methods fromList :: [Item [a]] -> [a] Source # fromListN :: Int -> [Item [a]] -> [a] Source # toList :: [a] -> [Item [a]] Source #