monus-weighted-search-0.2.0.0: Efficient search weighted by an ordered monoid with monus.
Copyright(c) Donnacha Oisín Kidney 2021
Maintainermail@doisinkidney.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Control.Comonad.Heap

Description

The Heap comonad: a comonad for efficient weighted search.

This module provides the Heap *comonad*.

Documentation

data Heap w a Source #

Constructors

Root !w a [Heap w a] 

Instances

Instances details
Arbitrary2 Heap Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

liftArbitrary2 :: Gen a -> Gen b -> Gen (Heap a b) #

liftShrink2 :: (a -> [a]) -> (b -> [b]) -> Heap a b -> [Heap a b] #

Bitraversable Heap Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Heap a b -> f (Heap c d) #

Bifoldable Heap Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

bifold :: Monoid m => Heap m m -> m #

bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Heap a b -> m #

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Heap a b -> c #

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Heap a b -> c #

Bifunctor Heap Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

bimap :: (a -> b) -> (c -> d) -> Heap a c -> Heap b d #

first :: (a -> b) -> Heap a c -> Heap b c #

second :: (b -> c) -> Heap a b -> Heap a c #

Eq2 Heap Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> Heap a c -> Heap b d -> Bool #

Ord2 Heap Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> Heap a c -> Heap b d -> Ordering #

Read2 Heap Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (Heap a b) #

liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Heap a b] #

liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (Heap a b) #

liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [Heap a b] #

Show2 Heap Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> Heap a b -> ShowS #

liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [Heap a b] -> ShowS #

NFData2 Heap Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

liftRnf2 :: (a -> ()) -> (b -> ()) -> Heap a b -> () #

ComonadCofree [] (Heap w) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

unwrap :: Heap w a -> [Heap w a] #

Monoid w => Monad (Heap w) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

(>>=) :: Heap w a -> (a -> Heap w b) -> Heap w b #

(>>) :: Heap w a -> Heap w b -> Heap w b #

return :: a -> Heap w a #

Functor (Heap w) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

fmap :: (a -> b) -> Heap w a -> Heap w b #

(<$) :: a -> Heap w b -> Heap w a #

Monoid w => Applicative (Heap w) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

pure :: a -> Heap w a #

(<*>) :: Heap w (a -> b) -> Heap w a -> Heap w b #

liftA2 :: (a -> b -> c) -> Heap w a -> Heap w b -> Heap w c #

(*>) :: Heap w a -> Heap w b -> Heap w b #

(<*) :: Heap w a -> Heap w b -> Heap w a #

Foldable (Heap w) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

fold :: Monoid m => Heap w m -> m #

foldMap :: Monoid m => (a -> m) -> Heap w a -> m #

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

foldr :: (a -> b -> b) -> b -> Heap w a -> b #

foldr' :: (a -> b -> b) -> b -> Heap w a -> b #

foldl :: (b -> a -> b) -> b -> Heap w a -> b #

foldl' :: (b -> a -> b) -> b -> Heap w a -> b #

foldr1 :: (a -> a -> a) -> Heap w a -> a #

foldl1 :: (a -> a -> a) -> Heap w a -> a #

toList :: Heap w a -> [a] #

null :: Heap w a -> Bool #

length :: Heap w a -> Int #

elem :: Eq a => a -> Heap w a -> Bool #

maximum :: Ord a => Heap w a -> a #

minimum :: Ord a => Heap w a -> a #

sum :: Num a => Heap w a -> a #

product :: Num a => Heap w a -> a #

Traversable (Heap w) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

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

sequenceA :: Applicative f => Heap w (f a) -> f (Heap w a) #

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

sequence :: Monad m => Heap w (m a) -> m (Heap w a) #

Arbitrary w => Arbitrary1 (Heap w) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

liftArbitrary :: Gen a -> Gen (Heap w a) #

liftShrink :: (a -> [a]) -> Heap w a -> [Heap w a] #

Eq w => Eq1 (Heap w) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

liftEq :: (a -> b -> Bool) -> Heap w a -> Heap w b -> Bool #

Ord w => Ord1 (Heap w) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

