Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: A prototype typechecker

From: jan:skibinski:sympatico:ca at: 13-Nov-2002 23:22

Hi all, I'd like to update you on my progress on prototype type checker. Things go fine so far and I am testing it quite extensively using the HOF module, which I just posted to the library. I hope you will find it useful. The type checker itself uses some of the obvious patterns from the HOF script. There are still few design decisions I have to consider, such as representation for cartesian types, or for (non-rebolian) tuples. In addition to the 'check function I described before, the type checker is now directly used by a function 'chain (for lack of a better name), which provides for automatic generation of type checked partial applications; i.e., functions that take incomplete (or complete for constant functions) sets of arguments. A little sweetener shown here, the 'summary function produces summary public functions of any script - not necessary of my own. The output quality depends on how much extra information a script is able provide. summary: func [ file [file! url!] /local script names x ][ script: load/header file names: sort map :to-word sort filter :set-word? script do file print rejoin replicate 60 #"-" print rejoin ["SUMMARY of script " uppercase second split-path file] print rejoin replicate 60 #"-" foreach name names [ x: :name if any-function? get :name [ print rejoin [padd-to 20 to-string x " " mold pattern :x] ] ] ] And here is its output for HOF script: ------------------------------------------------------------ SUMMARY of script HOF.R ------------------------------------------------------------ .. ([ord] -+ [ord]) all' ((a -+ logic) -+ [a] -+ logic) and' ([logic] -+ logic) any' ((a -+ logic) -+ [a] -+ logic) cat ([[a]] -+ [a]) cycle (integer -+ [a] -+ [a]) drop (integer -+ [a] -+ [a]) drop-while ((a -+ logic) -+ [a] -+ [a]) elem (series -+ any-type -+ logic) ensure ([[logic]] -+ logic) filter ((a -+ logic) -+ [a] -+ [a]) foldl ((a -+ b -+ a) -+ a -+ [b] -+ a) foldl1 ((a -+ a -+ a) -+ [a] -+ a) foldr ((a -+ b -+ b) -+ b -+ [a] -+ b) implies (logic -+ logic -+ logic) insert-by ((a -+ a -+ logic) -+ a -+ [a] -+ [a]) iterate (integer -+ (a -+ a) -+ a -+ [a]) map ((a -+ b) -+ [a] -+ [b]) max-block ([ord] -+ ord) min-block ([ord] -+ ord) or' ([logic] -+ logic) partition ((a -+ logic) -+ [a] -+ [[a] [a]]) poly ([number] -+ number -+ number) remove-by ((a -+ a -+ logic) -+ a -+ [a] -+ [a]) replicate (integer -+ a -+ [a]) require ([[logic]] -+ logic) scanl ((a -+ b -+ a) -+ a -+ [b] -+ [a]) span ((a -+ logic) -+ [a] -+ [[a] [a]]) take (integer -+ [a] -+ [a]) take-while ((a -+ logic) -+ [a] -+ [a]) unzip ([[c]] -+ [[a] [b]]) zip ([a] -+ [b] -+ [[a b]]) Regards, Jan