From 7882899b21a02f5ebcc73dd64988be9841577d06 Mon Sep 17 00:00:00 2001 From: David Johnson Date: Thu, 17 Nov 2016 15:27:41 -0600 Subject: [PATCH] Initial commit of Lift datatype --- servant/src/Servant/Utils/Enter.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/servant/src/Servant/Utils/Enter.hs b/servant/src/Servant/Utils/Enter.hs index 12f7a530..505e7ef3 100644 --- a/servant/src/Servant/Utils/Enter.hs +++ b/servant/src/Servant/Utils/Enter.hs @@ -49,6 +49,13 @@ instance C.Category (:~>) where instance Enter (m a) (m :~> n) (n a) where enter (Nat f) = f +-- | A lifting function from @a@ to @n a@. Used to `enter` particular +-- datatypes. +newtype x :^ n = Lift { unLift :: forall a. a -> n a} deriving Typeable + +instance Enter a (a :^ n) (n a) where + enter (Lift f) = f + -- | Like `lift`. liftNat :: (Control.Monad.Morph.MonadTrans t, Monad m) => m :~> t m liftNat = Nat Control.Monad.Morph.lift