From 9359dbcc2d01db19d251e68adf6c428eac7c7144 Mon Sep 17 00:00:00 2001
From: Ben Gamari <ben@smart-cactus.org>
Date: Tue, 27 Oct 2015 20:10:46 +0100
Subject: [PATCH] TcRnMonad: Backport pushLevelAndCaptureConstraints

---
 compiler/typecheck/TcRnMonad.hs | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/compiler/typecheck/TcRnMonad.hs b/compiler/typecheck/TcRnMonad.hs
index 74f80996b725..dd700111bda7 100644
--- a/compiler/typecheck/TcRnMonad.hs
+++ b/compiler/typecheck/TcRnMonad.hs
@@ -1170,6 +1170,17 @@ captureTcLevel thing_inside
                 thing_inside
        ; return (res, tclvl') }
 
+pushLevelAndCaptureConstraints :: TcM a -> TcM (a, TcLevel, WantedConstraints)
+pushLevelAndCaptureConstraints thing_inside
+  = do { env <- getLclEnv
+       ; lie_var <- newTcRef emptyWC ;
+       ; let tclvl' = pushTcLevel (tcl_tclvl env)
+       ; res <- setLclEnv (env { tcl_tclvl = tclvl'
+                               , tcl_lie   = lie_var })
+                thing_inside
+       ; lie <- readTcRef lie_var
+       ; return (res, tclvl', lie) }
+
 pushTcLevelM :: TcM a -> TcM a
 pushTcLevelM thing_inside
   = do { env <- getLclEnv
-- 
GitLab