While attempting to compile my random value generator library with Poly/ML, I encountered a type checking bug in Poly/ML (compiled from CVS).
Steps to reproduce:
1. Get MLton lib revision 6146. 2. Run ./Make.sh in the <mltonlib>/org/mlton/vesak/use-lib/unstable directory. 3. Run poly in the <mltonlib> directory and enter the following two expressions:
use "org/mlton/vesak/use-lib/unstable/polyml.use" ; use "com/ssh/random/unstable/lib.use" ;
The output
[...] Error: in '[...]/mltonlib-6146/com/ssh/random/unstable/detail/mk-random-gen.fun', line 7. Can't match 'a MkRandomGen().cod to 'a [...]
indicates a type checking bug in Poly/ML. For convenience, here is a shell script for triggering the bug:
svn -r 6146 co svn://mlton.org/mltonlib/trunk mltonlib-6146 cd mltonlib-6146/org/mlton/vesak/use-lib/unstable/ ./Make.sh cd ../../../../.. echo 'use "org/mlton/vesak/use-lib/unstable/polyml.use" ; use "com/ssh/random/unstable/lib.use" ;' | poly
Part of the code that triggers the bug are the following type definitions in the file <mltonlib>/com/ssh/random/unstable/detail/mk-random-gen.fun:
type 'a dom = Int.t * RNG.t and 'a cod = 'a type 'a t = 'a dom -> 'a cod
If the definitions of 'a dom and 'a cod are substituted into 'a t
type 'a t = Int.t * RNG.t -> 'a
the code compiles with Poly/ML. This shouldn't be necessary however.
For the curious, the dom and cod tycons are a leftover from an earlier signature that revealed that the t tycon is an arrow.
The same code compiles fine without modification with SML/NJ, MLton, and MLKit.
-Vesa Karvonen