data-fresh-0.2013.251.0: src/Data/Triplet.hs
module Data.Triplet where
import Control.Applicative
import Data.Foldable
import Data.Monoid
import Data.Traversable
data Triplet a = Triplet a a a
deriving (Eq, Read, Show)
instance Functor Triplet where
fmap f (Triplet l m r) = Triplet (f l) (f m) (f r)
instance Applicative Triplet where
pure x = Triplet x x x
Triplet fl fm fr <*> Triplet xl xm xr = Triplet (fl xl) (fm xm) (fr xr)
instance Foldable Triplet where
foldMap f (Triplet l m r) = mconcat . map f $ [l, m, r]
instance Traversable Triplet where
sequenceA (Triplet l m r) = Triplet <$> l <*> m <*> r