thinkingAloud 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. Topic: Modules
  2. Topic: Structure of the signature.
  3. * The module system is hierarchical so it seems resonable to
  4. structure the signature accordingly.
  5. * We need to be able to look up a QName in the signature.
  6. * Why does it have to be hierarchical? When do we need to manipulate
  7. an entire subtree?
  8. * A problem is that QNames aren't well thought out yet. Currently a
  9. moduleId is a concrete name. That's not very good.
  10. * Let's make it flat for the time being, that should be a simple
  11. thing to change at a later stage.
  12. * We would also have to think about what happens when modules are
  13. instantiated (module Foo = Bar Nat), but that can also be
  14. postponed.
  15. EndTopic
  16. Topic: Parameterised modules
  17. * Turns out to be a major headache to keep track of free variables.
  18. * We need to structure things nicely.
  19. * Attempt 1: Hierarchical signature.
  20. notes/ModulesAttempt1.hs
  21. Not necessary(?)
  22. * Attempt 2: Flat signature
  23. notes/Modules.hs
  24. EndTopic
  25. Topic: Rewriting for abstract things
  26. * Remark by Andreas during the video talk
  27. Would it be possible to add rewriting rules for definitional
  28. equalities which hold inside a module (where we know the values of
  29. abstract things) when working outside the module?
  30. Example:
  31. module Stack where
  32. abstract
  33. Stack : Set -> Set
  34. Stack = List
  35. push : A -> Stack A -> Stack A
  36. push = cons
  37. pop : Stack A -> Maybe (Stack A)
  38. pop nil = nothing
  39. pop (x::xs) = just xs
  40. rewrite pop (push x s) == just s
  41. The type of the rewrite should be checked without knowing the
  42. definitions and the left-hand-side and the right-hand-side should
  43. be convertible when knowing the definitions.
  44. EndTopic
  45. EndTopic
  46. Topic: Local functions
  47. Topic: Functions as parameterised modules
  48. * Remark by Conor during the video talk
  49. It would be nice to have a parameterised module containing all the local
  50. definitions for each definition. This way you could actually refer to the
  51. local functions by instantiating this module.
  52. f : (x:A) -> (y:B) -> C
  53. f x y = e
  54. where
  55. g : (z:C) -> D
  56. g z = e'
  57. would mean something like
  58. module f (x:A)(y:B) where
  59. g : (z:C) -> D
  60. g z = e'
  61. f : (x:A) -> (y:B) -> C
  62. f x y = e
  63. where
  64. module Local = f x y
  65. open Local
  66. Open problem: How to handle definitions with multiple clauses?
  67. EndTopic
  68. Topic: Lifting
  69. * Remark by Makoto during the video meeting
  70. When lifting local definitions you might not want to abstract over all
  71. variables in the context, but only those which are in scope. Example:
  72. foo x y z = bar y
  73. where
  74. bar true = true
  75. bar false = z
  76. Abstracting over all variables gives the following:
  77. lift_bar x y z true = true
  78. lift_bar x y z false = z
  79. foo x y z --> lift_bar x y z y
  80. foo x' y z --> lift_bar x' y z y
  81. So foo x y z != foo x' y z, even though foo never uses its first
  82. argument. If we instead abstract only over things that are actually used
  83. we get:
  84. lift_bar z true = true
  85. lift_bar z false = z
  86. foo x y z --> lift_bar y z
  87. foo x' y z --> lift_bar y z
  88. EndTopic
  89. EndTopic
  90. Topic: Pattern Matching
  91. Topic: Berry's majority function
  92. * Remark by Conor during the video talk:
  93. We won't be able to satisfy all equations of Berry's majority
  94. function definitionally in the core language, so if we do that in
  95. the full language we are in trouble.
  96. maj T T T = T
  97. maj T F x = x
  98. maj F x T = x
  99. maj x T F = x
  100. maj F F F = F
  101. Possible solution: Match patterns left-to-right, as soon as there
  102. is an inconclusive match the whole matching is inconclusive.
  103. Example:
  104. f T F = F
  105. f _ _ = T
  106. With the standard approach we have
  107. f x T --> T
  108. but instead we say that this doesn't reduce (since x is blocking
  109. the pattern T in the first clause). With this approach order does
  110. matter! Are there any problems? Example:
  111. f x 0 = 1
  112. f 0 (s y) = y
  113. f (s x) (s y) = x
  114. With left to right matching we still have f x 0 --> 1, but the
  115. tranlation will yield(?)
  116. f 0 = \y -> f1 y
  117. f (s x) = \y -> f2 x y
  118. f1 0 = 0
  119. f1 (s y) = y
  120. f2 x 0 = 1
  121. f2 x (s y) = x
  122. That is pattern matching first on the first argument. So f x 0
  123. will not reduce. Hm.
  124. Can we figure out the correct order in which to pattern match?
  125. Maybe. We can decide in which order to pattern match by scanning
  126. the clauses left to right, top to bottom. The first constructor
  127. pattern appears (in the example) in the second argument of the
  128. first clause, so we should start by matching on the second
  129. argument.
  130. EndTopic
  131. EndTopic
  132. Topic: Meta variables
  133. Topic: Meta variable dependencies and hidden application
  134. * Currently meta variable dependencies are represented as
  135. applications. This means that they contain hiding information.
  136. * Is this a problem? It does clutter up some things, but on the
  137. other hand it's possible that a meta variable _is_ applied to an
  138. hidden argument.
  139. EndTopic
  140. Topic: Sort meta variables
  141. * How can we solve them?
  142. * When do we have to?
  143. * One option could be to instantiate all unsolved (unconstrained)
  144. sort metas to Set.
  145. EndTopic
  146. Topic: Dependency juggling
  147. * Juggling parameters is a mess. There is a dire need for a nice
  148. clean API.
  149. EndTopic
  150. Topic: Scope
  151. * Meta variables need to be scope checked (probably) so when
  152. creating a new meta we should have access to scope information.
  153. It'll probably be enough to annotate declarations with scope and
  154. make sure that the type checker updates the current scope when
  155. passing a definition. Not having to bother with lambda bound
  156. things makes it easier.
  157. In any case interaction points need to have their scope. This we
  158. have when type checking (and thus when creating the meta).
  159. EndTopic
  160. Topic: Question mark numbers
  161. * We probably want to separate the numbers on question marks from
  162. those on underscores.
  163. * Possible solution:
  164. - generate question mark numbers during scope checking
  165. - generate MetaIds as before (both underscores and question marks)
  166. - keep a map from question mark numbers to meta ids
  167. - the interface will use question mark numbers
  168. EndTopic
  169. EndTopic
  170. Topic: Implementation details
  171. Topic: Representation
  172. Topic: Unique names in abstract syntax.
  173. * The names of local functions can clash and it's not clear how to
  174. disambiguate them if names are (qualified) strings.
  175. * So unique identifiers (numbers) for names sounds like a good idea.
  176. * Problem: Module system, in particular separate type checking and
  177. interface files. If names are identified by globally unique
  178. numbers we're in trouble.
  179. * Solution: qualified unique numbers. A name is a pair of a module
  180. and a unique number.
  181. * Question: How qualified (top-level modules or also sub-modules)?
  182. * Answer: It feels better to treat top-level modules and sub-modules
  183. the same as far as possible, so each module (including
  184. sub-modules) should have its own set of unique identifiers.
  185. EndTopic
  186. Topic: Module names vs. function names
  187. * Since there is no confusion between module names and function
  188. names (they can never appear in the same place) it makes sense to
  189. have different representations for them. For clarity if nothing
  190. else.
  191. EndTopic
  192. Topic: n-ary application in terms.
  193. * Some things might be simpler with binary application. Check it
  194. out.
  195. EndTopic
  196. EndTopic
  197. Topic: Generics
  198. * How much do we gain by the generics? Is it worth it?
  199. * Maybe there is a more light-weight approach.
  200. EndTopic
  201. Topic: Debugging
  202. * How to make debugging smooth?
  203. * We need different levels of information in print-outs.
  204. EndTopic
  205. Topic: Figuring out what's in Syntax.Internal(New)
  206. * type Args = [Value]
  207. * xxx2str :: xxx -> Reader Int String
  208. Generates fresh names.
  209. * Values can be beta redexes. Why? Maybe it will allow a better
  210. reduction strategy than call-by-name. I'm not sure it matters.
  211. * instance Eq Value. Only variables can be equal. Not very nice.
  212. Make a type wrapper (or define another function).
  213. * addArgs = flip apply (but generically)
  214. * data Sort = ... | Lub Sort Sort -- do we need this?
  215. * data TCErr = Fatal String | PatternErr MId
  216. This is nice. Pattern unification failure might go away if we wait
  217. a bit, PatternErr is used to signal such a failure.
  218. * reduce is parameterised by the stuff that's in the monad. This
  219. will probably make it more efficient than if it had been monadic.
  220. We can do this since it'll never change the state.
  221. EndTopic
  222. Topic: Module structure of the type checker
  223. - Syntax
  224. - Internal
  225. - TypeChecker
  226. - TypeChecking/
  227. - Conversion
  228. - Reduce
  229. - Monad
  230. Where to put subst and adjust? Let's put them in Reduce for the time
  231. being. No, that doesn't quite work. They'll have to go in
  232. Substitute.
  233. EndTopic
  234. EndTopic
  235. Topic: TODO
  236. * Check that meta variables have been solved at appropriate times.
  237. * Keep the type on instantiated interaction meta variables. Also
  238. remember which metas are interaction points and which are go
  239. figures after instantiation.
  240. * Meta variable scope (see Meta variables - Scope).
  241. EndTopic
  242. vim: sts=2 sw=2 tw=70 fdm=marker foldmarker=Topic\:,EndTopic