meeting_050907 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. Modules
  2. -------
  3. $(root)/A/Foo.agda:
  4. module Foo (A:Set)(op:A -> A -> A) where
  5. f : A -> A
  6. f = ..
  7. module Bar (x:A) where
  8. ...
  9. import .Baz -- looks for $(root)/A/Baz.agda
  10. import B.Baz -- looks for $(include_dirs)/B/Baz.agda
  11. Observations:
  12. - You can only import actual files.
  13. - The name of the top level module in a file as to match the file name.
  14. Local ::= ... | open m es [ as x | (xs) | ε ]
  15. D ::= ... | import x.x.x.x [ as x | ε ]
  16. open Foo Nat eq as FooNat (f, g) -- import f and g into the new name
  17. -- space FooNat.
  18. open FooNat (f) -- import f into the current name space
  19. open FooNat -- import everything from FooNat into
  20. -- the current name space
  21. At the moment there is a distinction between modules and name spaces.
  22. Above
  23. Foo Nat eq is a module
  24. FooNat is a name space
  25. You can refer to things using name spaces, as in FooNat.f. You cannot do
  26. this with modules. A name space is a sequence of names separated by dot.
  27. Not allowed:
  28. (Foo Nat eq).f
  29. You can open both name spaces and modules. For each non-parameterised
  30. module there is a name space with the same name.
  31. What does abstract and private mean?
  32. abstract takes a list of definitions:
  33. abstract Stack : Set
  34. Stack = List
  35. empty : Stack
  36. empty = []
  37. ...
  38. Outside the abstract block the definitions are not known (even inside
  39. the same module).
  40. private just means that the user cannot refer to the name outside the
  41. module. You can still compute with private things.
  42. How to translate to core?
  43. We can just forget about private and abstract. For abstract this means
  44. that the core type checker has more information than the full language
  45. checker. This shouldn't be a problem.
  46. Note: make sure that the type of something in an abstract block doesn't
  47. depend on the value of one of the earlier definitions (the type is
  48. exported).
  49. Typing rules
  50. ------------
  51. Γ ⊢ M : Set_i
  52. -------------------
  53. Γ ⊢ El_i M : type^i
  54. Also for prop.
  55. Algorithm
  56. Judgement forms:
  57. Γ ⊢ A s --> V check that A is a type and infer the sort
  58. Γ ⊢ e ↑ V --> v check that e has type V
  59. Γ ⊢ e ↓ V --> v infer the type of e
  60. Rules:
  61. Γ ⊢ M ↓ V --> v v = Sort ?s
  62. ------------------------------
  63. Γ ⊢ M ?s --> El_?s v
  64. Γ ⊢ f ↓ V -> v V = (x : ?A) -> ?B Γ ⊢ e ↑ ?A --> w
  65. ------------------------------------------------------
  66. Γ ⊢ f e ↓ ?B w --> v w
  67. We need sort meta variables: Γ ⊢ ? ? --> ?
  68. data Type = ... | Sort Sort
  69. data Sort = Type Nat | Prop | Meta MId | Lub Sort Sort
  70. So this means that we don't need the Maybe in the metainfo
  71. data MetaInfo = InstantiatedV Value
  72. | InstantiatedT Type
  73. | Underscore [ConstraintId]
  74. | QuestionmarkV Signature Context Type [ConstraintId]
  75. | QuestionmarkT Signature Context Sort [ConstraintId]
  76. Important observation:
  77. We don't have subtyping, only subsorting.
  78. Γ ⊢ e ↓ W --> v W = V
  79. -----------------------
  80. Γ ⊢ e ↑ V --> v
  81. Plan
  82. ----
  83. Things to do/figure out
  84. - Typing rules for the full language
  85. - Translation to Core
  86. - Explanations
  87. - User interactions
  88. - Testing
  89. - Plug-ins
  90. - Documentation
  91. - ( Classes )
  92. This will be done mainly at Chalmers
  93. Things we know how to do
  94. C - concrete and abstract syntax, translation
  95. C - parser, lexer
  96. C - pretty printing
  97. C - infrastructure (Makefile, directories)
  98. J - internal syntax
  99. J - unification and constraints
  100. J - monad and state (partially)
  101. C = Chalmers (Ulf)
  102. J = Japan (Jeff)
  103. Time plan
  104. Sep
  105. Fix signature datatype.
  106. Final version of typing rules.
  107. Finish(ing) infrastructure code ("Things we know how to do").
  108. Oct
  109. Start implementing type checker.
  110. Finish(ing) first version.
  111. Nov
  112. Have a running system.
  113. File organisation
  114. -----------------
  115. src
  116. Syntax
  117. Lexer
  118. Parser
  119. ParseMonad
  120. Position
  121. Concrete
  122. Abstract
  123. Internal
  124. Pretty
  125. ConcreteToAbstract
  126. TypeChecker
  127. Monad
  128. Unification
  129. (MetaVariables, Computation, .. ?)
  130. Testing
  131. ... fine grained testing
  132. Interaction
  133. ... interaction protocol, ...
  134. Plugins
  135. ...
  136. The Haddock trick
  137. -----------------
  138. Haddock doesn't handle circular module dependencies.
  139. Solution: Use a preprocessor before calling Haddock which removes lines
  140. containing REMOVE_IF_HADDOCK.
  141. Example:
  142. import {-# SOURCE #-} Foo (foo) -- REMOVE_IF_HADDOCK
  143. {- REMOVE_IF_HADDOCK
  144. -- | This function is really 'Foo.foo'. It's here to fool Haddock into
  145. -- accept circular module dependencies.
  146. foo :: Int -> Int
  147. REMOVE_IF_HADDOCK -}
  148. Coding conventions
  149. ------------------
  150. - Write typesignatures and haddock comments.
  151. - Never use booleans.
  152. - Datatypes should be abstract and accessed by views.
  153. - Scrap boilerplate locally. That is, define useful combinators using
  154. generics, but export non-generic functions. Another way of saying it:
  155. only use generics in close proximity to the definition of the datatype.
  156. The keeping-abstraction-when-splitting-a-module trick
  157. -----------------------------------------------------
  158. You have:
  159. --- A.hs ---
  160. module A ( Foo -- abstract type
  161. , foo
  162. ) where
  163. data Foo = Foo Int
  164. foo :: Foo -> Int
  165. foo (Foo n) = n
  166. ------------
  167. You want to split this module into two (because it's too big), without
  168. breaking the abstraction of Foo.
  169. Solution: You split the module into three, with the added advantage that
  170. you don't have to change modules importing A.
  171. --- A.hs ---
  172. module A ( Foo, foo ) where
  173. import A.Implementation
  174. import A.Foo
  175. ------------
  176. --- A/Implementation.hs ---
  177. module A.Implementation ( Foo(..) ) where -- exports definition of Foo
  178. data Foo = Foo Int
  179. ---------------------------
  180. --- A/Foo.hs ---
  181. module A.Foo (foo) where
  182. import A.Implementation
  183. foo :: Foo -> Int
  184. foo (Foo n) = n
  185. ----------------
  186. vim: sts=2 sw=2 tw=75