Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document exceptions #7

Open
copy opened this issue Nov 1, 2017 · 3 comments
Open

Document exceptions #7

copy opened this issue Nov 1, 2017 · 3 comments

Comments

@copy
Copy link

copy commented Nov 1, 2017

The exceptions that are raised should be documented, in particular what happens when an invalid image file is loaded and when Image.read_rgb is used with invalid bounds. result-returning variants would also be nice.

Also, the library should build and install mli, cmt, cmti and cmx files, so that documentation can be viewed by tools like merlin, ocp-browser, odig, etc.

@cfcs
Copy link
Collaborator

cfcs commented Nov 2, 2017

I agree re: documenting exceptions, it would be nice if someone took the time to go through and document these.

result:
@rlepigre previously expressed that they are not so fond of result (in this comment), but I personally prefer result. I think that wrapper functions that returned result types would be an OK compromise, but let's hear @rlepigre out.

Re: Installation: ocp-browser has no problems. As you can see .cmi (and .mli) files are included below.
cmx files contain the code itself; without cmx you can't link it when compiling native applications.

.cmt and .cmti are built when you pass -bin_annot to the compiler (look for safe_string in GNUmakefile for an example of how to do this). I do not know what the binary annotations are used for, but it is simple to enable their building. :)

List of files installed by the opam package:

~/.opam/4.04.2+fPIC/lib/imagelib$ ls
image.cmi     imageJPG.cmo  imagelib.cmxa  imagePNG.o     imageUtil.o
image.cmo     imageJPG.cmx  imageLib.mli   imagePPM.cmi   imageXCF.cmi
image.cmx     imageJPG.o    imageLib.o     imagePPM.cmo   imageXCF.cmo
imageGIF.cmi  imagelib.a    image.mli      imagePPM.cmx   imageXCF.cmx
imageGIF.cmo  imagelib.cma  image.o        imagePPM.o     imageXCF.o
imageGIF.cmx  imageLib.cmi  imagePNG.cmi   imageUtil.cmi  META
imageGIF.o    imageLib.cmo  imagePNG.cmo   imageUtil.cmo  opam.config
imageJPG.cmi  imageLib.cmx  imagePNG.cmx   imageUtil.cmx

@copy
Copy link
Author

copy commented Nov 2, 2017

I do not know what the binary annotations are used for, but it is simple to enable their building.

These are used by merlin for locate, document, and probably a few others. I believe ocp-browser uses them to show documentation.

rlepigre added a commit that referenced this issue Nov 2, 2017
compile with -bin_annot to support merlin (fixes #7)
@rlepigre
Copy link
Owner

rlepigre commented Nov 2, 2017

To come back on the result type VS exception debate, my reasons are simple: OCaml is not Haskell, and that's for the best. Monads and that kind of stuff may look cool, but they lead to a code that can be really hard to apprehend (for most people). Moreover, there is absolutely nothing wrong about using exceptions in exceptional situations! Especially in high-level libraries like imagelib. And as mentioned above, it is always possible to write wrapper functions if you prefer result type, but I'm not sure that we should include these in the library.

For the documentation issue, I'll do my best to update the documentation, but I'm going to be very busy in the next few weeks.

@rlepigre rlepigre reopened this Nov 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants