我有以下代码:
 - exception Negative of string;
> exn Negative = fn : string -> exn
 - local fun fact 0 =1
            | fact n = n* fact(n-1)
    in
            fun factorial n=
            if n >= 0 then fact n
            else
            raise Negative "Insert a positive number!!!"
            handle Negative msg => 0
    end;
它有什么问题?我得到错误:
! Toplevel input:
!       handle Negative msg => 0
!                              ^
! Type clash: expression of type
!   int
! cannot have type
!   exn
我该如何解决?如果用户输入负数,我希望函数通过异常返回 0。
我还想知道当用户输入负数时如何显示消息,因为 print() 返回单位,但函数的其余部分返回 int;