notes on typeclass

This commit is contained in:
2024-09-21 15:44:51 -07:00
parent 38f01065eb
commit 0e3a9fe605
5 changed files with 21 additions and 39 deletions

View File

@@ -102,6 +102,9 @@ parameters (ctx: Context)
solve : Nat -> Nat -> SnocList Val -> Val -> M ()
solve l m sp t = do
debug "solve \{show l} \{show m} \{show sp} \{show t}"
meta <- lookupMeta m
debug "meta \{show meta}"
ren <- invert l sp
tm <- rename m ren l t
let tm = lams (length sp) tm
@@ -156,6 +159,7 @@ parameters (ctx: Context)
(VLam fc _ t, t' ) => unify (l + 1) !(t $$ VVar emptyFC l [<]) !(t' `vapp` VVar emptyFC l [<])
(VMeta fc k sp, VMeta fc' k' sp' ) =>
if k == k' then unifySpine l (k == k') sp sp'
-- TODO, might want to try the other way, too.
else solve l k sp (VMeta fc' k' sp') >> pure neutral
(t, VMeta fc' i' sp') => solve l i' sp' t >> pure neutral
(VMeta fc i sp, t' ) => solve l i sp t' >> pure neutral

View File

@@ -37,7 +37,7 @@ export
freshMeta : Context -> FC -> Val -> M Tm
freshMeta ctx fc ty = do
mc <- readIORef ctx.metas
putStrLn "INFO at \{show fc}: fresh meta \{show mc.next}"
putStrLn "INFO at \{show fc}: fresh meta \{show mc.next} : \{show ty}"
writeIORef ctx.metas $ { next $= S, metas $= (Unsolved fc mc.next ctx ty ::) } mc
pure $ applyBDs 0 (Meta emptyFC mc.next) ctx.bds
where

View File

@@ -292,11 +292,6 @@ record Context
public export
data MetaEntry = Unsolved FC Nat Context Val | Solved Nat Val
export
covering
Show MetaEntry where
show (Unsolved pos k xs ty) = "Unsolved \{show pos} \{show k} : \{show ty}"
show (Solved k x) = "Solved \{show k} \{show x}"
public export
record MetaContext where
@@ -366,6 +361,12 @@ record Context where
metas : IORef MetaContext
fc : FC
export
covering
Show MetaEntry where
show (Unsolved pos k ctx ty) = "Unsolved \{show pos} \{show k} : \{show ty} \{show ctx.bds}"
show (Solved k x) = "Solved \{show k} \{show x}"
export withPos : Context -> FC -> Context
withPos ctx fc = { fc := fc } ctx