[plt-scheme] typed scheme mutation & "style" question

From: keydana at gmx.de (keydana at gmx.de)
Date: Wed Apr 14 15:40:41 EDT 2010

Hi,

I have difficulties with using mutator code in typed scheme (in getting the typing right & "nice").

For example, I have a function

(: replace-attnames ((Listof (Pair Attribute String)) (Listof Attribute) -> (Listof (Listof Void))))
(define replace-attnames
  (lambda (renamings attrs)
    (map (lambda: ((mapping : (Pair Attribute String))) (map (lambda: ((a : Attribute)) (set-Attribute-name! a (cdr mapping))) (filter (lambda: ((att : Attribute)) (attribute=? att (car mapping))) attrs))) renamings)))

Here, the 

(Listof (Listof Void))

is something I need to get the code to typecheck, but I'd never have thought of it "intuitively". Is it "ugly"? I mean, is something like the above an acceptable piece of typed scheme code to write or are there better/nicer methods to deal with mutator code (of which I don't intend to have much but in the given place it really seems useful).

Many thanks in advance for your advice,
Sigrid

Posted on the users mailing list.