<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi,<div><br></div><div>I'm trying to refactor the code for builtins to allow new builtins to be registered easier. At the moment I have the following types to represent builtins:</div><div><br></div><div><div><font class="Apple-style-span" face="Courier">data BuiltinDescriptor = BuiltinType Int -- Type, with number of constructors, if any</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; </font><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="Courier">                </font></span><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; | BuiltinCons &nbsp; &nbsp; -- Constructor</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | BuiltinPrim String (Term -&gt; TCM Type) -- Primitive&nbsp;</font></div><div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="Courier">                </font></span><font class="Apple-style-span" face="Courier"> &nbsp; &nbsp; &nbsp; | BuiltinPost &nbsp; &nbsp; -- Postulate (may need more info here)</font></div></div><div><font class="Apple-style-span" face="Courier"><br></font></div><div><font class="Apple-style-span" face="Courier">type BuiltinInfo = (String, (TCM Type, BuiltinDescriptor))</font></div><div><br></div><div>Where BuiltinInfo contains the name, type and description of the new builtin. You can then describe builtins like so:</div><div><br></div><div><div><font class="Apple-style-span" face="Courier">stdBuiltins :: [BuiltinInfo]</font></div><div><font class="Apple-style-span" face="Courier">stdBuiltins =&nbsp;</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp;[ (builtinList &nbsp; &nbsp; &nbsp;, (tset --&gt; tset &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;, BuiltinType 2))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp;, (builtinBool &nbsp; &nbsp; &nbsp;, (tset &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , BuiltinType 2))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp;, (builtinNat &nbsp; &nbsp; &nbsp; , (tset &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , BuiltinType 2))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp;, (builtinInteger &nbsp; , (tset &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , BuiltinType 0))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp;, (builtinAgdaTerm &nbsp;, (tset &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , BuiltinType 0))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp;, (builtinEquality &nbsp;, (hPi "A" tset (tv0 --&gt; tv0 --&gt; tset) , BuiltinType 0))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp;, (builtinNil</font><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="Courier">        </font></span><font class="Apple-style-span" face="Courier"> &nbsp; &nbsp; &nbsp;, (hPi "A" tset (el (list v0)) &nbsp; &nbsp; &nbsp; &nbsp; , BuiltinCons))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp;, (builtinCons &nbsp; &nbsp; &nbsp;, (hPi "A" tset tv0 --&gt; el (list v0) --&gt; el (list v0) , BuiltinCons))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp;, (builtinZero &nbsp; &nbsp; &nbsp;, (tnat &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , BuiltinCons))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp;, (builtinSuc &nbsp; &nbsp; &nbsp; , (tnat --&gt; tnat &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;, BuiltinCons))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp;, (builtinTrue &nbsp; &nbsp; &nbsp;, (tbool &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;, BuiltinCons))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp;, (builtinFalse &nbsp; &nbsp; , (tbool &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;, BuiltinCons))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp;, (builtinRefl &nbsp; &nbsp; &nbsp;, (hPi "A" tset (hPi "x" tv0 (el (primEquality &lt;#&gt; v1 &lt;@&gt; v0 &lt;@&gt; v0))) , BuiltinCons))</font></div><div><font class="Apple-style-span" face="Courier">]</font></div></div><div><br></div><div>for example.</div><div><br></div><div>Since I don't fully understand the Agda code yet, I want to check if this representation is adequate. One immediate problem I have is that the constructors for AgdaTerm do not have types assigned in the old system, and so I'd have to make the type check optional by making the type a Maybe (or else do something strange using TCM).</div><div><br></div><div>Should the AgdaTerm constructors have types, or have they deliberately been left type-less? Also in general should a builtin's type be mandatory or optional?</div><div><br></div><div>Thanks,</div><div><br></div><div>-Si.</div></body></html>