@@ -1274,6 +1274,9 @@ elabClause info opts (cnum, PClause fc fname lhs_in withs rhs_in whereblock)
12741274 (erun fc (build i info False fname rhs))
12751275 errAt "right hand side of " fname
12761276 (erun fc $ psolve lhs_tm)
1277+ hs <- get_holes
1278+ aux <- getAux
1279+ mapM_ (elabCaseHole aux) hs
12771280 tt <- get_term
12781281 let (tm, ds) = runState (collectDeferred (Just fname) tt) []
12791282 return (tm, ds, is))
@@ -1371,6 +1374,26 @@ elabClause info opts (cnum, PClause fc fname lhs_in withs rhs_in whereblock)
13711374 = PApp fc (PRef fc n) (map (\x -> pimp x (PRef fc x) True) ps)
13721375 propagateParams ps x = x
13731376
1377+ -- if a hole is just an argument/result of a case block, treat it as
1378+ -- the unit type. Hack to help elaborate case in do blocks.
1379+ elabCaseHole aux h = do
1380+ focus h
1381+ g <- goal
1382+ case g of
1383+ TType _ -> when (any (isArg h) aux) $ do apply (Var unitTy) []; solve
1384+ _ -> return ()
1385+
1386+ -- Is the name a pattern argument in the declaration
1387+ isArg :: Name -> PDecl -> Bool
1388+ isArg n (PClauses _ _ _ cs) = any isArg' cs
1389+ where
1390+ isArg' (PClause _ _ (PApp _ _ args) _ _ _)
1391+ = any (\x -> case x of
1392+ PRef _ n' -> n == n'
1393+ _ -> False) (map getTm args)
1394+ isArg' _ = False
1395+ isArg _ _ = False
1396+
13741397elabClause info opts (_, PWith fc fname lhs_in withs wval_in withblock)
13751398 = do let tcgen = Dictionary `elem` opts
13761399 ctxt <- getContext