liftCompare :: (a -> b -> Ordering) -> Heap w a -> Heap w b -> Ordering #

Read w => Read1 (Heap w) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Heap w a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Heap w a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Heap w a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Heap w a] #

Show w => Show1 (Heap w) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Heap w a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Heap w a] -> ShowS #

Comonad (Heap w) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

extract :: Heap w a -> a #

duplicate :: Heap w a -> Heap w (Heap w a) #

extend :: (Heap w a -> b) -> Heap w a -> Heap w b #

NFData w => NFData1 (Heap w) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

liftRnf :: (a -> ()) -> Heap w a -> () #

Generic1 (Heap w :: Type -> Type) Source # 
Instance details

Defined in Control.Comonad.Heap

Associated Types

type Rep1 (Heap w) :: k -> Type #

Methods

from1 :: forall (a :: k). Heap w a -> Rep1 (Heap w) a #

to1 :: forall (a :: k). Rep1 (Heap w) a -> Heap w a #

(Eq w, Eq a) => Eq (Heap w a) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

(==) :: Heap w a -> Heap w a -> Bool #

(/=) :: Heap w a -> Heap w a -> Bool #

(Data w, Data a) => Data (Heap w a) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Heap w a -> c (Heap w a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Heap w a) #

toConstr :: Heap w a -> Constr #

dataTypeOf :: Heap w a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Heap w a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Heap w a)) #

gmapT :: (forall b. Data b => b -> b) -> Heap w a -> Heap w a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Heap w a -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Heap w a -> r #

gmapQ :: (forall d. Data d => d -> u) -> Heap w a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Heap w a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Heap w a -> m (Heap w a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Heap w a -> m (Heap w a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Heap w a -> m (Heap w a) #

(Ord w, Ord a) => Ord (Heap w a) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

compare :: Heap w a -> Heap w a -> Ordering #

(<) :: Heap w a -> Heap w a -> Bool #

(<=) :: Heap w a -> Heap w a -> Bool #

(>) :: Heap w a -> Heap w a -> Bool #

(>=) :: Heap w a -> Heap w a -> Bool #

max :: Heap w a -> Heap w a -> Heap w a #

min :: Heap w a -> Heap w a -> Heap w a #

(Read w, Read a) => Read (Heap w a) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

readsPrec :: Int -> ReadS (Heap w a) #

readList :: ReadS [Heap w a] #

readPrec :: ReadPrec (Heap w a) #

readListPrec :: ReadPrec [Heap w a] #

(Show w, Show a) => Show (Heap w a) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

showsPrec :: Int -> Heap w a -> ShowS #

show :: Heap w a -> String #

showList :: [Heap w a] -> ShowS #

Generic (Heap w a) Source # 
Instance details

Defined in Control.Comonad.Heap

Associated Types

type Rep (Heap w a) :: Type -> Type #

Methods

from :: Heap w a -> Rep (Heap w a) x #

to :: Rep (Heap w a) x -> Heap w a #

(Arbitrary w, Arbitrary a) => Arbitrary (Heap w a) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

arbitrary :: Gen (Heap w a) #

shrink :: Heap w a -> [Heap w a] #

(NFData w, NFData a) => NFData (Heap w a) Source # 
Instance details

Defined in Control.Comonad.Heap

Methods

rnf :: Heap w a -> () #

type Rep1 (Heap w :: Type -> Type) Source # 
Instance details

Defined in Control.Comonad.Heap

type Rep (Heap w a) Source # 
Instance details

Defined in Control.Comonad.Heap

type Rep (Heap w a) = D1 ('MetaData "Heap" "Control.Comonad.Heap" "monus-weighted-search-0.2.0.0-inplace" 'False) (C1 ('MetaCons "Root" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 w) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Heap w a]))))

popMin :: Monus w => Heap w a -> ((w, a), Maybe (Heap w a)) Source #

(<+>) :: Monus w => Heap w a -> Heap w a -> Heap w a Source #

(<><) :: Semigroup w => w -> Heap w a -> Heap w a Source #

mergeHeaps :: Monus w => NonEmpty (Heap w a) -> Heap w a Source #

singleton :: w -> a -> Heap w a Source #