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

Reported type error #8008

Closed
vicuna opened this issue Feb 6, 2003 · 2 comments
Closed

Reported type error #8008

vicuna opened this issue Feb 6, 2003 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Feb 6, 2003

Original bug ID: 1536
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Dr Andrew A. Adams
Version: Caml Light 0.75/0.75
OS: RedHat Linux 7.3
Submission from: viwc1.rdg.ac.uk (134.225.16.91)

I have an application I'm developing to teach first year students. It involves
implementing types for Binary, Octal and Hexadecimal numbers and defining
conversions between them, integers and string representations of the Binary,
Octal and Hex numbers. When I cam to write the final part of this I wanted to
translate a list of string representations between two number systems leading to
the expression:

(map string_of_Octal (map Octal_of_Binary (map Binary_of_string strs)))

which leads to an error:

File "translation.ml", line 16, characters 8-33:

  			  (map Binary_of_string strs))));
  			   ^^^^^^^^^^^^^^^^^^^^^^^^^

This expression has type Binary list,
but is used with type Binary list.

A gzipped tar file with all the code is available at:

http://www.personal.rdg.ac.uk/~sis00aaa/BODH.tgz

include "translation";;

will show the error.

@vicuna
Copy link
Author

vicuna commented Feb 6, 2003

Comment author: administrator

Full_Name: Dr Andrew A. Adams
Version: Caml Light 0.75/0.75
OS: RedHat Linux 7.3
Submission from: viwc1.rdg.ac.uk (134.225.16.91)

I have an application I'm developing to teach first year students. It involves
implementing types for Binary, Octal and Hexadecimal numbers and defining
conversions between them, integers and string representations of the Binary,
Octal and Hex numbers. When I cam to write the final part of this I wanted to
translate a list of string representations between two number systems leading to
the expression:

(map string_of_Octal (map Octal_of_Binary (map Binary_of_string strs)))

which leads to an error:

File "translation.ml", line 16, characters 8-33:

			  (map Binary_of_string strs))));
			   ^^^^^^^^^^^^^^^^^^^^^^^^^

This expression has type Binary list,
but is used with type Binary list.

A gzipped tar file with all the code is available at:

http://www.personal.rdg.ac.uk/~sis00aaa/BODH.tgz

include "translation";;

will show the error.

Your problem is due to multiple redefinitions of types, since some
files that define basic types of the application are loaded more than
once (hence redefining over and over again the types they already
defined). This problem is explained in long in the FAQ of the
language: it is the first question about typing

* Error message: a type is not compatible with itself ?

Have a look to http://pauillac.inria.fr/caml/FAQ/FAQ_EXPERT-eng.html

The solution is to clear all the include directives into your files
(except for the last one). Somewhat better, you should add a new
main.ml file to contain the set of include directives necessary to
build your application:

(* File main.ml *)
include "binary";;
include "octal";;
include "hex";;
include "chunk";;
include "translate";;
include "transdec";;
include "dectrans";;
include "reading";;
include "writing";;
include "translation";;

(* End of file main.ml *)

This completely clarifies the situation :)

Then a new type error is reported:

File "translation.ml", line 11, characters 17-34:

                                  (map Decimal_of_Binary
                                       ^^^^^^^^^^^^^^^^^

The value identifier Decimal_of_Binary is unbound.

in effect:

$ grep Decimal_of_Binary *.ml
translation.ml: (map Decimal_of_Binary

But this one is yours ...

Even better, you could use modules that would be compiled separately and
build your entire system using a Makefile (the FAQ gives examples of
Makefile where you just have to list the files to get your application
automatically built). This is easy and scalable ...

Hope this helps.

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/

@vicuna
Copy link
Author

vicuna commented Feb 11, 2003

Comment author: administrator

FAQ (type redefinition).

@vicuna vicuna closed this as completed Feb 11, 2003
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant