Data.Strict.Tuple

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 #

The type of strict pairs.

Constructors

!a :!: !b infix 2 |

#### Instances

Instances details

Assoc Pair # |
Instance details Defined in Data.Strict.Tuple Methods assoc :: Pair (Pair a b) c -> Pair a (Pair b c) # unassoc :: Pair a (Pair b c) -> Pair (Pair a b) c #
Swap Pair # |
Instance details Defined in Data.Strict.Tuple Methods swap :: Pair a b -> Pair b a #
Bifoldable Pair # |
Instance details Defined in Data.Strict.Tuple Methods bifold :: Monoid m => Pair m m -> m # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Pair a b -> m # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Pair a b -> c # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Pair a b -> c #
Bifunctor Pair # |
Instance details Defined in Data.Strict.Tuple Methods bimap :: (a -> b) -> (c -> d) -> Pair a c -> Pair b d # first :: (a -> b) -> Pair a c -> Pair b c # second :: (b -> c) -> Pair a b -> Pair a c #
Bitraversable Pair # |
Instance details Defined in Data.Strict.Tuple Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Pair a b -> f (Pair c d) #
Eq2 Pair # |
Instance details Defined in Data.Strict.Tuple Methods liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> Pair a c -> Pair b d -> Bool #
Ord2 Pair # |
Instance details Defined in Data.Strict.Tuple Methods liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> Pair a c -> Pair b d -> Ordering #
Read2 Pair # |
    >>> 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) # liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Pair a b] # liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (Pair a b) # liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [Pair a b] #
