I'm new with Ocaml and functional programming, and I'm trying to implement some data structures that respect some component interfaces. At the moment I'm the problem with the following error
File "src/symbol_table.ml", line 24, characters 39-45:
24 | { variables=Hashtbl.create 0; parent=Option(table) }
^^^^^^
Error: This variant expression is expected to have type dec option
The constructor Option does not belong to type option
Command exited with code 2.
And I'm trying to implement the following interface
type dec
val begin_block : dec -> dec
With the following implementation
type dec = {
variables: (Ast.identifier, Ast.typ) Hashtbl.t;
parent: dec option
}
let begin_block (table: dec) =
logger#debug "Starting scope";
{ variables=Hashtbl.create 0; parent=table }
I think that my Java knowledge is the limit here, and my question is how I can make the cast to type dec option? to set the table as a parent?
question from:
https://stackoverflow.com/questions/65644425/cast-custom-type-to-option-custom-type 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…