module Data.Pair where

import Control.Applicative

infixl 2  :/:

data Pair a = (:/:) {forall a. Pair a -> a
leftOf :: a, forall a. Pair a -> a
rightOf :: a}
  deriving (Int -> Pair a -> ShowS
[Pair a] -> ShowS
Pair a -> String
(Int -> Pair a -> ShowS)
-> (Pair a -> String) -> ([Pair a] -> ShowS) -> Show (Pair a)
forall a. Show a => Int -> Pair a -> ShowS
forall a. Show a => [Pair a] -> ShowS
forall a. Show a => Pair a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> Pair a -> ShowS
showsPrec :: Int -> Pair a -> ShowS
$cshow :: forall a. Show a => Pair a -> String
show :: Pair a -> String
$cshowList :: forall a. Show a => [Pair a] -> ShowS
showList :: [Pair a] -> ShowS
Show)

instance Functor Pair where
  fmap :: forall a b. (a -> b) -> Pair a -> Pair b
fmap a -> b
f (a
a :/: a
b) = a -> b
f a
a b -> b -> Pair b
forall a. a -> a -> Pair a
:/: a -> b
f a
b

instance Applicative Pair where
  pure :: forall a. a -> Pair a
pure a
a = a
a a -> a -> Pair a
forall a. a -> a -> Pair a
:/: a
a
  (a -> b
f :/: a -> b
g) <*> :: forall a b. Pair (a -> b) -> Pair a -> Pair b
<*> (a
a :/: a
b) = a -> b
f a
a b -> b -> Pair b
forall a. a -> a -> Pair a
:/: a -> b
g a
b