@@ -142,6 +142,14 @@ genAll i args
142142 otherPats :: PTerm -> [PTerm]
143143 otherPats o@(PRef fc n) = ops fc n [] o
144144 otherPats o@(PApp _ (PRef fc n) xs) = ops fc n xs o
145+ otherPats o@(PPair fc l r)
146+ = ops fc pairCon
147+ ([pimp (UN "A") Placeholder, pimp (UN "B") Placeholder] ++
148+ [pexp l, pexp r]) o
149+ otherPats o@(PDPair fc t _ v)
150+ = ops fc (UN "Ex_intro")
151+ ([pimp (UN "a") Placeholder, pimp (UN "P") Placeholder] ++
152+ [pexp t,pexp v]) o
145153 otherPats arg = return Placeholder
146154
147155 ops fc n xs_in o
@@ -149,13 +157,21 @@ genAll i args
149157 = do let force = getForceable i n -- no need to generate forceable positions
150158 let xs = dropForce force xs_in 0
151159 xs' <- mapM otherPats (map getTm xs)
152− let p = PApp fc (PRef fc n) (zipWith upd xs' xs)
160+ let p = resugar (PApp fc (PRef fc n) (zipWith upd xs' xs))
153161 let tyn = getTy n (tt_ctxt i)
154162 case lookupCtxt tyn (idris_datatypes i) of
155163 (TI ns _ _ : _) -> p : map (mkPat fc) (ns \\ [n])
156164 _ -> [p]
157165 ops fc n arg o = return Placeholder
158166
167+ -- put it back to its original form
168+ resugar (PApp _ (PRef fc (UN "Ex_intro")) [_,_,t,v])
169+ = PDPair fc (getTm t) Placeholder (getTm v)
170+ resugar (PApp _ (PRef fc n) [_,_,l,r])
171+ | n == pairCon
172+ = PPair fc (getTm l) (getTm r)
173+ resugar t = t
174+
159175 getForceable i n = case lookupCtxt n (idris_optimisation i) of
160176 [Optimise _ fs _] -> fs
161177 _ -> []