Git Product home page Git Product logo

num's Introduction

⚠️ CAUTION

The developer team released OCaml 5.0.0 in December 2022. This release sports a full rewrite of its runtime system for shared-memory parallel programming using domains and native support for concurrent programming using effect handlers.

Owing to the large number of changes, the initial 5.0 release is more experimental than usual. It is recommended that all users wanting a stable release use the 4.14 release which will continue to be supported and updated while 5.x reaches feature and stability parity. Similarly, if you need one of the ports not yet supported in the 5.0 release you must use the 4.14 release.

The initial release of OCaml 5.0 only supports the native compiler under ARM64 and x86-64 architectures under Linux, macOS and the BSDs. On Windows, only the MinGW-w64 port is supported in OCaml 5.0 and the Cygwin port is restored in 5.1. On Linux, native code support for RISC-V and s390x/IBM Z is available in OCaml 5.1 and in 5.2 for Power.

❗ From OCaml 5.0 onwards, native compilation is available only on 64-bit systems. Native compilation on 32-bit systems is no longer available, nor are there plans to bring it back. The bytecode compiler will continue to work on all architectures.

Branch trunk Branch 5.2 Branch 5.1 Branch 5.0 Branch 4.14

Github CI Build Status (trunk branch) Github CI Hygiene Status (trunk branch) AppVeyor Build Status (trunk branch)

Github CI Build Status (5.2 branch) AppVeyor Build Status (5.2 branch)

Github CI Build Status (5.1 branch) AppVeyor Build Status (5.1 branch)

Github CI Build Status (5.0 branch) AppVeyor Build Status (5.0 branch)

Github CI Build Status (4.14 branch) AppVeyor Build Status (4.14 branch)

README

Overview

OCaml is a functional, statically-typed programming language from the ML family, offering a powerful module system extending that of Standard ML and a feature-rich, class-based object system.

OCaml comprises two compilers. One generates bytecode which is then interpreted by a C program. This compiler runs quickly, generates compact code with moderate memory requirements, and is portable to many 32 or 64 bit platforms. Performance of generated programs is quite good for a bytecoded implementation. This compiler can be used either as a standalone, batch-oriented compiler that produces standalone programs, or as an interactive REPL system.

The other compiler generates high-performance native code for a number of processors. Compilation takes longer and generates bigger code, but the generated programs deliver excellent performance, while retaining the moderate memory requirements of the bytecode compiler. The native-code compiler currently runs on the following platforms:

Tier 1 (actively maintained) Tier 2 (maintained when possible)

x86 64 bits

Linux, macOS, Windows, FreeBSD

NetBSD, OpenBSD, OmniOS (Solaris)

ARM 64 bits

Linux, macOS

FreeBSD, OpenBSD, NetBSD

Power 64 bits

Linux (little-endian, ABIv2)

Linux (big-endian, ABIv2)

RISC-V 64 bits

Linux

IBM Z (s390x)

Linux

Other operating systems for the processors above have not been tested, but the compiler may work under other operating systems with little work.

All files marked "Copyright INRIA" in this distribution are Copyright © 1996-2023 Institut National de Recherche en Informatique et en Automatique (INRIA) and distributed under the conditions stated in file LICENSE.

Installation

See the file INSTALL.adoc for installation instructions on machines running Unix, Linux, macOS, WSL and Cygwin. For native Microsoft Windows, see README.win32.adoc.

Documentation

The OCaml manual is distributed in HTML, PDF, and Emacs Info files. It is available at

Availability

The complete OCaml distribution can be accessed at

Keeping in Touch with the Caml Community

There is an active and friendly discussion forum at

The OCaml mailing list is the longest-running forum for OCaml users. You can email it at

You can subscribe and access list archives via the Web interface at

There also exist other mailing lists, chat channels, and various other forums around the internet for getting in touch with the OCaml and ML family language community. These can be accessed at

In particular, the IRC channel #ocaml on Libera has a long history and welcomes questions.

Bug Reports and User Feedback

Please report bugs using the issue tracker at https://github.com/ocaml/ocaml/issues

