Abstract
We solve the problem of extending Bird and Paterson’s generalized folds for nested datatypes and its dual to inductive and coinductive constructors of arbitrarily high ranks by appropriately generalizing Mendler-style (co)iteration.Characteristically to Mendler-style schemes of disciplined (co)recursion,the schemes we propose do not rest on notions like positivity or monotonicity of a constructor and facilitate programming in a natural and elegant style close to programming with the customary letrec construct,where the typings of the schemes,however, guarantee termination. For rank 2,a smoothened version of Bird and Paterson's generalized folds and its dual are achieved;for rank 1,the schemes instantiate to Mendler's original (re)formulation of iteration and coiteration. Several examples demonstrate the power of the approach. Strong normalization of our proposed extension of system F ω of higher-order parametric polymorphism is proven by a reduction-preserving embedding into pure F ω.
The first author gratefully acknowledges the support by the PhD Programme Logic in Computer Science (GKLI)of the Deutsche Forschungs-Gemeinschaft.
The third author is partially supported by the Estonian Science Foundation (ETF)under grant No.4155. He is also grateful to the GKLI for two invitations to Munich;the cooperation started during these visits.
Chapter PDF
Similar content being viewed by others
Keywords
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
References
A. Abel.Termination checking with types.Technical Report 0201,Inst. für Infor-matik,Ludwigs-Maximilians-Univ. München,2002.
A. Abel and R. Matthes.(Co-)iteration for higher-order nested datatypes. To appear in H. Geuvers, F. Wiedijk,eds.,Post-Conf. Proc. of IST WG TYPES 2nd Ann. Meeting, TYPES’02 Lect. Notes in Comput. Sci.Springer-Verlag.
T. Altenkirch and C. McBride.Generic programming within dependently typed programming.To appear in J. Gibbons and J. Jeuring,Proc. of IFIP TC2 WC on Generic Programming, WCGP 2002 Kluwer Acad.Publishers.
T. Altenkirch and B. Reus.Monadic presentations of lambda terms using general-ized inductive types.In J. Flum and M. Rodríguez-Artalejo,eds.,Proc. of 13th Int. Wksh. on Computer Science Logic, CSL’99 vol.1683 of Lect. Notes in Comput. Sci.pp.53–468.Springer-Verlag,1999.
G. Barthe, M.J. Frade, E. Giménez, L. Pinto,and T. Uustalu.Type-based termi-nation of recursive definitions.Math. Struct. in Comput. Sci., to appear.
R. Bird, J. Gibbons,and G. Jones.Program optimisation,naturally.In J. Davies, B. Roscoe, J. Woodcock,eds.,Millenial Perspectives in Computer Science. Pal-grave,2000.
R. Bird and L. Meertens.Nested datatypes.In J. Jeuring,ed.,Proc. of 4th Int. Conf. on Mathematics of Program Construction, MPC’98, vol.1422 of Lect. Notes in Comput. Sci., pp.52–67.Springer-Verlag,1998.
R. Bird and R. Paterson.Generalised folds for nested datatypes.Formal Aspects of Comput., 11(2):200–222,1999.
R. Bird and R. Paterson.De Bruijn notation as a nested datatype. J. of Funct. Program., 9(1):77–91,1999.
E. Giménez.Structural recursive definitions in type theory.In Proc. of 25th Int. Coll. on Automata, Languages and Programming, ICALP’98, vol.1443 of Lect. Notes in Comput. Sci., pp.397–408.Springer-Verlag,1998.
R. Hinze.Efficient generalized folds.In J. Jeuring,ed.,Proc.of 2nd Wksh. on Generic Programming, WGP 2000, Tech. Report UU-CS-2000-19, Dept.of Comput.Sci.,Utrecht Univ., pp.1–16.2000.
R. Hinze.Manufacturing datatypes. J. of Funct. Program.11(5):493–524,2001.
R. Hinze.Polytypic values possess polykinded types. Sci. of Comput. Program. 43(2–3):129–159, 2002.
C. B. Jay.Distinguishing data structures and functions:The constructor calculus and functorial types.In S. Abramsky,ed.,Proc. of 5th Int. Conf. on Typed Lambda Calculi and Appl., TLCA’01, vol. 2044 of Lect. Notes in Comput. Sci., pp.217–239. Berlin,2001.
C. Martin, J. Gibbons and I. Bayley.Disciplined,efficient,generalised folds for nested datatypes.Submitted.
R. Matthes.Extensions of System F by Iteration and Primitive Recursion on Monotone Inductive Types. PhD thesis,Ludwig-Maximilians-Univ.München,1998.
R. Matthes.Monotone inductive and coinductive constructors of rank 2.In L. Fribourg,ed.,Proc. of 15th Int. Wksh. on Computer Science Logic, CSL 2001 vol.2142 of Lect. Notes in Comput. Sci., pp.600–614.Springer-Verlag, 2001.
N. P. Mendler.Recursive types and type constraints in second-order lambda cal-culus.In Proc. of 2nd Ann. IEEE Symp. on Logic in Computer Science, LICS’87, pp.30–36. IEEE CS Press, 1987.
N. P. Mendler.Inductive types and type constraints in the second-order lambda calculus.Ann. of Pure and Appl. Logic 51(1–2):159–172,1991.
S. Mac Lane.Categories for the Working Mathematician vol.5 of Graduate Texts in Mathematics 2nd ed.Springer-Verlag, 1998.
T. Uustalu and V. Vene.A cube of proof systems for the intuitionistic predicate μ-,ν-logic.In M. Haveraaen and O. Owe,eds.,Selected Papers from the 8th Nordic Wksh. on Programming Theory, NWPT’ 96 Res.Rep. 248,Dept.of Informatics, Univ.of Oslo,pp.237–246,1997.
T. Uustalu and V. Vene.Coding recursion à la Mendler (extended abstract).In J. Jeuring,ed.,Proc. of 2nd Wksh. on Generic Programming, WGP 2000 Tech. Rep.UU-CS-2000-19,Dept.of Comput.Sci.,Utrecht Univ.,pp.69–85.2000.
T. Uustalu and V. Vene.The dual of substitution is redecoration.In K. Hammond and S. Curtis,eds.,Trends in Funct. Programming 3 pp.99–110.Intellect,2002.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2003 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Abel, A., Matthes, R., Uustalu, T. (2003). Generalized Iteration and Coiteration for Higher-Order Nested Datatypes. In: Gordon, A.D. (eds) Foundations of Software Science and Computation Structures. FoSSaCS 2003. Lecture Notes in Computer Science, vol 2620. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-36576-1_4
Download citation
DOI: https://doi.org/10.1007/3-540-36576-1_4
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-00897-2
Online ISBN: 978-3-540-36576-1
eBook Packages: Springer Book Archive