hedgehog-1.0.4: Release with confidence.
Safe HaskellNone
LanguageHaskell2010

Hedgehog.Internal.Tree

Synopsis

Documentation

type Tree = TreeT Identity Source #

A rose tree.

pattern Tree :: NodeT Identity a -> Tree a Source #

Pattern to ease construction / deconstruction of pure trees.

newtype TreeT m a Source #

An effectful tree, each node in the tree can have an effect before it is produced.

Constructors

TreeT 

Fields

Instances

Instances details
Foldable Tree Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

fold :: Monoid m => Tree m -> m #

foldMap :: Monoid m => (a -> m) -> Tree a -> m #

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

foldr :: (a -> b -> b) -> b -> Tree a -> b #

foldr' :: (a -> b -> b) -> b -> Tree a -> b #

foldl :: (b -> a -> b) -> b -> Tree a -> b #

foldl' :: (b -> a -> b) -> b -> Tree a -> b #

foldr1 :: (a -> a -> a) -> Tree a -> a #

foldl1 :: (a -> a -> a) -> Tree a -> a #

toList :: Tree a -> [a] #

null :: Tree a -> Bool #

length :: Tree a -> Int #

elem :: Eq a => a -> Tree a -> Bool #

maximum :: Ord a => Tree a -> a #

minimum :: Ord a => Tree a -> a #

sum :: Num a => Tree a -> a #

product :: Num a => Tree a -> a #

Traversable Tree Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

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

sequenceA :: Applicative f => Tree (f a) -> f (Tree a) #

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

sequence :: Monad m => Tree (m a) -> m (Tree a) #

MMonad TreeT Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

embed :: forall (n :: Type -> Type) m b. Monad n => (forall a. m a -> TreeT n a) -> TreeT m b -> TreeT n b #

MonadTrans TreeT Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

lift :: Monad m => m a -> TreeT m a #

MonadTransDistributive TreeT Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Associated Types

type Transformer f TreeT m Source #

Methods

distributeT :: forall f (m :: Type -> Type) a. Transformer f TreeT m => TreeT (f m) a -> f (TreeT m) a Source #

