2009-09-30 10 views

Odpowiedz

10

Istnieje dobry opis tego w ocaml tutorial. Co się stało to już zasłonięta definicji typu z nową definicją:

type nfa = int 
let f (x: nfa) = x 

type nfa = int 
let g (x: nfa) = x 

Ponowne najwyższego poziomu będzie pozbyć się starych definicji.

0

Aktualizacja:

Od OCaml 4.01.0 (wydana wrzesień 2013) ogólny problem jest taki sam, ale komunikat o błędzie dodaje numer do definicji typu, aby widoczne typy są wewnętrznie inny .

Pełny przykład z old OCaml FAQ w będąc w głównym:

type counter = Counter of int;; (* define a type *) 
type counter = Counter of int 
# let x = Counter 1;;   (* use the new type *) 
val x : counter = Counter 1 
type counter = Counter of int;; (* redefine the type, use it *) 
type counter = Counter of int 
# let incr_counter c = match c with Counter x -> Counter (x + 1);; 
val incr_counter : counter -> counter = <fun> 
# incr_counter x;;    (* now mix old and new defs *) 
Error: This expression has type counter/1029 
     but an expression was expected of type counter/1032 
# 
Powiązane problemy