Lecture 4 Notes

6 02 5 this type

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: y for a good module system. 27 7.4.1 Type Abbreviations We begin by discussing type abbreviations, or transparent types. Example 10. The program £ 8©  $  '0 % £ © ' £ ¡ % ©£    ¡ © £ &£  ¡ ¡ 1 © $£ " '  ¢ ¡ % £ ¤&1¡ £ © © ¡  § ¨ ¡ 6¢ ¥£¡ ¡ ¡ £ §§¥ £ ¡ 56&£ §¨ 8¡  ¤¢ §£% ¨ ¢ ¡  © £ ©  '£ ¡ ¡   ¢ ¡ % £ © £ ©  has type . Here the declaration in the interface binds to the type in the rest of the interface. The declaration in the module body, on the third line of the program, binds to the type in the rest of the module body. We say that is bound transparently to , or that is a transparent type. £ ©  £ ' £ ¡ % £ © £ 8©  £ ©  £ £ 8©  £ £ Example 11. Of course, we can use any name we like for the type. £ 8©  $  '0 % £ © ' ¥ ¡ % ©£   ¡ © £ &£  ¡ ¡ 1 © $¥ " '¥  ¢ ¡ % £ ¤&1¡ £ © © ¡  § ¨ ¡ 6¢ ¥£¡ ¡ ¡ §§¥ £ ¡ 56&£ §¨ 8¡  ¤¢ §£% ¨ ¢ ¡  © £ ©  has type . And of course we can declare more than one type. The type declarations can appear anywhere in the interface, so long as each declaration precedes all of its uses. 28 £ Example 12. If a module exports a type named , we can refer to that type wherever has been imported by writing . We call this a qualified type. £ ¡ 6&£ 5  38¡  £ ¡ 6&£ 5 is an abbreviation for the meaning £ 8©   38...
View Full Document

Ask a homework question - tutors are online