git.iko.soy/typeable/swagger2
on master help sign in
liftDeclare
commit610aeaf568cb92d2565e2d01c185548e2dd64015 authormoss <moss@tvisioninsights.com> dateMon 24 Apr 2017, 14:31 (9 years ago) parentfe3d81e
1 file changed+7
src/Data/Swagger/Declare.hs+7
src/Data/Swagger/Declare.hs+7
@@ -87,6 +87,13 @@ instance (Applicative m, Monad m, Monoid d) => MonadDeclare d (DeclareT d m) whe
8787 declare d = DeclareT (\_ -> return (d, ()))
8888 look = DeclareT (\d -> return (mempty, d))
8989
90+-- | Lift a computation from the simple Declare monad.
91+liftDeclare :: MonadDeclare d m => Declare d a -> m a
92+liftDeclare da = do
93+ (d', a) <- looks (runDeclare da)
94+ declare d'
95+ pure a
96+
9097-- | Retrieve a function of all the output so far.
9198looks :: MonadDeclare d m => (d -> a) -> m a
9299looks f = f <$> look