MonadBase b m => MonadBase b (TreeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

liftBase :: b α -> TreeT m α #

MonadBaseControl b m => MonadBaseControl b (TreeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Associated Types

type StM (TreeT m) a #

Methods

liftBaseWith :: (RunInBase (TreeT m) b -> b a) -> TreeT m a #

restoreM :: StM (TreeT m) a -> TreeT m a #

MonadWriter w m => MonadWriter w (TreeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

writer :: (a, w) -> TreeT m a #

tell :: w -> TreeT m () #

listen :: TreeT m a -> TreeT m (a, w) #

pass :: TreeT m (a, w -> w) -> TreeT m a #

MonadState s m => MonadState s (TreeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

get :: TreeT m s #

put :: s -> TreeT m () #

state :: (s -> (a, s)) -> TreeT m a #

MonadReader r m => MonadReader r (TreeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

ask :: TreeT m r #

local :: (r -> r) -> TreeT m a -> TreeT m a #

reader :: (r -> a) -> TreeT m a #

MonadError e m => MonadError e (TreeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

throwError :: e -> TreeT m a #

catchError :: TreeT m a -> (e -> TreeT m a) -> TreeT m a #

Monad m => Monad (TreeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

(>>=) :: TreeT m a -> (a -> TreeT m b) -> TreeT m b #

(>>) :: TreeT m a -> TreeT m b -> TreeT m b #

return :: a -> TreeT m a #

Functor m => Functor (TreeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

fmap :: (a -> b) -> TreeT m a -> TreeT m b #

(<$) :: a -> TreeT m b -> TreeT m a #

Applicative m => Applicative (TreeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

pure :: a -> TreeT m a #

(<*>) :: TreeT m (a -> b) -> TreeT m a -> TreeT m b #

liftA2 :: (a -> b -> c) -> TreeT m a -> TreeT m b -> TreeT m c #

(*>) :: TreeT m a -> TreeT m b -> TreeT m b #

(<*) :: TreeT m a -> TreeT m b -> TreeT m a #

Show1 m => Show1 (TreeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> TreeT m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [TreeT m a] -> ShowS #

Monad m => MonadZip (TreeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

mzip :: TreeT m a -> TreeT m b -> TreeT m (a, b) #

mzipWith :: (a -> b -> c) -> TreeT m a -> TreeT m b -> TreeT m c #

munzip :: TreeT m (a, b) -> (TreeT m a, TreeT m b) #

MonadIO m => MonadIO (TreeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

liftIO :: IO a -> TreeT m a #

Alternative m => Alternative (TreeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

empty :: TreeT m a #

(<|>) :: TreeT m a -> TreeT m a -> TreeT m a #

some :: TreeT m a -> TreeT m [a] #

many :: TreeT m a -> TreeT m [a] #

MonadPlus m => MonadPlus (TreeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

mzero :: TreeT m a #

mplus :: TreeT m a -> TreeT m a -> TreeT m a #

MonadCatch m => MonadCatch (TreeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

catch :: Exception e => TreeT m a -> (e -> TreeT m a) -> TreeT m a #

MonadThrow m => MonadThrow (TreeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

throwM :: Exception e => e -> TreeT m a #

PrimMonad m => PrimMonad (TreeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Associated Types

type PrimState (TreeT m) #

Methods

primitive :: (State# (PrimState (TreeT m)) -> (# State# (PrimState (TreeT m)), a #)) -> TreeT m a #

MonadResource m => MonadResource (TreeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

liftResourceT :: ResourceT IO a -> TreeT m a #

MFunctor TreeT Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

hoist :: forall m n (b :: k). Monad m => (forall a. m a -> n a) -> TreeT m b -> TreeT n b #

(Eq1 m, Eq a) => Eq (TreeT m a) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

(==) :: TreeT m a -> TreeT m a -> Bool #

(/=) :: TreeT m a -> TreeT m a -> Bool #

(Show1 m, Show a) => Show (TreeT m a) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

showsPrec :: Int -> TreeT m a -> ShowS #

show :: TreeT m a -> String #

showList :: [TreeT m a] -> ShowS #

type Transformer f TreeT m Source # 
Instance details

Defined in Hedgehog.Internal.Tree

type Transformer f TreeT m = (Monad m, Monad (f m), Monad (TreeT m), Monad (f (TreeT m)), MonadTrans f, MFunctor f)
type PrimState (TreeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

type StM (TreeT m) a Source # 
Instance details

Defined in Hedgehog.Internal.Tree

type StM (TreeT m) a = StM m (NodeT m a)

runTree :: Tree a -> Node a Source #

Extracts the Node from a Tree.

mapTreeT :: (m (NodeT m a) -> m (NodeT m a)) -> TreeT m a -> TreeT m a Source #

Map between TreeT computations.

treeValue :: Tree a -> a Source #

The value at the root of the Tree.

treeChildren :: Tree a -> [Tree a] Source #

The children of the Tree.

type Node = NodeT Identity Source #

A node in a rose tree.

pattern Node :: a -> [Tree a] -> Node a Source #

Pattern to ease construction / deconstruction of pure nodes.

data NodeT m a Source #

A node in an effectful tree, as well as its unevaluated children.

Constructors

NodeT 

Fields

Instances

Instances details
Foldable Node Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

fold :: Monoid m => Node m -> m #

foldMap :: Monoid m => (a -> m) -> Node a -> m #

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

foldr :: (a -> b -> b) -> b -> Node a -> b #

foldr' :: (a -> b -> b) -> b -> Node a -> b #

foldl :: (b -> a -> b) -> b -> Node a -> b #

foldl' :: (b -> a -> b) -> b -> Node a -> b #

foldr1 :: (a -> a -> a) -> Node a -> a #

foldl1 :: (a -> a -> a) -> Node a -> a #

toList :: Node a -> [a] #

null :: Node a -> Bool #

length :: Node a -> Int #

elem :: Eq a => a -> Node a -> Bool #

maximum :: Ord a => Node a -> a #

minimum :: Ord a => Node a -> a #

sum :: Num a => Node a -> a #

product :: Num a => Node a -> a #

Traversable Node Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

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

sequenceA :: Applicative f => Node (f a) -> f (Node a) #

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

sequence :: Monad m => Node (m a) -> m (Node a) #

Monad m => Monad (NodeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

(>>=) :: NodeT m a -> (a -> NodeT m b) -> NodeT m b #

(>>) :: NodeT m a -> NodeT m b -> NodeT m b #

return :: a -> NodeT m a #

Functor m => Functor (NodeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

fmap :: (a -> b) -> NodeT m a -> NodeT m b #

(<$) :: a -> NodeT m b -> NodeT m a #

Applicative m => Applicative (NodeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

pure :: a -> NodeT m a #

(<*>) :: NodeT m (a -> b) -> NodeT m a -> NodeT m b #

liftA2 :: (a -> b -> c) -> NodeT m a -> NodeT m b -> NodeT m c #

(*>) :: NodeT m a -> NodeT m b -> NodeT m b #

(<*) :: NodeT m a -> NodeT m b -> NodeT m a #

Show1 m => Show1 (NodeT m) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> NodeT m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [NodeT m a] -> ShowS #

MFunctor NodeT Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

hoist :: forall m n (b :: k). Monad m => (forall a. m a -> n a) -> NodeT m b -> NodeT n b #

(Eq a, Eq1 m) => Eq (NodeT m a) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

(==) :: NodeT m a -> NodeT m a -> Bool #

(/=) :: NodeT m a -> NodeT m a -> Bool #

(Show1 m, Show a) => Show (NodeT m a) Source # 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

showsPrec :: Int -> NodeT m a -> ShowS #

show :: NodeT m a -> String #

showList :: [NodeT m a] -> ShowS #

fromNodeT :: Applicative m => NodeT m a -> TreeT m a Source #

Create a TreeT from a NodeT

unfold :: Monad m => (a -> [a]) -> a -> TreeT m a Source #

Create a tree from a value and an unfolding function.

unfoldForest :: Monad m => (a -> [a]) -> a -> [TreeT m a] Source #

Create a forest from a value and an unfolding function.

expand :: Monad m => (a -> [a]) -> TreeT m a -> TreeT m a Source #

Expand a tree using an unfolding function.

prune :: Monad m => Int -> TreeT m a -> TreeT m a Source #

Throw away n levels of a tree's children.

prune 0 will throw away all of a tree's children.

catMaybes :: Tree (Maybe a) -> Maybe (Tree a) Source #

Takes a tree of Maybes and returns a tree of all the Just values.

If the root of the tree is Nothing then Nothing is returned.

filter :: (a -> Bool) -> Tree a -> Maybe (Tree a) Source #

Returns a tree containing only elements that match the predicate.

If the root of the tree does not match the predicate then Nothing is returned.

mapMaybe :: (a -> Maybe b) -> Tree a -> Maybe (Tree b) Source #

filterMaybeT :: (a -> Bool) -> TreeT (MaybeT Identity) a -> TreeT (MaybeT Identity) a Source #

Returns a tree containing only elements that match the predicate.

If the root of the tree does not match the predicate then Nothing is returned.

filterT :: (Monad m, Alternative m) => (a -> Bool) -> TreeT m a -> TreeT m a Source #

Returns a tree containing only elements that match the predicate.

When an element does not match the predicate its node is replaced with empty.

mapMaybeT :: (Monad m, Alternative m) => (a -> Maybe b) -> TreeT m a -> TreeT m b Source #

depth :: Tree a -> Int Source #

Returns the depth of the deepest leaf node in the tree.

interleave :: forall m a. Monad m => [NodeT m a] -> NodeT m [a] Source #

render :: Tree String -> String Source #

Render a tree of strings.

renderT :: Monad m => TreeT m String -> m String Source #

Render a tree of strings, note that this forces all the delayed effects in the tree.