Functional un|unparsing
Functional un|unparsing
复制标题
函数式解|解解析
DOI:
10.1007/s10990-012-9087-2
复制
发表时间:
2012
期刊:
影响因子:
--
通讯作者:
and C.-c. Shan
中科院分区:
文献类型:
--
作者:
Asai;K.;O. Kiselyov;and C.-c. Shan
Danvy’sfunctional unparsingproblem (Danvy in J. Funct. Program. 8(6), 621–625, 1998) is to implement a type-safe ‘printf’ function, which converts a sequence of heterogeneous arguments to a string according to a given format. The dual problem is to implement a type-safe ‘scanf’ function, which extracts a sequence of heterogeneous arguments from a string byinterpreting(Friedman and Wand in LFP, pp. 348–355, 1984 and in Essentials of Programming Languages, MIT Press, 2008) the same format as an equally heterogeneous sequence of patterns that binds zero or more variables. Wederivemultiple solutions to both problems (Wand in J. ACM 27(1), 164–180, 1980) from their formal specifications (Wand in Theor. Comput. Sci. 20(1), 3–32, 1982).On one hand, our solutions show how the Hindley-Milner type system, unextended, permits accessing heterogeneous sequences with the static assurance of type safety. On the other hand, our solutions demonstrate the use ofcontrol operators(Felleisen et al. in Proceedings of the 1988 ACM Conference on Lisp and Functional Programming, pp. 52–62, ACM Press, New York, 1988; Wand in POPL 85: Conference Record of the Annual ACM Symposium on Principles of Programming Languages, vol. 16, ACM Press, New York, 1985; Meyer and Wand in Logics of Programs, Lecture Notes in Computer Science, vol. 193, pp. 219–224, Springer, Berlin, 1985) to communicate with formats ascoroutines(Wand in Proceedings of the 1980 ACM Conference on Lisp and Functional Programming, vol. 12, pp. 285–299, ACM Press, New York, 1980 and Haynes et al. in LFP, pp. 293–298, 1984).