Friday, February 27, 2009

Finally found exponential ML type inference in real life

Today I finally hit SML/NJ exponential type inference.  (Not surprisingly, MLton has no trouble with this example.)  Using the pretty functional record update with a record of size 13, my program was not compiling.  After trying this with smaller records I found that NJ just can't compile this.  Here's the type for makeUpdate with 8 records:


val makeUpdate8 = fn
  : ('a -> 'b) *
    (((((((('c -> (((((((('c,'d) u,'e) u,'f) u,'g) u,'h) u,'i) u,'j) u,'k) u,
            'e -> (((((((('c,'d) u,'e) u,'f) u,'g) u,'h) u,'i) u,'j) u,'k) u)
             product,
           'f -> (((((((('c,'d) u,'e) u,'f) u,'g) u,'h) u,'i) u,'j) u,'k) u)
            product,
          'g -> (((((((('c,'d) u,'e) u,'f) u,'g) u,'h) u,'i) u,'j) u,'k) u)
           product,
         'h -> (((((((('c,'d) u,'e) u,'f) u,'g) u,'h) u,'i) u,'j) u,'k) u)
          product,
        'i -> (((((((('c,'d) u,'e) u,'f) u,'g) u,'h) u,'i) u,'j) u,'k) u)
         product,
       'j -> (((((((('c,'d) u,'e) u,'f) u,'g) u,'h) u,'i) u,'j) u,'k) u)
        product,
      'k -> (((((((('c,'d) u,'e) u,'f) u,'g) u,'h) u,'i) u,'j) u,'k) u)
       product
     -> 'l) * ('m -> 'n)
    -> 'm
       -> ('l *
           (((((((('o,'p) product,'q) product,'r) product,'s) product,'t)
                product,'u) product,'v) product *
            (((((((('o,'w) u,'p) u,'q) u,'r) u,'s) u,'t) u,'u) u,'v) u
            -> ((((((('o,'p) product,'q) product,'r) product,'s) product,'t)
                   product,'u) product,'v) product) * 'n,'x * 'y * 'a,'b,'z)
            Fold.t

1 comment: