case builder starting to work

This commit is contained in:
2024-08-30 21:40:14 -07:00
parent 7f47029efe
commit 987ab18b94
13 changed files with 340 additions and 65 deletions

View File

@@ -181,8 +181,8 @@ infer : Context -> Raw -> M (Tm, Val)
export
check : Context -> Raw -> Val -> M Tm
-- FIXME we need to switch to FC
-- This is the old case checking that expected a user-supplied case tree
checkAlt : Val -> Context -> Val -> RCaseAlt -> M CaseAlt
checkAlt scty ctx ty (MkAlt ptm body) = do
-- we have a pattern term and a body
@@ -270,7 +270,16 @@ checkAlt scty ctx ty (MkAlt ptm body) = do
check ctx tm ty = case (tm, !(forceType ty)) of
-- previous code
-- (RCase fc rsc alts, ty) => do
-- (sc, scty) <- infer ctx rsc
-- let (VRef fc nm (TCon cnames) sp) = scty
-- | _ => error fc "expected TCon for scrutinee type, got: \{show scty}"
-- debug "constructor names \{show cnames}"
-- alts' <- for alts $ checkAlt scty ctx ty
-- pure $ Case emptyFC sc alts'
(RCase fc rsc alts, ty) => do
-- scrutinee must infer. We will probably want to `let` it too.
(sc, scty) <- infer ctx rsc
let (VRef fc nm (TCon cnames) sp) = scty
| _ => error fc "expected TCon for scrutinee type, got: \{show scty}"