module Control.Monad.Ology.General.Extract where

import Control.Monad.Ology.General.Function
import Control.Monad.Ology.General.Inner
import Import

-- | Instances of this type are isomorphic to @(Q,a)@ for some type @Q@ (with @Monoid Q@).
class MonadInner m => MonadExtract m where
    mToValue :: Extract m

instance MonadExtract Identity where
    mToValue :: Extract Identity
mToValue (Identity a
a) = a
a

instance Monoid p => MonadExtract ((,) p) where
    mToValue :: Extract ((,) p)
mToValue (p
_, a
a) = a
a

instance MonadExtract (Either Void) where
    mToValue :: Extract (Either Void)
mToValue (Left Void
p) = forall a. Void -> a
absurd Void
p
    mToValue (Right a
a) = a
a