strict-0.5.1: Strict data types and String IO.

Safe Haskell | Safe
Language | Haskell2010

Data.Strict.Tuple

Description

The strict variant of the standard Haskell pairs and the corresponding variants of the functions from Data.Tuple.

Note that unlike regular Haskell pairs, `(x :!: _|_) = (_|_ :!: y) = _|_`

Synopsis

- data Pair a b = !a :!: !b
- type (:!:) = Pair
- fst :: Pair a b -> a
- snd :: Pair a b -> b
- curry :: (Pair a b -> c) -> a -> b -> c
- uncurry :: (a -> b -> c) -> Pair a b -> c
- swap :: Pair a b -> Pair b a
- zip :: [a] -> [b] -> [Pair a b]
- unzip :: [Pair a b] -> ([a], [b])

# Documentation

data Pair a b Source #

The type of strict pairs.

Constructors

!a :!: !b infix 2 |

#### Instances

Instances details

Assoc Pair Source # |
Instance details Defined in Data.Strict.Tuple Methods assoc :: Pair (Pair a b) c -> Pair a (Pair b c) Source # unassoc :: Pair a (Pair b c) -> Pair (Pair a b) c Source #
Swap Pair Source # |
Instance details Defined in Data.Strict.Tuple Methods swap :: Pair a b -> Pair b a Source #
Bifoldable Pair Source # |
Instance details Defined in Data.Strict.Tuple Methods bifold :: Monoid m => Pair m m -> m Source # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Pair a b -> m Source # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Pair a b -> c Source # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Pair a b -> c Source #
Bifunctor Pair Source # |
Instance details Defined in Data.Strict.Tuple Methods bimap :: (a -> b) -> (c -> d) -> Pair a c -> Pair b d Source # first :: (a -> b) -> Pair a c -> Pair b c Source # second :: (b -> c) -> Pair a b -> Pair a c Source #
Bitraversable Pair Source # |
Instance details Defined in Data.Strict.Tuple Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Pair a b -> f (Pair c d) Source #
Eq2 Pair Source # |
Instance details Defined in Data.Strict.Tuple Methods liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> Pair a c -> Pair b d -> Bool Source #
Ord2 Pair Source # |
Instance details Defined in Data.Strict.Tuple Methods liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> Pair a c -> Pair b d -> Ordering Source #

Read2 Pair Source #

    >>> readsPrec2 0 "'a' :!: ('b' :!: 'c')" :: [(Pair Char (Pair Char Char), String)]
    [('a' :!: ('b' :!: 'c'),"")]

    >>> readsPrec2 0 "('a' :!: 'b') :!: 'c'" :: [(Pair (Pair Char Char) Char, String)]
    [(('a' :!: 'b') :!: 'c',"")]

Instance details

Defined in Data.Strict.Tuple

Methods

liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (Pair a b) Source #

liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Pair a b] Source #

liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (Pair a b) Source #

liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [Pair a b] Source #

Show2 Pair Source # |
Instance details Defined in Data.Strict.Tuple Methods liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> Pair a b -> ShowS Source # liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [Pair a b] -> ShowS Source #
NFData2 Pair Source # |
Instance details Defined in Data.Strict.Tuple Methods liftRnf2 :: (a -> ()) -> (b -> ()) -> Pair a b -> () Source #
Hashable2 Pair Source # |
Instance details Defined in Data.Strict.Tuple Methods liftHashWithSalt2 :: (Int -> a -> Int) -> (Int -> b -> Int) -> Int -> Pair a b -> Int Source #
Generic1 (Pair a :: Type -> Type) Source # |

Instance details

Defined in Data.Strict.Tuple

Associated Types

type Rep1 (Pair a :: Type -> Type) |

Instance details

Defined in Data.Strict.Tuple