Show2 Pair # |
Instance details Defined in Data.Strict.Tuple Methods liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> Pair a b -> ShowS # liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [Pair a b] -> ShowS #
NFData2 Pair # |
Instance details Defined in Data.Strict.Tuple Methods liftRnf2 :: (a -> ()) -> (b -> ()) -> Pair a b -> () #
Hashable2 Pair # |
Instance details Defined in Data.Strict.Tuple Methods liftHashWithSalt2 :: (Int -> a -> Int) -> (Int -> b -> Int) -> Int -> Pair a b -> Int #
Generic1 (Pair a :: Type -> Type) # |
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-1mB1yRAtJfYEfaxRHR0qto" '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 # to1 :: Rep1 (Pair a) a0 -> Pair a a0 #
Eq a => Eq1 (Pair a) # |
Instance details Defined in Data.Strict.Tuple Methods liftEq :: (a0 -> b -> Bool) -> Pair a a0 -> Pair a b -> Bool #
Ord a => Ord1 (Pair a) # |
Instance details Defined in Data.Strict.Tuple Methods liftCompare :: (a0 -> b -> Ordering) -> Pair a a0 -> Pair a b -> Ordering #
Read a => Read1 (Pair a) # |
Instance details Defined in Data.Strict.Tuple Methods liftReadsPrec :: (Int -> ReadS a0) -> ReadS [a0] -> Int -> ReadS (Pair a a0) # liftReadList :: (Int -> ReadS a0) -> ReadS [a0] -> ReadS [Pair a a0] # liftReadPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec (Pair a a0) # liftReadListPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec [Pair a a0] #
Show a => Show1 (Pair a) # |
Instance details Defined in Data.Strict.Tuple Methods liftShowsPrec :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> Int -> Pair a a0 -> ShowS # liftShowList :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> [Pair a a0] -> ShowS #
NFData a => NFData1 (Pair a) # |
Instance details Defined in Data.Strict.Tuple Methods liftRnf :: (a0 -> ()) -> Pair a a0 -> () #
Functor (Pair e) # |
Instance details Defined in Data.Strict.Tuple Methods fmap :: (a -> b) -> Pair e a -> Pair e b # (<$) :: a -> Pair e b -> Pair e a #
Foldable (Pair e) # |
Instance details Defined in Data.Strict.Tuple Methods fold :: Monoid m => Pair e m -> m # foldMap :: Monoid m => (a -> m) -> Pair e a -> m # foldMap' :: Monoid m => (a -> m) -> Pair e a -> m # foldr :: (a -> b -> b) -> b -> Pair e a -> b # foldr' :: (a -> b -> b) -> b -> Pair e a -> b # foldl :: (b -> a -> b) -> b -> Pair e a -> b # foldl' :: (b -> a -> b) -> b -> Pair e a -> b # foldr1 :: (a -> a -> a) -> Pair e a -> a # foldl1 :: (a -> a -> a) -> Pair e a -> a # toList :: Pair e a -> [a] # null :: Pair e a -> Bool # length :: Pair e a -> Int # elem :: Eq a => a -> Pair e a -> Bool # maximum :: Ord a => Pair e a -> a # minimum :: Ord a => Pair e a -> a # sum :: Num a => Pair e a -> a # product :: Num a => Pair e a -> a #
Traversable (Pair e) # |
Instance details Defined in Data.Strict.Tuple Methods traverse :: Applicative f => (a -> f b) -> Pair e a -> f (Pair e b) # sequenceA :: Applicative f => Pair e (f a) -> f (Pair e a) # mapM :: Monad m => (a -> m b) -> Pair e a -> m (Pair e b) # sequence :: Monad m => Pair e (m a) -> m (Pair e a) #
Hashable a => Hashable1 (Pair a) # |
Instance details Defined in Data.Strict.Tuple Methods liftHashWithSalt :: (Int -> a0 -> Int) -> Int -> Pair a a0 -> Int #
(Binary a, Binary b) => Binary (Pair a b) # |
Instance details Defined in Data.Strict.Tuple Methods put :: Pair a b -> Put # get :: Get (Pair a b) # putList :: [Pair a b] -> Put #
(NFData a, NFData b) => NFData (Pair a b) # |
Instance details Defined in Data.Strict.Tuple Methods rnf :: Pair a b -> () #
(Monoid a, Monoid b) => Monoid (Pair a b) # |
Instance details Defined in Data.Strict.Tuple Methods mempty :: Pair a b # mappend :: Pair a b -> Pair a b -> Pair a b # mconcat :: [Pair a b] -> Pair a b #
(Semigroup a, Semigroup b) => Semigroup (Pair a b) # |
Instance details Defined in Data.Strict.Tuple Methods (<>) :: Pair a b -> Pair a b -> Pair a b # sconcat :: NonEmpty (Pair a b) -> Pair a b # stimes :: Integral b0 => b0 -> Pair a b -> Pair a b #
(Data a, Data b) => Data (Pair a b) # |
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) # gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Pair a b) # toConstr :: Pair a b -> Constr # dataTypeOf :: Pair a b -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Pair a b)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Pair a b)) # gmapT :: (forall b0. Data b0 => b0 -> b0) -> Pair a b -> Pair a b # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Pair a b -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Pair a b -> r # gmapQ :: (forall d. Data d => d -> u) -> Pair a b -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Pair a b -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Pair a b -> m (Pair a b) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Pair a b -> m (Pair a b) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Pair a b -> m (Pair a b) #
(Bounded a, Bounded b) => Bounded (Pair a b) # |
Instance details Defined in Data.Strict.Tuple Methods minBound :: Pair a b # maxBound :: Pair a b #
Generic (Pair a b) # |
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-1mB1yRAtJfYEfaxRHR0qto" '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 # to :: Rep (Pair a b) x -> Pair a b #
(Ix a, Ix b) => Ix (Pair a b) # |
Instance details Defined in Data.Strict.Tuple Methods range :: (Pair a b, Pair a b) -> [Pair a b] # index :: (Pair a b, Pair a b) -> Pair a b -> Int # unsafeIndex :: (Pair a b, Pair a b) -> Pair a b -> Int # inRange :: (Pair a b, Pair a b) -> Pair a b -> Bool # rangeSize :: (Pair a b, Pair a b) -> Int # unsafeRangeSize :: (Pair a b, Pair a b) -> Int #
(Read a, Read b) => Read (Pair a b) # |
Instance details Defined in Data.Strict.Tuple Methods readsPrec :: Int -> ReadS (Pair a b) # readList :: ReadS [Pair a b] # readPrec :: ReadPrec (Pair a b) # readListPrec :: ReadPrec [Pair a b] #
(Show a, Show b) => Show (Pair a b) # |
Instance details Defined in Data.Strict.Tuple Methods showsPrec :: Int -> Pair a b -> ShowS # show :: Pair a b -> String # showList :: [Pair a b] -> ShowS #
(Eq a, Eq b) => Eq (Pair a b) # |
Instance details Defined in Data.Strict.Tuple Methods (==) :: Pair a b -> Pair a b -> Bool # (/=) :: Pair a b -> Pair a b -> Bool #
(Ord a, Ord b) => Ord (Pair a b) # |
Instance details Defined in Data.Strict.Tuple Methods compare :: Pair a b -> Pair a b -> Ordering # (<) :: Pair a b -> Pair a b -> Bool # (<=) :: Pair a b -> Pair a b -> Bool # (>) :: Pair a b -> Pair a b -> Bool # (>=) :: Pair a b -> Pair a b -> Bool # max :: Pair a b -> Pair a b -> Pair a b # min :: Pair a b -> Pair a b -> Pair a b #
(Hashable a, Hashable b) => Hashable (Pair a b) # |
Instance details Defined in Data.Strict.Tuple Methods hashWithSalt :: Int -> Pair a b -> Int # hash :: Pair a b -> Int #
Strict (a, b) (Pair a b) # |
Instance details Defined in Data.Strict.Classes Methods toStrict :: (a, b) -> Pair a b # toLazy :: Pair a b -> (a, b) #
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-1mB1yRAtJfYEfaxRHR0qto" '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) # |
Instance details Defined in Data.Strict.Tuple type Rep (Pair a b) = D1 ('MetaData "Pair" "Data.Strict.Tuple" "strict-0.5.1-1mB1yRAtJfYEfaxRHR0qto" '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 #

fst :: Pair a b -> a #

Extract the first component of a strict pair.

snd :: Pair a b -> b #

Extract the second component of a strict pair.

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

Curry a function on strict pairs.

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

Convert a curried function to a function on strict pairs.

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

Analogous to `swap` from Data.Tuple

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

Zip for strict pairs (defined with zipWith).

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

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