Generalized Iteration and Coiteration for Higher-Order Nested Datatypes

  • Andreas Abel
  • Ralph Matthes
  • Tarmo Uustalu
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 2620)

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ω.

References

  1. 1.
    A. Abel.Termination checking with types.Technical Report 0201,Inst. für Infor-matik,Ludwigs-Maximilians-Univ. München,2002.Google Scholar
  2. 2.
    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.Google Scholar
  3. 3.
    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.Google Scholar
  4. 4.
    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.Google Scholar
  5. 5.
    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.Google Scholar
  6. 6.
    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.Google Scholar
  7. 7.
    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.Google Scholar
  8. 8.
    R. Bird and R. Paterson.Generalised folds for nested datatypes.Formal Aspects of Comput., 11(2):200–222,1999.MATHCrossRefGoogle Scholar
  9. 9.
    R. Bird and R. Paterson.De Bruijn notation as a nested datatype. J. of Funct. Program., 9(1):77–91,1999.MATHCrossRefMathSciNetGoogle Scholar
  10. 10.
    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.Google Scholar
  11. 11.
    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.Google Scholar
  12. 12.
    R. Hinze.Manufacturing datatypes. J. of Funct. Program.11(5):493–524,2001.Google Scholar
  13. 13.
    R. Hinze.Polytypic values possess polykinded types. Sci. of Comput. Program. 43(2–3):129–159, 2002.Google Scholar
  14. 14.
    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.Google Scholar
  15. 15.
    C. Martin, J. Gibbons and I. Bayley.Disciplined,efficient,generalised folds for nested datatypes.Submitted.Google Scholar
  16. 16.
    R. Matthes.Extensions of System F by Iteration and Primitive Recursion on Monotone Inductive Types. PhD thesis,Ludwig-Maximilians-Univ.München,1998.Google Scholar
  17. 17.
    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.Google Scholar
  18. 18.
    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.Google Scholar
  19. 19.
    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.CrossRefMathSciNetMATHGoogle Scholar
  20. 20.
    S. Mac Lane.Categories for the Working Mathematician vol.5 of Graduate Texts in Mathematics 2nd ed.Springer-Verlag, 1998.Google Scholar
  21. 21.
    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.Google Scholar
  22. 22.
    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.Google Scholar
  23. 23.
    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.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2003

Authors and Affiliations

  • Andreas Abel
    • 1
  • Ralph Matthes
    • 2
  • Tarmo Uustalu
    • 3
  1. 1.Department of Computer ScienceUniversity of MunichMunich
  2. 2.Preuves, Programmes et SystèmesCNRS, Université Paris VII (on leave from University of Munich)Munich
  3. 3.Inst.of CyberneticsTallinn Technical UniversityTallinn

Personalised recommendations