@@ -1028,12 +1028,22 @@ elab ist info emode opts fn tm
10281028 solve
10291029 elab' ina _ c@(PCase fc scr opts)
10301030 = do attack
1031+
10311032 tyn <- getNameFrom (sMN 0 "scty")
10321033 claim tyn RType
10331034 valn <- getNameFrom (sMN 0 "scval")
10341035 scvn <- getNameFrom (sMN 0 "scvar")
10351036 claim valn (Var tyn)
10361037 letbind scvn (Var tyn) (Var valn)
1038+
1039+ -- Start filling in the scrutinee type, if we can work one
1040+ -- out from the case options
1041+ let scrTy = getScrType (map fst opts)
1042+ case scrTy of
1043+ Nothing -> return ()
1044+ Just ty -> do focus tyn
1045+ elabE ina (Just fc) ty
1046+
10371047 focus valn
10381048 elabE (ina { e_inarg = True }) (Just fc) scr
10391049 -- Solve any remaining implicits - we need to solve as many
@@ -1084,6 +1094,21 @@ elab ist info emode opts fn tm
10841094 Just xs@(_:_) -> sNS n xs
10851095 _ -> n
10861096
1097+ getScrType [] = Nothing
1098+ getScrType (f : os) = maybe (getScrType os) Just (getAppType f)
1099+
1100+ getAppType (PRef _ _ n) =
1101+ case lookupTyName n (tt_ctxt ist) of
1102+ [(n', ty)] | isDConName n' (tt_ctxt ist) ->
1103+ case unApply (getRetTy ty) of
1104+ (P _ tyn _, args) ->
1105+ Just (PApp fc (PRef fc [] tyn)
1106+ (map pexp (map (const Placeholder) args)))
1107+ _ -> Nothing
1108+ _ -> Nothing -- ambiguity is no help to us!
1109+ getAppType (PApp _ t as) = getAppType t
1110+ getAppType _ = Nothing
1111+
10871112 inApp (P _ n _) = [n]
10881113 inApp (App _ f a) = inApp f ++ inApp a
10891114 inApp (Bind n (Let _ v) sc) = inApp v ++ inApp sc