123456789101112131415161718192021222324252627282930313233343536(* This file is free software, part of dolmen. See file "LICENSE" for more information *)(* Arithmetic conversions *)(* ************************************************************************* *)letint_to_ratv=letz=Value.extract_exn~ops:Int.opsvinRat.mk(Q.of_bigintz)letint_to_realv=letz=Value.extract_exn~ops:Int.opsvinReal.mk(Q.of_bigintz)(* Builtins *)(* ************************************************************************* *)moduleE=Dolmen.Std.ExprexceptionUnsupported_coercionofE.Ty.t*E.Ty.tletcoercesrcdst=ifE.Ty.equalsrcdstthen(funvalue->value)elsematchE.Ty.viewsrc,E.Ty.viewdstwith|`Int,`Rat->int_to_rat|`Int,`Real->int_to_real|_,_->raise(Unsupported_coercion(src,dst))letbuiltins_env(cst:E.Term.Const.t)=matchcst.builtinwith|Dolmen.Std.Builtin.Coercion->Some(Fun.ad_hoc~cst(funsrc->Fun.ad_hoc~cst~ty_args:[src](fundst->Fun.fun_1~cst~ty_args:[src;dst](coercesrcdst))))|_->None