Giter Site home page Giter Site logo

esumii / min-caml Goto Github PK

View Code? Open in Web Editor NEW
481.0 481.0 114.0 6.42 MB

moved from https://sourceforge.net/p/min-caml/code/

License: Other

Makefile 5.65% OCaml 57.73% Assembly 6.54% C 11.20% C++ 10.94% Scheme 6.27% HTML 1.40% Shell 0.22% Standard ML 0.05%

min-caml's People

Contributors

cookie-s avatar esumii avatar kato8966 avatar kensakayori avatar rhysd 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

min-caml's Issues

The type system is not polymorphic (missing generalization)

The readme states:

As in ordinary ML, MinCaml infers the types of variables and functions even if no types are given in the program. This functionality is called type inference. It is very useful in particular for programs with polymorphic and higher-order functions.

But generalization and instantiation are missing from the type system, so it's not actually implementing polymorphic functions at all. For example, this fails:

let rec f y = 0 in
let _ = f 0 in
let _ = f true in
print_int 0

with:

Fatal error: exception Typing.Error(_, 2, 1)

If this is intended, it would be good to specify that the type system does actually not support Hindley-Milner type inference.

Negative zero in floating-point constant table

In virtual.ml, an entry in floating-point constant table is reused if they equate by =. Unfortunately, = does not distinguish the sign of zero, so MinCaml wrongly convert -0.0 to 0.0 (or vice versa) if both 0.0 and -0.0 are used in the program.

For example, the following code prints 0 on OCaml, but it will print 1 on MinCaml (I haven't managed to run the generated code, but the constant table in the assembly contains only 0.0).

let rec f x = x /. 0.0 = x /. -0.0 in
if f (cos 0.0) then print_int 1 else print_int 0

In OCaml, there is Float.sign_bit to examine the sign of zero, but it is a relatively new feature (since 4.08.0). Another solution is d = d' && 1.0 /. d = 1.0 /. d'.

How do min-caml catch the type error?

the example ack.ml under floder test:

let rec ack x y =
 if x <= 0 then y + 1 else
 if y <= 0 then ack (x - 1) 1 else
 ack (x - 1) (ack x (y - 1)) in
print_int (ack 3 10)

if I change the line

print_int (ack 3 10)

to this:

print_int (ack 3 1.23)

then make,got error:

Fatal error:exception Typing.Error(_,2,3)

I search the sorce,can't find info of Typing.Error,or Fatal.so how min-caml catch the type error?The ocaml compiler display in other way:

Error:this expression has type float but an expression was expected of type int

so where is the info

Fatal error:exception Typing.Error(_,2,3)

from?Thanks!

dune 対応

ビルドシステムを dune に対応させる予定とかってありますかね.(ちょっとやってみようとしたけど,結構な改造が必要そう?)

Type inference fails when applying function contains its callee in parameter

Repro:

let rec f _ = 42 in
print_int (f f)

Error:

uninstantiated type variable detected; assuming int
Fatal error: exception Typing.Error(_, 2, _)

It looks that type inference cannot infer the type of a function which is called with itself as argument such as f in above. But I'm not sure that this is a limitation of type inference. So I created this issue.

License

Hi! MinCaml is such a wonderful project, I keep coming back to it.

Would you consider adding a license to the project (or releasing it into the public domain, whichever you prefer)?

That would make it easier to contribute / fork and experiment / derive projects from the existing code: https://choosealicense.com/no-permission/

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.