adaptive-containers-0.1: Self optimizing container typesSource codeContentsIndex
Data.Adaptive.Tuple
Stabilityexperimental
Maintainerdons@galois.com
Description

Self optimzing pair types.

This library statically adapts the polymorphic container representation of tuples to specific, more efficient representations, when instantiated with particular monomorphic types. It does this via an associated more efficient data type for each pair of elements you wish to store in your container.

That is, instead of representing '(Int,Char)' as:

            (,)
           /   \
       I# 3#   C# x#

A self-optimizing pair will unpack the constructors, yielding this data representation:

       PairIntChar 3# x#

Saving two indirections. The resulting structure should be both more time and space efficient than the generic polymorphic container it is derived from. For example, adaptive pairs use 8 bytes to store an Int and Char pair, while a lazy pair uses 24 bytes.

 > Prelude Size> unsafeSizeof ((42, 'x') :: (Int,Char))
 > 24
 Prelude Size> unsafeSizeof (pair 42 'x' :: Pair Int Char)
 > 8

You can inspect the size and layout of your adaptive structures using two scripts, one for measuring the size of a closure, described in http://ghcmutterings.wordpress.com/2009/02/, and vacuum-cairo, for rendering the heap structure explicitly http://hackage.haskell.org/cgi-bin/hackage-scripts/package/vacuum-cairo

Types that instantiate the Adapt class will self-adapt this way.

Self adaptive polymorphic containers are able to unpack their components, something not possible with, for example, strict polymorphic containers.

