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 | None
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 #

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 #

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

Methods

fromList :: [Item l] -> l #

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

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

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] #

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

#### Instances

Instances details

IsList ByteArray | Since: base-4.17.0.0

Instance details

Defined in Data.Array.Byte

Associated Types

type Item ByteArray |
Instance details Defined in Data.Array.Byte type Item ByteArray = Word8

Methods

fromList :: [Item ByteArray] -> ByteArray #

fromListN :: Int -> [Item ByteArray] -> ByteArray #

toList :: ByteArray -> [Item ByteArray] #

IsList AsciiString # |

Instance details

Defined in Basement.Types.AsciiString

Associated Types

type Item AsciiString |
Instance details Defined in Basement.Types.AsciiString type Item AsciiString = Char7

Methods

fromList :: [Item AsciiString] -> AsciiString #

fromListN :: Int -> [Item AsciiString] -> AsciiString #

toList :: AsciiString -> [Item AsciiString] #

IsList String # |

Instance details

Defined in Basement.UTF8.Base

Associated Types

type Item String |
Instance details Defined in Basement.UTF8.Base type Item String = Char

Methods

fromList :: [Item String] -> String #

fromListN :: Int -> [Item String] -> String #

toList :: String -> [Item String] #

IsList Version | @since base-4.8.0.0

Instance details

Defined in GHC.Internal.IsList

Associated Types

type Item Version |
Instance details Defined in GHC.Internal.IsList type Item Version = Int

Methods

fromList :: [Item Version] -> Version #

fromListN :: Int -> [Item Version] -> Version #

toList :: Version -> [Item Version] #

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.Internal.IsList

Associated Types

type Item CallStack |
Instance details Defined in GHC.Internal.IsList type Item CallStack = (String, SrcLoc)

Methods

fromList :: [Item CallStack] -> CallStack #

fromListN :: Int -> [Item CallStack] -> CallStack #

toList :: CallStack -> [Item CallStack] #

PrimType ty => IsList (Block ty) # |

Instance details

Defined in Basement.Block.Base

Associated Types

type Item (Block ty) |
Instance details Defined in Basement.Block.Base type Item (Block ty) = ty

Methods

fromList :: [Item (Block ty)] -> Block ty #

fromListN :: Int -> [Item (Block ty)] -> Block ty #

toList :: Block ty -> [Item (Block ty)] #

IsList (Array ty) # |

Instance details

Defined in Basement.BoxedArray

Associated Types

type Item (Array ty) |
Instance details Defined in Basement.BoxedArray type Item (Array ty) = ty

Methods

fromList :: [Item (Array ty)] -> Array ty #

fromListN :: Int -> [Item (Array ty)] -> Array ty #

toList :: Array ty -> [Item (Array ty)] #

IsList c => IsList (NonEmpty c) # |

Instance details

Defined in Basement.NonEmpty

Associated Types

type Item (NonEmpty c) |
Instance details Defined in Basement.NonEmpty type Item (NonEmpty c) = Item c

Methods

fromList :: [Item (NonEmpty c)] -> NonEmpty c #

fromListN :: Int -> [Item (NonEmpty c)] -> NonEmpty c #

toList :: NonEmpty c -> [Item (NonEmpty c)] #

PrimType ty => IsList (UArray ty) # |

Instance details

Defined in Basement.UArray.Base

Associated Types

type Item (UArray ty) |
Instance details Defined in Basement.UArray.Base type Item (UArray ty) = ty

Methods

fromList :: [Item (UArray ty)] -> UArray ty #

fromListN :: Int -> [Item (UArray ty)] -> UArray ty #

toList :: UArray ty -> [Item (UArray ty)] #

IsList (NonEmpty a) | @since base-4.9.0.0

Instance details

Defined in GHC.Internal.IsList

Associated Types

type Item (NonEmpty a) |
Instance details Defined in GHC.Internal.IsList type Item (NonEmpty a) = a

Methods

fromList :: [Item (NonEmpty a)] -> NonEmpty a #

fromListN :: Int -> [Item (NonEmpty a)] -> NonEmpty a #

toList :: NonEmpty a -> [Item (NonEmpty a)] #

IsList (ZipList a) | @since base-4.15.0.0

Instance details

Defined in GHC.Internal.IsList

Associated Types

type Item (ZipList a) |
Instance details Defined in GHC.Internal.IsList type Item (ZipList a) = a

Methods

fromList :: [Item (ZipList a)] -> ZipList a #

fromListN :: Int -> [Item (ZipList a)] -> ZipList a #

toList :: ZipList a -> [Item (ZipList a)] #

IsList [a] | @since base-4.7.0.0

Instance details

Defined in GHC.Internal.IsList

Associated Types

type Item [a] |
Instance details Defined in GHC.Internal.IsList type Item [a] = a

Methods

fromList :: [Item [a]] -> [a] #

fromListN :: Int -> [Item [a]] -> [a] #

toList :: [a] -> [Item [a]] #