{-# LANGUAGE DeriveFunctor #-} module Test.Hspec.Core.Formatters.Free where import Prelude () import Test.Hspec.Core.Compat data Free f a = Free (f (Free f a)) | Pure a deriving a -> Free f b -> Free f a (a -> b) -> Free f a -> Free f b (forall a b. (a -> b) -> Free f a -> Free f b) -> (forall a b. a -> Free f b -> Free f a) -> Functor (Free f) forall a b. a -> Free f b -> Free f a forall a b. (a -> b) -> Free f a -> Free f b forall (f :: * -> *) a b. Functor f => a -> Free f b -> Free f a forall (f :: * -> *) a b. Functor f => (a -> b) -> Free f a -> Free f b forall (f :: * -> *). (forall a b. (a -> b) -> f a -> f b) -> (forall a b. a -> f b -> f a) -> Functor f <$ :: a -> Free f b -> Free f a $c<$ :: forall (f :: * -> *) a b. Functor f => a -> Free f b -> Free f a fmap :: (a -> b) -> Free f a -> Free f b $cfmap :: forall (f :: * -> *) a b. Functor f => (a -> b) -> Free f a -> Free f b Functor instance Functor f => Applicative (Free f) where pure :: a -> Free f a pure = a -> Free f a forall (f :: * -> *) a. a -> Free f a Pure Pure a -> b f <*> :: Free f (a -> b) -> Free f a -> Free f b <*> Pure a a = b -> Free f b forall (f :: * -> *) a. a -> Free f a Pure (a -> b f a a) Pure a -> b f <*> Free f (Free f a) m = f (Free f b) -> Free f b forall (f :: * -> *) a. f (Free f a) -> Free f a Free ((a -> b) -> Free f a -> Free f b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap a -> b f (Free f a -> Free f b) -> f (Free f a) -> f (Free f b) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> f (Free f a) m) Free f (Free f (a -> b)) m <*> Free f a b = f (Free f b) -> Free f b forall (f :: * -> *) a. f (Free f a) -> Free f a Free ((Free f (a -> b) -> Free f b) -> f (Free f (a -> b)) -> f (Free f b) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap (Free f (a -> b) -> Free f a -> Free f b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Free f a b) f (Free f (a -> b)) m) instance Functor f => Monad (Free f) where return :: a -> Free f a return = a -> Free f a forall (f :: * -> *) a. Applicative f => a -> f a pure Pure a a >>= :: Free f a -> (a -> Free f b) -> Free f b >>= a -> Free f b f = a -> Free f b f a a Free f (Free f a) m >>= a -> Free f b f = f (Free f b) -> Free f b forall (f :: * -> *) a. f (Free f a) -> Free f a Free ((Free f a -> Free f b) -> f (Free f a) -> f (Free f b) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap (Free f a -> (a -> Free f b) -> Free f b forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b >>= a -> Free f b f) f (Free f a) m) liftF :: Functor f => f a -> Free f a liftF :: f a -> Free f a liftF f a command = f (Free f a) -> Free f a forall (f :: * -> *) a. f (Free f a) -> Free f a Free ((a -> Free f a) -> f a -> f (Free f a) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap a -> Free f a forall (f :: * -> *) a. a -> Free f a Pure f a command)