type Rep1 (Pair a :: Type -> Type) = D1 ('MetaData "Pair" "Data.Strict.Tuple" "strict-0.5.1-6zHJYgY6KC0J8ARV1Lf80b" 'False) (C1 ('MetaCons ":!:" ('InfixI 'NotAssociative 2) 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) Par1))

Methods

from1 :: Pair a a0 -> Rep1 (Pair a) a0 Source #

to1 :: Rep1 (Pair a) a0 -> Pair a a0 Source #

Eq a => Eq1 (Pair a) Source # |
Instance details Defined in Data.Strict.Tuple Methods liftEq :: (a0 -> b -> Bool) -> Pair a a0 -> Pair a b -> Bool Source #
Ord a => Ord1 (Pair a) Source # |
Instance details Defined in Data.Strict.Tuple Methods liftCompare :: (a0 -> b -> Ordering) -> Pair a a0 -> Pair a b -> Ordering Source #
Read a => Read1 (Pair a) Source # |
Instance details Defined in Data.Strict.Tuple Methods liftReadsPrec :: (Int -> ReadS a0) -> ReadS [a0] -> Int -> ReadS (Pair a a0) Source # liftReadList :: (Int -> ReadS a0) -> ReadS [a0] -> ReadS [Pair a a0] Source # liftReadPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec (Pair a a0) Source # liftReadListPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec [Pair a a0] Source #
Show a => Show1 (Pair a) Source # |
Instance details Defined in Data.Strict.Tuple Methods liftShowsPrec :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> Int -> Pair a a0 -> ShowS Source # liftShowList :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> [Pair a a0] -> ShowS Source #
NFData a => NFData1 (Pair a) Source # |
Instance details Defined in Data.Strict.Tuple Methods liftRnf :: (a0 -> ()) -> Pair a a0 -> () Source #
Functor (Pair e) Source # |
Instance details Defined in Data.Strict.Tuple Methods fmap :: (a -> b) -> Pair e a -> Pair e b Source # (<$) :: a -> Pair e b -> Pair e a Source #
Foldable (Pair e) Source # |

Instance details

Defined in Data.Strict.Tuple

Methods

fold :: Monoid m => Pair e m -> m Source #

foldMap :: Monoid m => (a -> m) -> Pair e a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Pair e a -> m Source #

foldr :: (a -> b -> b) -> b -> Pair e a -> b Source #

foldr' :: (a -> b -> b) -> b -> Pair e a -> b Source #

foldl :: (b -> a -> b) -> b -> Pair e a -> b Source #

foldl' :: (b -> a -> b) -> b -> Pair e a -> b Source #

foldr1 :: (a -> a -> a) -> Pair e a -> a Source #

foldl1 :: (a -> a -> a) -> Pair e a -> a Source #

toList :: Pair e a -> [a] Source #

null :: Pair e a -> Bool Source #

length :: Pair e a -> Int Source #

elem :: Eq a => a -> Pair e a -> Bool Source #

maximum :: Ord a => Pair e a -> a Source #

minimum :: Ord a => Pair e a -> a Source #

sum :: Num a => Pair e a -> a Source #

product :: Num a => Pair e a -> a Source #

Traversable (Pair e) Source # |
Instance details Defined in Data.Strict.Tuple Methods traverse :: Applicative f => (a -> f b) -> Pair e a -> f (Pair e b) Source # sequenceA :: Applicative f => Pair e (f a) -> f (Pair e a) Source # mapM :: Monad m => (a -> m b) -> Pair e a -> m (Pair e b) Source # sequence :: Monad m => Pair e (m a) -> m (Pair e a) Source #
Hashable a => Hashable1 (Pair a) Source # |
Instance details Defined in Data.Strict.Tuple Methods liftHashWithSalt :: (Int -> a0 -> Int) -> Int -> Pair a a0 -> Int Source #
(Binary a, Binary b) => Binary (Pair a b) Source # |
Instance details Defined in Data.Strict.Tuple Methods put :: Pair a b -> Put Source # get :: Get (Pair a b) Source # putList :: [Pair a b] -> Put Source #
(NFData a, NFData b) => NFData (Pair a b) Source # |
Instance details Defined in Data.Strict.Tuple Methods rnf :: Pair a b -> () Source #
(Monoid a, Monoid b) => Monoid (Pair a b) Source # |
Instance details Defined in Data.Strict.Tuple Methods mempty :: Pair a b Source # mappend :: Pair a b -> Pair a b -> Pair a b Source # mconcat :: [Pair a b] -> Pair a b Source #
(Semigroup a, Semigroup b) => Semigroup (Pair a b) Source # |
Instance details Defined in Data.Strict.Tuple Methods (<>) :: Pair a b -> Pair a b -> Pair a b Source # sconcat :: NonEmpty (Pair a b) -> Pair a b Source # stimes :: Integral b0 => b0 -> Pair a b -> Pair a b Source #
(Data a, Data b) => Data (Pair a b) Source # |

Instance details

Defined in Data.Strict.Tuple

Methods

gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Pair a b -> c (Pair a b) Source #

gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Pair a b) Source #

toConstr :: Pair a b -> Constr Source #

dataTypeOf :: Pair a b -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Pair a b)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Pair a b)) Source #

gmapT :: (forall b0. Data b0 => b0 -> b0) -> Pair a b -> Pair a b Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Pair a b -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Pair a b -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Pair a b -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Pair a b -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Pair a b -> m (Pair a b) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Pair a b -> m (Pair a b) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Pair a b -> m (Pair a b) Source #

(Bounded a, Bounded b) => Bounded (Pair a b) Source # |
Instance details Defined in Data.Strict.Tuple Methods minBound :: Pair a b Source # maxBound :: Pair a b Source #
Generic (Pair a b) Source # |