To be effective, bug reports should include a complete program (preferably small) that exhibits the unexpected behavior, and the configuration you are using (machine type, etc).

For information on contributing to OCaml, see HACKING.adoc and CONTRIBUTING.md.

Separately maintained components

Some libraries and tools which used to be part of the OCaml distribution are now maintained separately and distributed as OPAM packages. Please use the issue trackers at their respective new homes:

Library Removed since OPAM package

The Stream and Genlex standard library modules

OCaml 5.0

camlp-streams

The Graphics library

OCaml 4.09

graphics

The Num library

OCaml 4.06

num

The OCamlbuild tool

OCaml 4.03

ocamlbuild

The camlp4 tool

OCaml 4.02

camlp4

The LablTk library

OCaml 4.02

labltk

The CamlDBM library

OCaml 4.00

dbm

The OCamlWinTop Windows toplevel

OCaml 4.00

none

num's People

Contributors

alainfrisch avatar bschommer avatar damiendoligez avatar dra27 avatar gasche avatar glondu avatar hhugo avatar kit-ty-kate avatar lefessan avatar maranget avatar mshinwell avatar nojb avatar np avatar pierreweis avatar rgrinberg avatar roglo avatar shindere avatar thelortex avatar vouillon avatar whitequark avatar xavierleroy avatar xclerc avatar zoggy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

num's Issues

Don't release with -warn-error A

We should practice what we preach - this library is no longer in the OCaml distribution, so we should have -warn-error A in developer mode only, not in release mode. Of course, that means we also need developer/release mode!

Bytecode-only build does not work: build system tries to use missing `ocamlopt` and freezes

This is the same issue which was present in 1.4, and despite a PR #30 intending to fix it, it is still broken in 1.5, unfortunately.

This is what happens on ppc (where only bytecode is available):

--->  Configuring ocaml-num
--->  Building ocaml-num
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_ocaml_ocaml-num/ocaml-num/work/num-1.5" && /usr/bin/make -j6 -w all 
make: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_ocaml_ocaml-num/ocaml-num/work/num-1.5'
/usr/bin/make -C src all
make[1]: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_ocaml_ocaml-num/ocaml-num/work/num-1.5/src'
ocamlc -ccopt -DBNG_ARCH_power -c bng.c
ocamlc -ccopt -DBNG_ARCH_power -c nat_stubs.c
ocamlc -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c int_misc.mli
ocamlc -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c nat.mli
ocamlc -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c arith_flags.mli
ocamlc -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c arith_status.mli
cp ../toplevel/num_top_printers.mli ../toplevel/num_top.mli ../toplevel/num_top_printers.ml ../toplevel/num_top.ml .
cp ../toplevel/num_top_printers.mli ../toplevel/num_top.mli ../toplevel/num_top_printers.ml ../toplevel/num_top.ml .
cp ../toplevel/num_top_printers.mli ../toplevel/num_top.mli ../toplevel/num_top_printers.ml ../toplevel/num_top.ml .
ocamlc -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c num_top.mli
echo 'version = "1.6~dev"' > META.top
cat META.num-top.in >> META.top
ocamlopt -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c int_misc.ml
make[1]: posix_spawn: ocamlopt: No such file or directory
ocamlc -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c int_misc.ml
ocamlc -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c nat.ml
ocamlc -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c big_int.mli
ocamlc -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c arith_flags.ml
ocamlc -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c ratio.mli
ocamlc -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c arith_status.ml
ocamlc -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c num_top.ml
ocamlc -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c big_int.ml
ocamlc -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c ratio.ml
ocamlc -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c num.mli
ocamlmklib -oc nums bng.o nat_stubs.o
ocamlc -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c num.ml
ocamlc -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c num_top_printers.mli
ocamlc -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c num_top_printers.ml
ocamlc -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -a -o num_top.cma num_top_printers.cmo num_top.cmo
ocamlmklib -o nums -oc nums -linkall int_misc.cmo nat.cmo big_int.cmo arith_flags.cmo ratio.cmo num.cmo arith_status.cmo

Notice what the build system tries:

