{-# LANGUAGE DeriveFoldable, DeriveFunctor, DeriveTraversable #-} module Data.Entry (Entry(..)) where import Data.Bifunctor (Bifunctor (..)) import Data.Function (on) import Data.Ord (comparing) data Entry p a = Entry { Entry p a -> p priority :: !p, Entry p a -> a payload :: a } deriving (ReadPrec [Entry p a] ReadPrec (Entry p a) Int -> ReadS (Entry p a) ReadS [Entry p a] (Int -> ReadS (Entry p a)) -> ReadS [Entry p a] -> ReadPrec (Entry p a) -> ReadPrec [Entry p a] -> Read (Entry p a) forall a. (Int -> ReadS a) -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a forall p a. (Read p, Read a) => ReadPrec [Entry p a] forall p a. (Read p, Read a) => ReadPrec (Entry p a) forall p a. (Read p, Read a) => Int -> ReadS (Entry p a) forall p a. (Read p, Read a) => ReadS [Entry p a] readListPrec :: ReadPrec [Entry p a] $creadListPrec :: forall p a. (Read p, Read a) => ReadPrec [Entry p a] readPrec :: ReadPrec (Entry p a) $creadPrec :: forall p a. (Read p, Read a) => ReadPrec (Entry p a) readList :: ReadS [Entry p a] $creadList :: forall p a. (Read p, Read a) => ReadS [Entry p a] readsPrec :: Int -> ReadS (Entry p a) $creadsPrec :: forall p a. (Read p, Read a) => Int -> ReadS (Entry p a) Read, Int -> Entry p a -> ShowS [Entry p a] -> ShowS Entry p a -> String (Int -> Entry p a -> ShowS) -> (Entry p a -> String) -> ([Entry p a] -> ShowS) -> Show (Entry p a) forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a forall p a. (Show p, Show a) => Int -> Entry p a -> ShowS forall p a. (Show p, Show a) => [Entry p a] -> ShowS forall p a. (Show p, Show a) => Entry p a -> String showList :: [Entry p a] -> ShowS $cshowList :: forall p a. (Show p, Show a) => [Entry p a] -> ShowS show :: Entry p a -> String $cshow :: forall p a. (Show p, Show a) => Entry p a -> String showsPrec :: Int -> Entry p a -> ShowS $cshowsPrec :: forall p a. (Show p, Show a) => Int -> Entry p a -> ShowS Show, a -> Entry p b -> Entry p a (a -> b) -> Entry p a -> Entry p b (forall a b. (a -> b) -> Entry p a -> Entry p b) -> (forall a b. a -> Entry p b -> Entry p a) -> Functor (Entry p) forall a b. a -> Entry p b -> Entry p a forall a b. (a -> b) -> Entry p a -> Entry p b forall p a b. a -> Entry p b -> Entry p a forall p a b. (a -> b) -> Entry p a -> Entry p b forall (f :: * -> *). (forall a b. (a -> b) -> f a -> f b) -> (forall a b. a -> f b -> f a) -> Functor f <$ :: a -> Entry p b -> Entry p a $c<$ :: forall p a b. a -> Entry p b -> Entry p a fmap :: (a -> b) -> Entry p a -> Entry p b $cfmap :: forall p a b. (a -> b) -> Entry p a -> Entry p b Functor, Entry p a -> Bool (a -> m) -> Entry p a -> m (a -> b -> b) -> b -> Entry p a -> b (forall m. Monoid m => Entry p m -> m) -> (forall m a. Monoid m => (a -> m) -> Entry p a -> m) -> (forall m a. Monoid m => (a -> m) -> Entry p a -> m) -> (forall a b. (a -> b -> b) -> b -> Entry p a -> b) -> (forall a b. (a -> b -> b) -> b -> Entry p a -> b) -> (forall b a. (b -> a -> b) -> b -> Entry p a -> b) -> (forall b a. (b -> a -> b) -> b -> Entry p a -> b) -> (forall a. (a -> a -> a) -> Entry p a -> a) -> (forall a. (a -> a -> a) -> Entry p a -> a) -> (forall a. Entry p a -> [a]) -> (forall a. Entry p a -> Bool) -> (forall a. Entry p a -> Int) -> (forall a. Eq a => a -> Entry p a -> Bool) -> (forall a. Ord a => Entry p a -> a) -> (forall a. Ord a => Entry p a -> a) -> (forall a. Num a => Entry p a -> a) -> (forall a. Num a => Entry p a -> a) -> Foldable (Entry p) forall a. Eq a => a -> Entry p a -> Bool forall a. Num a => Entry p a -> a forall a. Ord a => Entry p a -> a forall m. Monoid m => Entry p m -> m forall a. Entry p a -> Bool forall a. Entry p a -> Int forall a. Entry p a -> [a] forall a. (a -> a -> a) -> Entry p a -> a forall p a. Eq a => a -> Entry p a -> Bool forall p a. Num a => Entry p a -> a forall p a. Ord a => Entry p a -> a forall m a. Monoid m => (a -> m) -> Entry p a -> m forall p m. Monoid m => Entry p m -> m forall p a. Entry p a -> Bool forall p a. Entry p a -> Int forall p a. Entry p a -> [a] forall b a. (b -> a -> b) -> b -> Entry p a -> b forall a b. (a -> b -> b) -> b -> Entry p a -> b forall p a. (a -> a -> a) -> Entry p a -> a forall p m a. Monoid m => (a -> m) -> Entry p a -> m forall p b a. (b -> a -> b) -> b -> Entry p a -> b forall p a b. (a -> b -> b) -> b -> Entry p a -> b forall (t :: * -> *). (forall m. Monoid m => t m -> m) -> (forall m a. Monoid m => (a -> m) -> t a -> m) -> (forall m a. Monoid m => (a -> m) -> t a -> m) -> (forall a b. (a -> b -> b) -> b -> t a -> b) -> (forall a b. (a -> b -> b) -> b -> t a -> b) -> (forall b a. (b -> a -> b) -> b -> t a -> b) -> (forall b a. (b -> a -> b) -> b -> t a -> b) -> (forall a. (a -> a -> a) -> t a -> a) -> (forall a. (a -> a -> a) -> t a -> a) -> (forall a. t a -> [a]) -> (forall a. t a -> Bool) -> (forall a. t a -> Int) -> (forall a. Eq a => a -> t a -> Bool) -> (forall a. Ord a => t a -> a) -> (forall a. Ord a => t a -> a) -> (forall a. Num a => t a -> a) -> (forall a. Num a => t a -> a) -> Foldable t product :: Entry p a -> a $cproduct :: forall p a. Num a => Entry p a -> a sum :: Entry p a -> a $csum :: forall p a. Num a => Entry p a -> a minimum :: Entry p a -> a $cminimum :: forall p a. Ord a => Entry p a -> a maximum :: Entry p a -> a $cmaximum :: forall p a. Ord a => Entry p a -> a elem :: a -> Entry p a -> Bool $celem :: forall p a. Eq a => a -> Entry p a -> Bool length :: Entry p a -> Int $clength :: forall p a. Entry p a -> Int null :: Entry p a -> Bool $cnull :: forall p a. Entry p a -> Bool toList :: Entry p a -> [a] $ctoList :: forall p a. Entry p a -> [a] foldl1 :: (a -> a -> a) -> Entry p a -> a $cfoldl1 :: forall p a. (a -> a -> a) -> Entry p a -> a foldr1 :: (a -> a -> a) -> Entry p a -> a $cfoldr1 :: forall p a. (a -> a -> a) -> Entry p a -> a foldl' :: (b -> a -> b) -> b -> Entry p a -> b $cfoldl' :: forall p b a. (b -> a -> b) -> b -> Entry p a -> b foldl :: (b -> a -> b) -> b -> Entry p a -> b $cfoldl :: forall p b a. (b -> a -> b) -> b -> Entry p a -> b foldr' :: (a -> b -> b) -> b -> Entry p a -> b $cfoldr' :: forall p a b. (a -> b -> b) -> b -> Entry p a -> b foldr :: (a -> b -> b) -> b -> Entry p a -> b $cfoldr :: forall p a b. (a -> b -> b) -> b -> Entry p a -> b foldMap' :: (a -> m) -> Entry p a -> m $cfoldMap' :: forall p m a. Monoid m => (a -> m) -> Entry p a -> m foldMap :: (a -> m) -> Entry p a -> m $cfoldMap :: forall p m a. Monoid m => (a -> m) -> Entry p a -> m fold :: Entry p m -> m $cfold :: forall p m. Monoid m => Entry p m -> m Foldable, Functor (Entry p) Foldable (Entry p) Functor (Entry p) -> Foldable (Entry p) -> (forall (f :: * -> *) a b. Applicative f => (a -> f b) -> Entry p a -> f (Entry p b)) -> (forall (f :: * -> *) a. Applicative f => Entry p (f a) -> f (Entry p a)) -> (forall (m :: * -> *) a b. Monad m => (a -> m b) -> Entry p a -> m (Entry p b)) -> (forall (m :: * -> *) a. Monad m => Entry p (m a) -> m (Entry p a)) -> Traversable (Entry p) (a -> f b) -> Entry p a -> f (Entry p b) forall p. Functor (Entry p) forall p. Foldable (Entry p) forall p (m :: * -> *) a. Monad m => Entry p (m a) -> m (Entry p a) forall p (f :: * -> *) a. Applicative f => Entry p (f a) -> f (Entry p a) forall p (m :: * -> *) a b. Monad m => (a -> m b) -> Entry p a -> m (Entry p b) forall p (f :: * -> *) a b. Applicative f => (a -> f b) -> Entry p a -> f (Entry p b) forall (t :: * -> *). Functor t -> Foldable t -> (forall (f :: * -> *) a b. Applicative f => (a -> f b) -> t a -> f (t b)) -> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a)) -> (forall (m :: * -> *) a b. Monad m => (a -> m b) -> t a -> m (t b)) -> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a)) -> Traversable t forall (m :: * -> *) a. Monad m => Entry p (m a) -> m (Entry p a) forall (f :: * -> *) a. Applicative f => Entry p (f a) -> f (Entry p a) forall (m :: * -> *) a b. Monad m => (a -> m b) -> Entry p a -> m (Entry p b) forall (f :: * -> *) a b. Applicative f => (a -> f b) -> Entry p a -> f (Entry p b) sequence :: Entry p (m a) -> m (Entry p a) $csequence :: forall p (m :: * -> *) a. Monad m => Entry p (m a) -> m (Entry p a) mapM :: (a -> m b) -> Entry p a -> m (Entry p b) $cmapM :: forall p (m :: * -> *) a b. Monad m => (a -> m b) -> Entry p a -> m (Entry p b) sequenceA :: Entry p (f a) -> f (Entry p a) $csequenceA :: forall p (f :: * -> *) a. Applicative f => Entry p (f a) -> f (Entry p a) traverse :: (a -> f b) -> Entry p a -> f (Entry p b) $ctraverse :: forall p (f :: * -> *) a b. Applicative f => (a -> f b) -> Entry p a -> f (Entry p b) $cp2Traversable :: forall p. Foldable (Entry p) $cp1Traversable :: forall p. Functor (Entry p) Traversable) instance Bifunctor Entry where bimap :: (a -> b) -> (c -> d) -> Entry a c -> Entry b d bimap a -> b f c -> d g (Entry a p c a) = b -> d -> Entry b d forall p a. p -> a -> Entry p a Entry (a -> b f a p) (c -> d g c a) {-# INLINE bimap #-} instance Eq p => Eq (Entry p a) where == :: Entry p a -> Entry p a -> Bool (==) = p -> p -> Bool forall a. Eq a => a -> a -> Bool (==) (p -> p -> Bool) -> (Entry p a -> p) -> Entry p a -> Entry p a -> Bool forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c `on` Entry p a -> p forall p a. Entry p a -> p priority {-# INLINE (==) #-} instance (Ord p) => Ord (Entry p a) where compare :: Entry p a -> Entry p a -> Ordering compare = (Entry p a -> p) -> Entry p a -> Entry p a -> Ordering forall a b. Ord a => (b -> a) -> b -> b -> Ordering comparing Entry p a -> p forall p a. Entry p a -> p priority {-# INLINE compare #-}