Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ollef committed Jan 19, 2024
1 parent cd62744 commit cc091f6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
19 changes: 17 additions & 2 deletions src/Elaboration/Context.hs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ skip context = do

define :: Context v -> Domain.Head -> Domain.Args -> Domain.Value -> M (Context v)
define context head_ args value = do
putText "define"
dumpValue context (Domain.Neutral head_ $ Domain.Apps args)
dumpValue context value
deps <- evalStateT (freeVars context value) mempty
let context' = defineWellOrdered context head_ args value
context''
Expand Down Expand Up @@ -477,7 +480,6 @@ dumpTerm context term = do
term' <- zonk context term
doc <- prettyTerm context term'
liftIO $ Prettyprinter.putDoc doc
putText ""

prettyValue :: Context v -> Domain.Value -> M (Doc ann)
prettyValue context term = do
Expand All @@ -486,8 +488,21 @@ prettyValue context term = do

dumpValue :: Context v -> Domain.Value -> M ()
dumpValue context value = do
term <- Readback.readback (toEnvironment context) value
let env = toEnvironment context
term <- Readback.readback env value
dumpTerm context term
putText ""
unless (HashMap.null context.equations.equal) $
putText " where"
forM_ (HashMap.toList context.equations.equal) \(head_, argValues) ->
forM_ argValues \(args, eqValue) -> do
lhsTerm <- Readback.readback env (Domain.Neutral head_ $ Domain.Apps args)
rhsTerm <- Readback.readback env eqValue
putStr (" " :: Text)
dumpTerm context lhsTerm
putStr (" = " :: Text)
dumpTerm context rhsTerm
putText ""

toPrettyableTerm :: Context v -> Syntax.Term v -> M Error.PrettyableTerm
toPrettyableTerm context term = do
Expand Down
10 changes: 8 additions & 2 deletions src/Elaboration/Unification.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {-# SOURCE #-} qualified Elaboration
import Elaboration.Context (Context)
import qualified Elaboration.Context as Context
import Elaboration.Depth (compareHeadDepths)
import qualified Elaboration.Equation as Equation
import qualified Elaboration.Meta as Meta
import qualified Environment
import qualified Error
Expand Down Expand Up @@ -355,8 +356,13 @@ withConstructorBranch
withConstructorBranch context env head args constr constrArgs tele k =
case tele of
Telescope.Empty _ -> do
let context' = Context.defineWellOrdered context head args $ Domain.Con constr constrArgs
k context'
let constrValue = Domain.Con constr constrArgs
context' <- case constrValue of
Builtin.Refl _ value1 value2 ->
Equation.equate context Flexibility.Rigid value1 value2
_ -> pure context
let context'' = Context.defineWellOrdered context' head args $ Domain.Con constr constrArgs
k context''
Telescope.Extend bindings type_ plicity tele' -> do
type' <- Evaluation.evaluate env type_
(context', var) <- Context.extend context (Bindings.toName bindings) type'
Expand Down

0 comments on commit cc091f6

Please sign in to comment.