Agda
Safe HaskellNone
LanguageHaskell2010

Agda.Utils.Tuple

Synopsis

Documentation

(//) :: a -> b -> (a, b) infixr 4 Source #

Strict pairing.

(***) :: Arrow a => a b c -> a b' c' -> a (b, b') (c, c') infixr 3 #

Split the input between the two argument arrows and combine their output. Note that this is in general not a functor.

The default definition may be overridden with a more efficient version if desired.

  b ╭─────╮ b'
>───┼─ f ─┼───>
>───┼─ g ─┼───>
  c ╰─────╯ c'

(&&&) :: Arrow a => a b c -> a b c' -> a b (c, c') infixr 3 #

Fanout: send the input to both argument arrows and combine their output.

The default definition may be overridden with a more efficient version if desired.

    ╭───────╮ c
  b │ ┌─ f ─┼───>
>───┼─┤     │
    │ └─ g ─┼───>
    ╰───────╯ c'

first :: Bifunctor p => (a -> b) -> p a c -> p b c #

Map covariantly over the first argument.

first f ≡ bimap f id

Examples

Expand
>>> first toUpper ('j', 3)
('J',3)
>>> first toUpper (Left 'j')
Left 'J'

second :: Bifunctor p => (b -> c) -> p a b -> p a c #

Map covariantly over the second argument.

secondbimap id

Examples

Expand
>>> second (+1) ('j', 3)
('j',4)
>>> second (+1) (Right 3)
Right 4

sortPair :: Ord a => (a, a) -> (a, a) Source #

Order a pair.

fst3 :: (a, b, c) -> a Source #

snd3 :: (a, b, c) -> b Source #

thd3 :: (a, b, c) -> c Source #

swap :: (a, b) -> (b, a) #

Swap the components of a pair.

uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d Source #

uncurry4 :: (a -> b -> c -> d -> e) -> (a, b, c, d) -> e Source #

mapPairM :: Applicative m => (a -> m c) -> (b -> m d) -> (a, b) -> m (c, d) Source #

Monadic version of ***.

firstM :: Functor m => (a -> m c) -> (a, b) -> m (c, b) Source #

Monadic first.

secondM :: Functor m => (b -> m d) -> (a, b) -> m (a, d) Source #

Monadic second.

data Pair a Source #

Constructors

Pair a a 

Instances

Instances details
Applicative Pair Source # 
Instance details

Defined in Agda.Utils.Tuple

Methods

pure :: a -> Pair a #

(<*>) :: Pair (a -> b) -> Pair a -> Pair b #

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

(*>) :: Pair a -> Pair b -> Pair b #

(<*) :: Pair a -> Pair b -> Pair a #

Functor Pair Source # 
Instance details

Defined in Agda.Utils.Tuple

Methods

fmap :: (a -> b) -> Pair a -> Pair b #

(<$) :: a -> Pair b -> Pair a #

Foldable Pair Source # 
Instance details

Defined in Agda.Utils.Tuple

Methods

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

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

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

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

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

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

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

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

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

toList :: Pair a -> [a] #

null :: Pair a -> Bool #

length :: Pair a -> Int #

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

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

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

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

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

Traversable Pair Source # 
Instance details

Defined in Agda.Utils.Tuple

Methods

traverse :: Applicative f => (a -> f b) -> Pair a -> f (Pair b) #

sequenceA :: Applicative f => Pair (f a) -> f (Pair a) #

mapM :: Monad m => (a -> m b) -> Pair a -> m (Pair b) #

sequence :: Monad m => Pair (m a) -> m (Pair a) #

NFData a => NFData (Pair a) Source # 
Instance details

Defined in Agda.Utils.Tuple

Methods

rnf :: Pair a -> () #

Generic (Pair a) Source # 
Instance details

Defined in Agda.Utils.Tuple

Associated Types

type Rep (Pair a) 
Instance details

Defined in Agda.Utils.Tuple

Methods

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

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

Show a => Show (Pair a) Source # 
Instance details

Defined in Agda.Utils.Tuple

Methods

showsPrec :: Int -> Pair a -> ShowS #

show :: Pair a -> String #

showList :: [Pair a] -> ShowS #

Eq a => Eq (Pair a) Source # 
Instance details

Defined in Agda.Utils.Tuple

Methods

(==) :: Pair a -> Pair a -> Bool #

(/=) :: Pair a -> Pair a -> Bool #

type Rep (Pair a) Source # 
Instance details

Defined in Agda.Utils.Tuple