ocamlopt -w +a-4-9-41-42-44-45-48  -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c int_misc.ml
make[1]: posix_spawn: ocamlopt: No such file or directory

In result the build just freezes and I have to interrupt the process. Libraries are in fact successfully built, but forcing ocamlopt call prevents it from completion.

@dra27 Could you please take a look? It should be pretty trivial to fix in the master: we just need it to check if ocamlopt is de facto available, or at least offer a configure option to switch off native code generation, if reliable detection during the build is problematic for some reason.

Num library fails to install on Cygwin/Mingw64

When trying to install the Num library on Windows (Cygwin + Mingw64) with OCaml 4.06.0, the build
succeeds but installation fails. I presume this is due to the incorrect filename extension that is used for the generated DLL. The scripts somehow use the $SO variable from the core configuration files of the OCaml compiler (which is for some unknown reason set to "s.o").

As far as I can tell, the filename extension used should be "dll" in the Cygwin/Mingw64 environment.

Here is the output of make all:

marneu@build ~/setup/num
$ make all
make -C src all
make[1]: Entering directory '/home/marneu/setup/num/src'
ocamlc -ccopt -DBNG_ARCH_amd64 -c bng.c
ocamlc -ccopt -DBNG_ARCH_amd64 -c nat_stubs.c
ocamlmklib -oc nums bng.o nat_stubs.o
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c int_misc.mli
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c int_misc.ml
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c nat.mli
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c nat.ml
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c big_int.mli
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c big_int.ml
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c arith_flags.mli
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c arith_flags.ml
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c ratio.mli
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c ratio.ml
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c num.mli
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c num.ml
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c arith_status.mli
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c arith_status.ml
ocamlmklib -o nums -oc nums -linkall int_misc.cmo nat.cmo big_int.cmo arith_flags.cmo ratio.cmo num.cmo arith_status.cmo
ocamlopt -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -O3 -c int_misc.ml
ocamlopt -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -O3 -c nat.ml
ocamlopt -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -O3 -c big_int.ml
ocamlopt -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -O3 -c arith_flags.ml
ocamlopt -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -O3 -c ratio.ml
ocamlopt -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -O3 -c num.ml
ocamlopt -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -O3 -c arith_status.ml
ocamlmklib -o nums -oc nums -linkall int_misc.cmx nat.cmx big_int.cmx arith_flags.cmx ratio.cmx num.cmx arith_status.cmx
ocamlopt -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -O3 -I . -shared -o nums.cmxs nums.cmxa
make[1]: Leaving directory '/home/marneu/setup/num/src'
make -C toplevel all
make[1]: Entering directory '/home/marneu/setup/num/toplevel'
ocamlc -I ../src -I +compiler-libs -w +a-4-9-41-42-44-45-48 -warn-error A -safe-string -strict-sequence -strict-formats -c num_top_printers.mli
ocamlc -I ../src -I +compiler-libs -w +a-4-9-41-42-44-45-48 -warn-error A -safe-string -strict-sequence -strict-formats -c num_top_printers.ml
ocamlc -I ../src -I +compiler-libs -w +a-4-9-41-42-44-45-48 -warn-error A -safe-string -strict-sequence -strict-formats -c num_top.mli
ocamlc -I ../src -I +compiler-libs -w +a-4-9-41-42-44-45-48 -warn-error A -safe-string -strict-sequence -strict-formats -c num_top.ml
ocamlc -I ../src -I +compiler-libs -w +a-4-9-41-42-44-45-48 -warn-error A -safe-string -strict-sequence -strict-formats -a -o num_top.cma num_top_printers.cmo num_top.cmo
make[1]: Leaving directory '/home/marneu/setup/num/toplevel'

The following is the output of the make install command:

