{-# LANGUAGE CPP #-}
module Data.Pair where

#if __GLASGOW_HASKELL__ < 710
import Control.Applicative
#endif

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
showList :: [Pair a] -> ShowS
$cshowList :: forall a. Show a => [Pair a] -> ShowS
show :: Pair a -> String
$cshow :: forall a. Show a => Pair a -> String
showsPrec :: Int -> Pair a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> 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