{-# LANGUAGE UndecidableInstances #-}

module Blucontrol.Control.Print (
  ControlPrintT
, runControlPrintT
) where

import Control.Monad.Base
import Control.Monad.Trans
import Control.Monad.Trans.Control

import Blucontrol.Control

newtype ControlPrintT m a = ControlPrintT { ControlPrintT m a -> m a
unControlPrintT :: m a }
  deriving (Functor (ControlPrintT m)
a -> ControlPrintT m a
Functor (ControlPrintT m)
-> (forall a. a -> ControlPrintT m a)
-> (forall a b.
    ControlPrintT m (a -> b) -> ControlPrintT m a -> ControlPrintT m b)
-> (forall a b c.
    (a -> b -> c)
    -> ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m c)
-> (forall a b.
    ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m b)
-> (forall a b.
    ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m a)
-> Applicative (ControlPrintT m)
ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m b
ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m a
ControlPrintT m (a -> b) -> ControlPrintT m a -> ControlPrintT m b
(a -> b -> c)
-> ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m c
forall a. a -> ControlPrintT m a
forall a b.
ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m a
forall a b.
ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m b
forall a b.
ControlPrintT m (a -> b) -> ControlPrintT m a -> ControlPrintT m b
forall a b c.
(a -> b -> c)
-> ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
forall (m :: * -> *). Applicative m => Functor (ControlPrintT m)
forall (m :: * -> *) a. Applicative m => a -> ControlPrintT m a
forall (m :: * -> *) a b.
Applicative m =>
ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m a
forall (m :: * -> *) a b.
Applicative m =>
ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m b
forall (m :: * -> *) a b.
Applicative m =>
ControlPrintT m (a -> b) -> ControlPrintT m a -> ControlPrintT m b
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m c
<* :: ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m a
$c<* :: forall (m :: * -> *) a b.
Applicative m =>
ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m a
*> :: ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m b
$c*> :: forall (m :: * -> *) a b.
Applicative m =>
ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m b
liftA2 :: (a -> b -> c)
-> ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m c
$cliftA2 :: forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m c
<*> :: ControlPrintT m (a -> b) -> ControlPrintT m a -> ControlPrintT m b
$c<*> :: forall (m :: * -> *) a b.
Applicative m =>
ControlPrintT m (a -> b) -> ControlPrintT m a -> ControlPrintT m b
pure :: a -> ControlPrintT m a
$cpure :: forall (m :: * -> *) a. Applicative m => a -> ControlPrintT m a
$cp1Applicative :: forall (m :: * -> *). Applicative m => Functor (ControlPrintT m)
Applicative, a -> ControlPrintT m b -> ControlPrintT m a
(a -> b) -> ControlPrintT m a -> ControlPrintT m b
(forall a b. (a -> b) -> ControlPrintT m a -> ControlPrintT m b)
-> (forall a b. a -> ControlPrintT m b -> ControlPrintT m a)
-> Functor (ControlPrintT m)
forall a b. a -> ControlPrintT m b -> ControlPrintT m a
forall a b. (a -> b) -> ControlPrintT m a -> ControlPrintT m b
forall (m :: * -> *) a b.
Functor m =>
a -> ControlPrintT m b -> ControlPrintT m a
forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> ControlPrintT m a -> ControlPrintT m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> ControlPrintT m b -> ControlPrintT m a
$c<$ :: forall (m :: * -> *) a b.
Functor m =>
a -> ControlPrintT m b -> ControlPrintT m a
fmap :: (a -> b) -> ControlPrintT m a -> ControlPrintT m b
$cfmap :: forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> ControlPrintT m a -> ControlPrintT m b
Functor, Applicative (ControlPrintT m)
a -> ControlPrintT m a
Applicative (ControlPrintT m)
-> (forall a b.
    ControlPrintT m a -> (a -> ControlPrintT m b) -> ControlPrintT m b)
-> (forall a b.
    ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m b)
-> (forall a. a -> ControlPrintT m a)
-> Monad (ControlPrintT m)
ControlPrintT m a -> (a -> ControlPrintT m b) -> ControlPrintT m b
ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m b
forall a. a -> ControlPrintT m a
forall a b.
ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m b
forall a b.
ControlPrintT m a -> (a -> ControlPrintT m b) -> ControlPrintT m b
forall (m :: * -> *). Monad m => Applicative (ControlPrintT m)
forall (m :: * -> *) a. Monad m => a -> ControlPrintT m a
forall (m :: * -> *) a b.
Monad m =>
ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m b
forall (m :: * -> *) a b.
Monad m =>
ControlPrintT m a -> (a -> ControlPrintT m b) -> ControlPrintT m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> ControlPrintT m a
$creturn :: forall (m :: * -> *) a. Monad m => a -> ControlPrintT m a
>> :: ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m b
$c>> :: forall (m :: * -> *) a b.
Monad m =>
ControlPrintT m a -> ControlPrintT m b -> ControlPrintT m b
>>= :: ControlPrintT m a -> (a -> ControlPrintT m b) -> ControlPrintT m b
$c>>= :: forall (m :: * -> *) a b.
Monad m =>
ControlPrintT m a -> (a -> ControlPrintT m b) -> ControlPrintT m b
$cp1Monad :: forall (m :: * -> *). Monad m => Applicative (ControlPrintT m)
Monad, MonadBase b, MonadBaseControl b)

instance MonadTrans ControlPrintT where
  lift :: m a -> ControlPrintT m a
lift = m a -> ControlPrintT m a
forall (m :: * -> *) a. m a -> ControlPrintT m a
ControlPrintT

instance MonadTransControl ControlPrintT where
  type StT ControlPrintT a = a
  liftWith :: (Run ControlPrintT -> m a) -> ControlPrintT m a
liftWith Run ControlPrintT -> m a
inner = m a -> ControlPrintT m a
forall (m :: * -> *) a. m a -> ControlPrintT m a
ControlPrintT (m a -> ControlPrintT m a) -> m a -> ControlPrintT m a
forall a b. (a -> b) -> a -> b
$ Run ControlPrintT -> m a
inner Run ControlPrintT
forall (m :: * -> *) a. ControlPrintT m a -> m a
unControlPrintT
  restoreT :: m (StT ControlPrintT a) -> ControlPrintT m a
restoreT = m (StT ControlPrintT a) -> ControlPrintT m a
forall (m :: * -> *) a. m a -> ControlPrintT m a
ControlPrintT

instance MonadBaseControl IO m => MonadControl (ControlPrintT m) where
  type ControlConstraint (ControlPrintT m) a = Show a
  doInbetween :: a -> ControlPrintT m ()
doInbetween a
a = IO () -> ControlPrintT m ()
forall (b :: * -> *) (m :: * -> *) α. MonadBase b m => b α -> m α
liftBase (IO () -> ControlPrintT m ()) -> IO () -> ControlPrintT m ()
forall a b. (a -> b) -> a -> b
$ a -> IO ()
forall a. Show a => a -> IO ()
print a
a

runControlPrintT :: ControlPrintT m a -> m a
runControlPrintT :: ControlPrintT m a -> m a
runControlPrintT = ControlPrintT m a -> m a
forall (m :: * -> *) a. ControlPrintT m a -> m a
unControlPrintT