Elaborator Reflection - Example 3

:
%language ElabReflection


addTypeDecl : Elab ()
addTypeDecl = do 
  let tname : TTName = `{{GenData}}
  declareDatatype $ Declare tname []  RType
  defineDatatype $ DefineDatatype tname []
  
%runElab addTypeDecl

 

 

After each tactic we will look at the state:

We start with the type signature like this:
%language ElabReflection


addTypeDecl : Elab ()
addTypeDecl = do 
  let tname : TTName = `{{GenData}}
In order to investigate how the program works we can look at the proofState at each stage as the tactics are applied. So here is the proofState at the start: proof state 1
We can also look at the logic at each stage: example 1 logic 1
The term is:
 

getEnv

getGoal

getHoles

x
getGuess

error no guess

 

x
x
         declareDatatype $ Declare tname []  RType
  example 2
  logic example 1 2
Term:
? {hole_0} . {hole_0}

getEnv

getGoal

getHoles

getEnv=[]

getGoal=({hole_0}, {TT:App
tt1={TT:Parameter name ref
NameType=NameType de Bruijn indexed
TTName={`{{Elab}}.["Elab", "Reflection", "Language"]}
TT={TT:Erased}
}
tt2={TT:Parameter name ref
NameType=NameType de Bruijn indexed
TTName=`{{Unit}}
TT={TT:Erased}
}
})

getHoles=[{hole_0}]
getGuess

x

 
Holes:
             ----------------------------------
             {hole_0} : Language.Reflection.Elab.Elab Unit
Place a term into a hole, unifying its type
         defineDatatype $ DefineDatatype tname []
  example 1 3
  logic example 1
Term:
? {hole_0} . {hole_0}

getEnv

getGoal

getHoles

getEnv=[]

getGoal=({hole_0}, {TT:App
tt1={TT:Parameter name ref
NameType=NameType de Bruijn indexed
TTName={`{{Elab}}.["Elab", "Reflection", "Language"]}
TT={TT:Erased}
}
tt2={TT:Parameter name ref
NameType=NameType de Bruijn indexed
TTName=`{{Unit}}
TT={TT:Erased}
}
})

getHoles=[{hole_0}]
getGuess
x
 
 Holes:
             ----------------------------------
             {hole_0} : Language.Reflection.Elab.Elab Unit
 
         x
   
  logic example 1 4
 
x

getEnv

getGoal

getHoles

x
getGuess
x
 
x

 

 


metadata block
see also:
Correspondence about this page

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2023 Martin John Baker - All rights reserved - privacy policy.