Instance details

Defined in Data.Strict.Tuple

Associated Types

type Rep (Pair a b) |

Instance details

Defined in Data.Strict.Tuple

type Rep (Pair a b) = D1 ('MetaData "Pair" "Data.Strict.Tuple" "strict-0.5.1-6zHJYgY6KC0J8ARV1Lf80b" 'False) (C1 ('MetaCons ":!:" ('InfixI 'NotAssociative 2) 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b)))

Methods

from :: Pair a b -> Rep (Pair a b) x Source #

to :: Rep (Pair a b) x -> Pair a b Source #

(Ix a, Ix b) => Ix (Pair a b) Source # |
Instance details Defined in Data.Strict.Tuple Methods range :: (Pair a b, Pair a b) -> [Pair a b] Source # index :: (Pair a b, Pair a b) -> Pair a b -> Int Source # unsafeIndex :: (Pair a b, Pair a b) -> Pair a b -> Int Source # inRange :: (Pair a b, Pair a b) -> Pair a b -> Bool Source # rangeSize :: (Pair a b, Pair a b) -> Int Source # unsafeRangeSize :: (Pair a b, Pair a b) -> Int Source #
(Read a, Read b) => Read (Pair a b) Source # |
Instance details Defined in Data.Strict.Tuple Methods readsPrec :: Int -> ReadS (Pair a b) Source # readList :: ReadS [Pair a b] Source # readPrec :: ReadPrec (Pair a b) Source # readListPrec :: ReadPrec [Pair a b] Source #
(Show a, Show b) => Show (Pair a b) Source # |
Instance details Defined in Data.Strict.Tuple Methods showsPrec :: Int -> Pair a b -> ShowS Source # show :: Pair a b -> String Source # showList :: [Pair a b] -> ShowS Source #
(Eq a, Eq b) => Eq (Pair a b) Source # |
Instance details Defined in Data.Strict.Tuple Methods (==) :: Pair a b -> Pair a b -> Bool Source # (/=) :: Pair a b -> Pair a b -> Bool Source #
(Ord a, Ord b) => Ord (Pair a b) Source # |
Instance details Defined in Data.Strict.Tuple Methods compare :: Pair a b -> Pair a b -> Ordering Source # (<) :: Pair a b -> Pair a b -> Bool Source # (<=) :: Pair a b -> Pair a b -> Bool Source # (>) :: Pair a b -> Pair a b -> Bool Source # (>=) :: Pair a b -> Pair a b -> Bool Source # max :: Pair a b -> Pair a b -> Pair a b Source # min :: Pair a b -> Pair a b -> Pair a b Source #
(Hashable a, Hashable b) => Hashable (Pair a b) Source # |
Instance details Defined in Data.Strict.Tuple Methods hashWithSalt :: Int -> Pair a b -> Int Source # hash :: Pair a b -> Int Source #
Strict (a, b) (Pair a b) Source # |
Instance details Defined in Data.Strict.Classes Methods toStrict :: (a, b) -> Pair a b Source # toLazy :: Pair a b -> (a, b) Source #
type Rep1 (Pair a :: Type -> Type) Source # |

Instance details

Defined in Data.Strict.Tuple

type Rep1 (Pair a :: Type -> Type) = D1 ('MetaData "Pair" "Data.Strict.Tuple" "strict-0.5.1-6zHJYgY6KC0J8ARV1Lf80b" 'False) (C1 ('MetaCons ":!:" ('InfixI 'NotAssociative 2) 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) Par1))

type Rep (Pair a b) Source # |

Instance details

Defined in Data.Strict.Tuple

type Rep (Pair a b) = D1 ('MetaData "Pair" "Data.Strict.Tuple" "strict-0.5.1-6zHJYgY6KC0J8ARV1Lf80b" 'False) (C1 ('MetaCons ":!:" ('InfixI 'NotAssociative 2) 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b)))

type (:!:) = Pair infix 2 Source #

fst :: Pair a b -> a Source #

Extract the first component of a strict pair.

snd :: Pair a b -> b Source #

Extract the second component of a strict pair.

curry :: (Pair a b -> c) -> a -> b -> c Source #

Curry a function on strict pairs.

uncurry :: (a -> b -> c) -> Pair a b -> c Source #

Convert a curried function to a function on strict pairs.

swap :: Pair a b -> Pair b a Source #

Analogous to `swap` from Data.Tuple

zip :: [a] -> [b] -> [Pair a b] Source #

Zip for strict pairs (defined with zipWith).

unzip :: [Pair a b] -> ([a], [b]) Source #

Unzip for stict pairs into a (lazy) pair of lists.