marneu@build ~/setup/num
$ make install
make -C src install
make[1]: Entering directory '/home/marneu/setup/num/src'
ocamlfind install num META
Installed C:/ocamlmgw64/lib/site-lib\num\META
install -m 644 nums.cma libnums.a big_int.cmi nat.cmi num.cmi ratio.cmi arith_status.cmi big_int.mli nat.mli num.mli ratio.mli arith_status.mli big_int.cmti nat.cmti num.cmti ratio.cmti arith_status.cmti nums.cmxa nums.a big_int.cmx nat.cmx num.cmx ratio.cmx arith_status.cmx nums.cmxs C:/ocamlmgw64/lib
install dllnums.s.o C:/ocamlmgw64/lib/stublibs
install: cannot stat 'dllnums.s.o': No such file or directory
make[1]: *** [Makefile:88: install] Error 1
make[1]: Leaving directory '/home/marneu/setup/num/src'
make: *** [Makefile:14: install] Error 2

And here an excerpt of the contents of the /config/Makefile that was used to build OCaml 4.06.0:

########## Toolchain and OS dependencies

TOOLCHAIN=mingw

### Toolchain prefix
TARGET=x86_64-w64-mingw32
HOST=$(TARGET)

TOOLPREF=$(TARGET)-

CCOMPTYPE=cc
O=o
A=a
S=s
SO=s.o
EXE=.exe
EMPTY=

Should more `cmx` files be installed?

When compiling with flambda at high optimization settings we get:

OCAMLOPT  plugins/micromega/polynomial.ml
File "_none_", line 1:
Error (warning 58): no cmx file was found in path for module Arith_flags, and its interface was not compiled with -opaque
File "_none_", line 1:
Error (warning 58): no cmx file was found in path for module Int_misc, and its interface was not compiled with -opaque
Makefile.build:736: recipe for target 'plugins/micromega/polynomial.cmx' failed

should the cmx for these files also installed?

How to use `num` with OCamlbuild?

In QuickChick/QuickChick#102, I need to compile a program that uses Big.big_int into .native executables. Is OCamlbuild the right tool to use? If yes, how shall we avoid the error message?

File "BinPos.mli", line 6, characters 13-24:
Error: Unbound module Big

nums.cmxs is installed without execute bit set

