|
|
||
|
|
Start of topic | Skip to actions
Notes for March 21Clarification regarding type checking a lambda termNote for our type_checker function, which takes an untyped lambda calculus term and constructs a typed lambda calculus term, indicating that the untyped expression types correctly. The question was raised by Dan, how can we push a variable's type onto the environment during an abstraction - this requires type inference if the input expr is truly untyped. We must assume that the untyped expr provides us with the type of the lambda's variable. Type inference is too much work.Cast notesEven though cast is a built in function that we need for certain tricks, we don't have to use that version. We can roll our own casts, for specific pairs. Cast can be defined inductively for any two types, but not necessarily for all types, without using the low level Obj.magic.
type ('a:'(OCamlType), 'b) eq = Eq of let a in unit : ('(a), '(a)) eq;;
Now we can define a castE function that will return a function that will cast a variable of type '(a) to '(b).
castE :: A a,b. ('(a), '(b)) eq -> '(a) -> '(b)
The function is defined as:
let rec castE .|a, b| (x:('(a), '(b)) eq) : '(a) -> '(b) =
match x as ('(a1), '(b1)) eq in '(a1) -> '(b1) with
| Eq .|c| _ -> (fun x -> x);;
Since concoqtion knows that Eq contains two elements of the same type, this is possible. a1 and b1 are both substituted by c in the Eq branch. This, conceptually, is refl_eq on the Concoqtion level, rather than on the Coq level. Note from Walid: CAST IS NOT EQUAL TO MAGIC OR THE IDENTITY FUNCTION! WE DO NOT USE MAGIC HERE! Project ideas
Topic Actions: Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r3 < r2 < r1 | More topic actions
Webs: Main | TWiki | Africa | EmbeddedSystems | Gpce | Houston | International | K12 | MetaOCaml | MulticoreOCR | ProgrammingLanguages | RAP | RIDL | Sandbox | SpeechClub | Teaching | Texbot | WG211 Web Actions: |
|
This work is licensed under a Creative Commons Attribution 2.5 License. Please follow our citation guidelines.