Synopsis
class Adapt a b where
data Pair a b
fst :: Pair a b -> a
snd :: Pair a b -> b
curry :: (Pair a b -> c) -> a -> b -> c
pair :: Adapt a b => a -> b -> Pair a b
uncurry :: Adapt a b => (a -> b -> c) -> Pair a b -> c
fromPair :: Adapt a b => Pair a b -> (a, b)
toPair :: Adapt a b => (a, b) -> Pair a b
Documentation
class Adapt a b whereSource
Representation-improving polymorphic tuples.
Associated Types
data Pair a b Source
Methods
fst :: Pair a b -> aSource
Extract the first component of a pair.
snd :: Pair a b -> bSource
Extract the second component of a pair.
curry :: (Pair a b -> c) -> a -> b -> cSource
curry converts an uncurried function to a curried function.
show/hide Instances
Adapt Char Char
Adapt Char Double
Adapt Char Double
Adapt Char Float
Adapt Char Float
Adapt Char Int
Adapt Char Int
Adapt Char Int8
Adapt Char Int8
Adapt Char Int16
Adapt Char Int16
Adapt Char Int32
Adapt Char Int32
Adapt Char Int64
Adapt Char Int64
Adapt Char Integer
Adapt Char Integer
Adapt Char Word
Adapt Char Word
Adapt Char Word8
Adapt Char Word8
Adapt Char Word16
Adapt Char Word16
Adapt Char Word32
Adapt Char Word32
Adapt Char Word64
Adapt Char Word64
Adapt Double Char
Adapt Double Char
Adapt Double Double
Adapt Double Float
Adapt Double Float
Adapt Double Int
Adapt Double Int
Adapt Double Int8
Adapt Double Int8
Adapt Double Int16
Adapt Double Int16
Adapt Double Int32
Adapt Double Int32
Adapt Double Int64
Adapt Double Int64
Adapt Double Integer
Adapt Double Integer
Adapt Double Word
Adapt Double Word
Adapt Double Word8
Adapt Double Word8
Adapt Double Word16
Adapt Double Word16
Adapt Double Word32
Adapt Double Word32
Adapt Double Word64
Adapt Double Word64
Adapt Float Char
Adapt Float Char
Adapt Float Double
Adapt Float Double
Adapt Float Float
Adapt Float Int
Adapt Float Int
Adapt Float Int8
Adapt Float Int8
Adapt Float Int16
Adapt Float Int16
Adapt Float Int32
Adapt Float Int32
Adapt Float Int64
Adapt Float Int64
Adapt Float Integer
Adapt Float Integer
Adapt Float Word
Adapt Float Word
Adapt Float Word8
Adapt Float Word8
Adapt Float Word16
Adapt Float Word16
Adapt Float Word32
Adapt Float Word32
Adapt Float Word64
Adapt Float Word64
Adapt Int Char
Adapt Int Char
Adapt Int Double
Adapt Int Double
Adapt Int Float
Adapt Int Float
Adapt Int Int
Adapt Int Int8
Adapt Int Int8
Adapt Int Int16
Adapt Int Int16
Adapt Int Int32
Adapt Int Int32
Adapt Int Int64
Adapt Int Int64
Adapt Int Integer
Adapt Int Integer
Adapt Int Word
Adapt Int Word
Adapt Int Word8
Adapt Int Word8
Adapt Int Word16
Adapt Int Word16
Adapt Int Word32
Adapt Int Word32
Adapt Int Word64
Adapt Int Word64
Adapt Int8 Char
Adapt Int8 Char
Adapt Int8 Double
Adapt Int8 Double
Adapt Int8 Float
Adapt Int8 Float
Adapt Int8 Int
Adapt Int8 Int
Adapt Int8 Int8
Adapt Int8 Int16
Adapt Int8 Int16
Adapt Int8 Int32
Adapt Int8 Int32
Adapt Int8 Int64
Adapt Int8 Int64
Adapt Int8 Integer
Adapt Int8 Integer
Adapt Int8 Word
Adapt Int8 Word
Adapt Int8 Word8
Adapt Int8 Word8
Adapt Int8 Word16
Adapt Int8 Word16
Adapt Int8 Word32
Adapt Int8 Word32
Adapt Int8 Word64
Adapt Int8 Word64
Adapt Int16 Char
Adapt Int16 Char
Adapt Int16 Double
Adapt Int16 Double
Adapt Int16 Float
Adapt Int16 Float
Adapt Int16 Int
Adapt Int16 Int
Adapt Int16 Int8
Adapt Int16 Int8
Adapt Int16 Int16
Adapt Int16 Int32
Adapt Int16 Int32
Adapt Int16 Int64
Adapt Int16 Int64
Adapt Int16 Integer
Adapt Int16 Integer
Adapt Int16 Word
Adapt Int16 Word
Adapt Int16 Word8
Adapt Int16 Word8
Adapt Int16 Word16
Adapt Int16 Word16
Adapt Int16 Word32
Adapt Int16 Word32
Adapt Int16 Word64
Adapt Int16 Word64
Adapt Int32 Char
Adapt Int32 Char
Adapt Int32 Double
Adapt Int32 Double
Adapt Int32 Float
Adapt Int32 Float
Adapt Int32 Int
Adapt Int32 Int
Adapt Int32 Int8
Adapt Int32 Int8
Adapt Int32 Int16
Adapt Int32 Int16
Adapt Int32 Int32
Adapt Int32 Int64
Adapt Int32 Int64
Adapt Int32 Integer
Adapt Int32 Integer
Adapt Int32 Word
Adapt Int32 Word
Adapt Int32 Word8
Adapt Int32 Word8
Adapt Int32 Word16
Adapt Int32 Word16
Adapt Int32 Word32
Adapt Int32 Word32
Adapt Int32 Word64
Adapt Int32 Word64
Adapt Int64 Char
Adapt Int64 Char
Adapt Int64 Double
Adapt Int64 Double
Adapt Int64 Float
Adapt Int64 Float
Adapt Int64 Int
Adapt Int64 Int
Adapt Int64 Int8
Adapt Int64 Int8
Adapt Int64 Int16
Adapt Int64 Int16
Adapt Int64 Int32
Adapt Int64 Int32
Adapt Int64 Int64
Adapt Int64 Integer
Adapt Int64 Integer
Adapt Int64 Word
Adapt Int64 Word
Adapt Int64 Word8
Adapt Int64 Word8
Adapt Int64 Word16
Adapt Int64 Word16
Adapt Int64 Word32
Adapt Int64 Word32
Adapt Int64 Word64
Adapt Int64 Word64
Adapt Integer Char
Adapt Integer Char
Adapt Integer Double
Adapt Integer Double
Adapt Integer Float
Adapt Integer Float
Adapt Integer Int
Adapt Integer Int
Adapt Integer Int8
Adapt Integer Int8
Adapt Integer Int16
Adapt Integer Int16
Adapt Integer Int32
Adapt Integer Int32
Adapt Integer Int64
Adapt Integer Int64
Adapt Integer Integer
Adapt Integer Word
Adapt Integer Word
Adapt Integer Word8
Adapt Integer Word8
Adapt Integer Word16
Adapt Integer Word16
Adapt Integer Word32
Adapt Integer Word32
Adapt Integer Word64
Adapt Integer Word64
Adapt Word Char
Adapt Word Char
Adapt Word Double
Adapt Word Double
Adapt Word Float
Adapt Word Float
Adapt Word Int
Adapt Word Int
Adapt Word Int8
Adapt Word Int8
Adapt Word Int16
Adapt Word Int16
Adapt Word Int32
Adapt Word Int32
Adapt Word Int64
Adapt Word Int64
Adapt Word Integer
Adapt Word Integer
Adapt Word Word
Adapt Word Word8
Adapt Word Word8
Adapt Word Word16
Adapt Word Word16
Adapt Word Word32
Adapt Word Word32
Adapt Word Word64
Adapt Word Word64
Adapt Word8 Char
Adapt Word8 Char
Adapt Word8 Double
Adapt Word8 Double
Adapt Word8 Float
Adapt Word8 Float
Adapt Word8 Int
Adapt Word8 Int
Adapt Word8 Int8
Adapt Word8 Int8
Adapt Word8 Int16
Adapt Word8 Int16
Adapt Word8 Int32
Adapt Word8 Int32
Adapt Word8 Int64
Adapt Word8 Int64
Adapt Word8 Integer
Adapt Word8 Integer
Adapt Word8 Word
Adapt Word8 Word
Adapt Word8 Word8
Adapt Word8 Word16
Adapt Word8 Word16
Adapt Word8 Word32
Adapt Word8 Word32
Adapt Word8 Word64
Adapt Word8 Word64
Adapt Word16 Char
Adapt Word16 Char
Adapt Word16 Double
Adapt Word16 Double
Adapt Word16 Float
Adapt Word16 Float
Adapt Word16 Int
Adapt Word16 Int
Adapt Word16 Int8
Adapt Word16 Int8
Adapt Word16 Int16
Adapt Word16 Int16
Adapt Word16 Int32
Adapt Word16 Int32
Adapt Word16 Int64
Adapt Word16 Int64
Adapt Word16 Integer
Adapt Word16 Integer
Adapt Word16 Word
Adapt Word16 Word
Adapt Word16 Word8
Adapt Word16 Word8
Adapt Word16 Word16
Adapt Word16 Word32
Adapt Word16 Word32
Adapt Word16 Word64
Adapt Word16 Word64
Adapt Word32 Char
Adapt Word32 Char
Adapt Word32 Double
Adapt Word32 Double
Adapt Word32 Float
Adapt Word32 Float
Adapt Word32 Int
Adapt Word32 Int
Adapt Word32 Int8
Adapt Word32 Int8
Adapt Word32 Int16
Adapt Word32 Int16
Adapt Word32 Int32
Adapt Word32 Int32
Adapt Word32 Int64
Adapt Word32 Int64
Adapt Word32 Integer
Adapt Word32 Integer
Adapt Word32 Word
Adapt Word32 Word
Adapt Word32 Word8
Adapt Word32 Word8
Adapt Word32 Word16
Adapt Word32 Word16
Adapt Word32 Word32
Adapt Word32 Word64
Adapt Word32 Word64
Adapt Word64 Char
Adapt Word64 Char
Adapt Word64 Double
Adapt Word64 Double
Adapt Word64 Float
Adapt Word64 Float
Adapt Word64 Int
Adapt Word64 Int
Adapt Word64 Int8
Adapt Word64 Int8
Adapt Word64 Int16
Adapt Word64 Int16
Adapt Word64 Int32
Adapt Word64 Int32
Adapt Word64 Int64
Adapt Word64 Int64
Adapt Word64 Integer
Adapt Word64 Integer
Adapt Word64 Word
Adapt Word64 Word
Adapt Word64 Word8
Adapt Word64 Word8
Adapt Word64 Word16
Adapt Word64 Word16
Adapt Word64 Word32
Adapt Word64 Word32
Adapt Word64 Word64
Adapt () ()
pair :: Adapt a b => a -> b -> Pair a bSource
Construct a new pair.
uncurry :: Adapt a b => (a -> b -> c) -> Pair a b -> cSource
uncurry converts a curried function to a function on pairs.
fromPair :: Adapt a b => Pair a b -> (a, b)Source
Convert an adaptive pair to a regular polymorphic tuple
toPair :: Adapt a b => (a, b) -> Pair a bSource
Convert a regular polymorphic tuple to an adaptive pair
Produced by Haddock version 2.4.2