When installing num via opam, the installed file lib/ocaml/nums.cmxs has no execute bit set. This leads to errors under Cygwin, which seems to check for execution permission when loading a .cmxs file (I don't know exactly why, but it does).

Note that almost every .cmxs file has its bit set, e.g. str.cmxs and unix.cmxs do, so this behavior is at least inconsistent with most of the remaining OCaml platform.

It seems the current master version, based on dune, does not have this issue (I didn't try, but by default dune sets the bit), but since the latest release available on opam is 1.4, its old makefile is still used.

Maybe I could submit a patch to opam-repository which only applies to {os = "windows"}? Would it be acceptable?

`opam install num` fails

I am trying to install num using opam. However the build fails with following message:

# ocamlfind: Package num is already installed
#  - (file /home/dev/.opam/default/lib/num/META already exists)
Full output
[dev@localhost ~]$ eval $(opam env)
[dev@localhost ~]$ opam show num

<><> num: information on all versions <><><><><><><><><><><><><><><><><><><><><>
name         num
all-versions 0  1.0  1.1  1.2  1.3  1.4

<><> Version-specific details <><><><><><><><><><><><><><><><><><><><><><><><><>
version       1.4
repository    default
url.src:      "https://github.com/ocaml/num/archive/v1.4.tar.gz"
url.checksum:
          "md5=cda2b727e116a0b6a9c03902cc4b2415"
          "sha512=0cc9be8ad95704bb683b4bf6698bada1ee9a40dc05924b72adc7b969685c33eeb68ccf174cc09f6a228c48c18fe94af06f28bebc086a24973a066da620db8e6f"
homepage:     "https://github.com/ocaml/num/"
bug-reports:  "https://github.com/ocaml/num/issues"
dev-repo:     "git+https://github.com/ocaml/num.git"
authors:      "Valérie Ménissier-Morain" "Pierre Weis" "Xavier Leroy"
maintainer:   "Xavier Leroy <[email protected]>"
license:      "LGPL-2.1-only with OCaml-LGPL-linking-exception"
depends:      "ocaml" {>= "4.06.0"} "ocamlfind" {build & >= "1.7.3"}
conflicts:    "base-num"
synopsis      The legacy Num library for arbitrary-precision integer and rational arithmetic
[dev@localhost ~]$ opam install num
The following actions will be performed:
  ∗ install ocamlfind 1.9.1 [required by num]
  ∗ install num       1.4
===== ∗ 2 =====
Do you want to continue? [Y/n] y

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[num.1.4] downloaded from cache at https://opam.ocaml.org/cache
[ocamlfind.1.9.1] downloaded from cache at https://opam.ocaml.org/cache

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
∗ installed ocamlfind.1.9.1
[ERROR] The installation of num failed at "make findlib-install".

#=== ERROR while installing num.1.4 ===========================================#
# context     2.0.6 | linux/x86_64 | ocaml-system.4.10.0 | https://opam.ocaml.org#d9074796
# path        ~/.opam/default/.opam-switch/build/num.1.4
# command     ~/.opam/opam-init/hooks/sandbox.sh install make findlib-install
# exit-code   2
# env-file    ~/.opam/log/num-24962-899ac0.env
# output-file ~/.opam/log/num-24962-899ac0.out
### output ###
# make -C src findlib-install
# make[1]: Entering directory '/home/dev/.opam/default/.opam-switch/build/num.1.4/src'
# sed -e '/\^/d' -e 's/%%VERSION%%/1.4/g' META.in > META
# ocamlfind install num META nums.cma libnums.a big_int.cmi nat.cmi num.cmi ratio.cmi arith_status.cmi big_int.mli nat.mli num.mli ratio.mli arith_status.mli big_int.cmti nat.cmti num.cmti ratio.cmti arith_status.cmti nums.cmxa nums.a int_misc.cmx nat.cmx big_int.cmx arith_flags.cmx ratio.cmx num.cmx arith_status.cmx nums.cmxs dllnums.so
# ocamlfind: Package num is already installed
#  - (file /home/dev/.opam/default/lib/num/META already exists)
# make[1]: *** [Makefile:101: findlib-install] Error 2
# make[1]: Leaving directory '/home/dev/.opam/default/.opam-switch/build/num.1.4/src'
# make: *** [Makefile:18: findlib-install] Error 2



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ ∗ install num 1.4
└─ 
┌─ The following changes have been performed
│ ∗ install ocamlfind 1.9.1
└─ 

The former state can be restored with:
    opam switch import "/home/dev/.opam/default/.opam-switch/backup/state-20210503221339.export"

Unbound module Longident

Hello,
I'm trying to build num as a dependency of Scilab with ocaml 4.06 on an Arch Linux machine, but make fails with the following log. Do you have any advice to make it build ?

make -C src all
make[1]: Entering directory 'src'
ocamlc -ccopt -DBNG_ARCH_amd64 -c bng.c
ocamlc -ccopt -DBNG_ARCH_amd64 -c nat_stubs.c
ocamlmklib -oc nums bng.o nat_stubs.o
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c int_misc.mli
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c int_misc.ml
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c nat.mli
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c nat.ml
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c big_int.mli
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c big_int.ml
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c arith_flags.mli
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c arith_flags.ml
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c ratio.mli
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c ratio.ml
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c num.mli
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c num.ml
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c arith_status.mli
ocamlc -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c arith_status.ml
ocamlmklib -o nums -oc nums -linkall int_misc.cmo nat.cmo big_int.cmo arith_flags.cmo ratio.cmo num.cmo arith_status.cmo
ocamlopt -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c int_misc.ml
ocamlopt -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c nat.ml
ocamlopt -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c big_int.ml
ocamlopt -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c arith_flags.ml
ocamlopt -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c ratio.ml
ocamlopt -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c num.ml
ocamlopt -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -c arith_status.ml
ocamlmklib -o nums -oc nums -linkall int_misc.cmx nat.cmx big_int.cmx arith_flags.cmx ratio.cmx num.cmx arith_status.cmx
ocamlopt -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot -g -safe-string -strict-sequence -strict-formats -I . -shared -o nums.cmxs nums.cmxa
make[1]: Leaving directory 'src'
make -C toplevel all
make[1]: Entering directory 'toplevel'
ocamlc -I ../src -I +compiler-libs -w +a-4-9-41-42-44-45-48 -warn-error A -safe-string -strict-sequence -strict-formats -c num_top_printers.mli
ocamlc -I ../src -I +compiler-libs -w +a-4-9-41-42-44-45-48 -warn-error A -safe-string -strict-sequence -strict-formats -c num_top_printers.ml
ocamlc -I ../src -I +compiler-libs -w +a-4-9-41-42-44-45-48 -warn-error A -safe-string -strict-sequence -strict-formats -c num_top.mli
ocamlc -I ../src -I +compiler-libs -w +a-4-9-41-42-44-45-48 -warn-error A -safe-string -strict-sequence -strict-formats -c num_top.ml
File "num_top.ml", line 17, characters 5-14:
Error: Unbound module Longident

/usr/lib/ocaml/stublibs not created

There is a problem installing ocaml-num into a DESTDIR where /usr/lib/ocaml/stublibs does not exist yet:
install dllnums.so /destdir//ocaml-num-1.1//usr/lib/ocaml/stublibs will install the dllnums.so as stublibs file. You need to create the directory first.

The `.cmx` files should be installed as well

Compiling a package that depends on num under recent OCaml versions currently generates loads of the following warnings:

File "_none_", line 1:
Warning 58: no cmx file was found in path for module Big_int, and its interface was not compiled with -opaque
File "_none_", line 1:
Warning 58: no cmx file was found in path for module Num, and its interface was not compiled with -opaque

Num.num_of_string should accept decimal numbers

Original bug ID: 4553
Reporter: zack
Status: acknowledged (set by @damiendoligez on 2008-08-04T15:21:21Z)
Resolution: open
Priority: normal
Severity: feature
Version: 3.10.1
Category: otherlibs

Bug description

It seems that Num.num_of_string works only on strings denoting integers:

Num.num_of_string "1.5";;

Exception: Failure "num_of_string".

Supporting decimal numbers appears to be quite easy: numbers such as "1.5" can be mapped to the Ratio.ratio "15/10" and then injected to Num using the Num.Ratio constructor. The change will be backward compatible as the new functionality can be triggered only when the input string contain a '.', situation which currently raise the Failure above.

Can you please consider adding support for decimal numbers in the Num.num_of_string function?

A sample implementation (relying on the current implementation of Num.num_of_string for integer strings) is reported below in the additional information section.

Cheers.

Additional information

let my_num_of_string s =
let dot_pos = try Some (String.index s '.') with Not_found -> None in
match dot_pos with
| None -> Num.num_of_string s
| Some i -> (* e.g.: s = "45.6789", i = 2 )
let len = String.length s in
let numerator = (
e.g. "45" ^ "6789" = "456789" )
String.sub s 0 i ^ String.sub s (i + 1) (len - (i + 1)) in
let denominator = (
e.g. <big_int 10000> *)
Big_int.power_int_positive_int 10 (len - (i + 1)) in
Num.Ratio (Ratio.create_ratio (big_int_of_string numerator) denominator)

Big_Int random numbers

(This issue has been imported from the OCaml bugtracker)

Original bug ID: 4652
Reporter: hugo
Status: acknowledged (set by @damiendoligez on 2008-12-03T13:12:55Z)
Resolution: open
Priority: normal
Severity: feature
Version: 3.10.2
Category: otherlibs
Related to: #4641

Bug description

A recent request (0004641) was filed asking for bit twiddling functions for the
Big_Int in the Num library. In the same vein I would like to ask if random number
generation may also be added the Num library, specifically for the integers.

Additional information

I am working on a simulator to test a machine learning algorithm and require
the use of arbitrary precision integers and the generation of random
values of such integers. Currently to do this I must use the GMP library
(http://gmplib.org/) which I could otherwise avoid.

num fails to build with dune 3.0

Building with dune 2.x never failed AFAIR. But with 3.0 it fails consistently:

[   14s] + dune installed-libraries
[   14s] bigarray               (version: [distributed with OCaml])
[   14s] bytes                  (version: [distributed with OCaml])
[   14s] compiler-libs          (version: [distributed with OCaml])
[   14s] compiler-libs.bytecomp (version: [distributed with OCaml])
[   14s] compiler-libs.common   (version: [distributed with OCaml])
[   14s] compiler-libs.optcomp  (version: [distributed with OCaml])
[   14s] compiler-libs.toplevel (version: [distributed with OCaml])
[   14s] dynlink                (version: [distributed with OCaml])
[   14s] ocamldoc               (version: [distributed with OCaml])
[   14s] raw_spacetime          (version: 4.13.1)
[   14s] seq                    (version: 4.13.1)
[   14s] stdlib                 (version: [distributed with OCaml])
[   14s] str                    (version: [distributed with OCaml])
[   14s] threads                (version: [distributed with OCaml])
[   14s] threads.posix          (version: [distributed with OCaml])
[   14s] uchar                  (version: 4.13.1)
[   14s] unix                   (version: [distributed with OCaml])
...
[   14s] + dune build --verbose --for-release-of-packages=num -j8 @install
...
[   14s] Actual targets:
[   14s] - recursive alias @install
[   15s] Running[1]: (cd _build/default/src && /usr/bin/gcc-11 -O2 -fno-strict-aliasing -fwrapv -pthread -Werror=implicit-function-declaration -Werror=return-type -Wno-deprecated-declarations -ffat-lto-objects -fPIC -pipe -D_FILE_OFFSET_BITS=64 -DBNG_ARCH_amd64 -g -I /usr/lib64/ocaml -o bng.o -c bng.c)
[   15s] Running[2]: (cd _build/default/src && /usr/bin/gcc-11 -O2 -fno-strict-aliasing -fwrapv -pthread -Werror=implicit-function-declaration -Werror=return-type -Wno-deprecated-declarations -ffat-lto-objects -fPIC -pipe -D_FILE_OFFSET_BITS=64 -DBNG_ARCH_amd64 -g -I /usr/lib64/ocaml -o nat_stubs.o -c nat_stubs.c)
[   15s] Running[3]: (cd _build/default && /usr/bin/ocamlc.opt -w -40 -g -a -o src/num.cma)
[   15s] Running[4]: (cd _build/default && /usr/bin/ocamlopt.opt -w -40 -g -a -o src/num.cmxa)
[   15s] Running[5]: (cd _build/default && /usr/bin/ocamlopt.opt -w -40 -g -shared -linkall -I src -o src/num.cmxs src/num.cmxa)
[   15s] File "src/dune", line 14, characters 21-24:
[   15s] 14 |   (c_names nat_stubs bng bng_generic)
[   15s]                           ^^^
[   15s] Command [1] exited with code 1:
[   15s] $ (cd _build/default/src && /usr/bin/gcc-11 -O2 -fno-strict-aliasing -fwrapv -pthread -Werror=implicit-function-declaration -Werror=return-type -Wno-deprecated-declarations -ffat-lto-objects -fPIC -pipe -D_FILE_OFFSET_BITS=64 -DBNG_ARCH_amd64 -g -I /usr/lib64/ocaml -o bng.o -c bng.c)
[   15s] bng.c:23:10: fatal error: bng_amd64.c: No such file or directory
[   15s]    23 | #include "bng_amd64.c"
[   15s]       |          ^~~~~~~~~~~~~
[   15s] compilation terminated.
[   15s] Running[6]: (cd _build/default/src && /usr/bin/touch bng_generic.c)

Undocumented exception(s) in the Num module

Original bug ID: 7065
Reporter: SpiceGuid
Status: acknowledged (set by @gasche on 2015-11-28T20:19:38Z)
Resolution: open
Priority: low
Severity: feature
Target version: later
Category: documentation

Bug description

Some people assume they can compute square root or cubic root by providing
a 1/2 or 1/3 ratio argument to the Num.power_num function.

Unfortunately they can't :

# #load "nums.cma";;
# open Num;;
# int_of_num (Int 27 **/ (Int 1 // Int 3));;
Exception: Invalid_argument "power_num".

The problem is not they can't, the problem is they assume they can and are encouraged by the silent documentation to do so.

I suggest that all Num functions should be totally documented, including exceptions and conditions that can raise them.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.