@@ -1274,6 +1274,9 @@ elabClause info opts (cnum, PClause fc fname lhs_in withs rhs_in whereblock)
1274 (erun fc (build i info False fname rhs))
1274 (erun fc (build i info False fname rhs))
1275 errAt "right hand side of " fname
1275 errAt "right hand side of " fname
1276 (erun fc $ psolve lhs_tm)
1276 (erun fc $ psolve lhs_tm)
1279+ mapM_ (elabCaseHole aux) hs
1277 tt <- get_term
1280 tt <- get_term
1278 let (tm, ds) = runState (collectDeferred (Just fname) tt) []
1281 let (tm, ds) = runState (collectDeferred (Just fname) tt) []
1279 return (tm, ds, is))
1282 return (tm, ds, is))
@@ -1371,6 +1374,26 @@ elabClause info opts (cnum, PClause fc fname lhs_in withs rhs_in whereblock)
1371 = PApp fc (PRef fc n) (map (\x -> pimp x (PRef fc x) True) ps)
1374 = PApp fc (PRef fc n) (map (\x -> pimp x (PRef fc x) True) ps)
1372 propagateParams ps x = x
1375 propagateParams ps x = x
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
1383+ TType _ -> when (any (isArg h) aux) $ do apply (Var unitTy) []; solve
1386+ -- Is the name a pattern argument in the declaration
1387+ isArg :: Name -> PDecl -> Bool
1388+ isArg n (PClauses _ _ _ cs) = any isArg' cs
1390+ isArg' (PClause _ _ (PApp _ _ args) _ _ _)
1391+ = any (\x -> case x of
1392+ PRef _ n' -> n == n'
1393+ _ -> False) (map getTm args)
1374elabClause info opts (_, PWith fc fname lhs_in withs wval_in withblock)
1397elabClause info opts (_, PWith fc fname lhs_in withs wval_in withblock)
1375 = do let tcgen = Dictionary `elem` opts
1398 = do let tcgen = Dictionary `elem` opts
1376 ctxt <- getContext
1399 ctxt <- getContext