Newt - a dependent typed programming language

todo list updates

+25 -22
+25 -22
TODO.md
··· 3 3 4 4 - [ ] Use looping for TCO 5 5 - For single functions at least - I think this would be a performance win. I've learned that the slowness on `bun` goes away if I drop the TCO transform. 6 + - Doing this manually for `lookupT23` got 3% speedup. 6 7 - [ ] Importing Prelude twice should be an error (currently it causes double hints and breaks auto) 7 - - [ ] For errors in other files, point to the import 8 + - [x] For errors in other files, point to the import 8 9 - [x] Unsolved metas should be errors (user metas are fine) 9 10 - [x] Better syntax for forward declared data (so we can distinguish from functions) 10 11 - [ ] maybe allow "Main" module name for any file ··· 14 15 - [x] Case split for LSP mode 15 16 - [x] Require lowercase pattern variables 16 17 - I accidentally misspell a constructor and end up with a wildcard. 17 - - [ ] Leverage LSP code for web playground 18 + - [x] Leverage LSP code for web playground 18 19 - [ ] Improve handling of names: 19 20 - We need FC on names in a lot of places 20 21 - [x] FC for duplicate `data`, `record`, `class` name is wrong (points to `data`) ··· 46 47 - Or the name on the VVar? 47 48 - Also we should render %pi, etc more readably (bonus points for _×_) 48 49 - Editor support: 49 - - [ ] add missing cases should skip indented lines 50 - - [ ] add missing cases should handle `_::_` 51 - - [ ] add missing cases should share code between vscode and playground 50 + - [x] add missing cases should skip indented lines 51 + - [x] add missing cases should handle `_::_` 52 + - [x] add missing cases should share code between vscode and playground 52 53 - [x] "Not in scope" should offer to import 53 - - [ ] Case split 54 + - [x] Case split 54 55 - [ ] Delay checking 55 56 - We have things like `foldr (\ x acc => case x : ...`, where the lambda doesn't have a good type, so we have to be explicit. If we could defer the checking of that expression until more things are solved, we might not need the annotation (e.g. checking the other arguments). Some `case` statements may have a similar situation. 56 57 - One idea is to throw the checks onto some sort of TODO list and run whatever works. (I think Idris may have a heuristic where it checks arguments backwards in some cases.) 57 58 - [x] Dependent records (I guess I missed that bit) 58 - - [ ] Arguments on records 59 + - [x] Arguments on records 59 60 - [ ] Add sugar for type aliases (maybe infer arguments) 60 61 - Lean has this, we maybe could run infer on the RHS and call it a day? We would need a simple LHS, though. 61 62 - [ ] see if we can get a better error if `for` is used instead of `for_` in do blocks ··· 89 90 - [ ] Look into using holes for errors (https://types.pl/@AndrasKovacs/115401455046442009) 90 91 - This would let us hit more cases in a function when we hit an error. 91 92 - I've been wanting to try holes for parse errors too. 93 + - Does softening up check errors break `auto`? 92 94 - [ ] Missing `∀ k` in type is error -> no declaration for, if we insert a hole, we can get the declaration. 93 95 - [ ] in-scope type at point in vscode 94 96 - So the idea here is that the references will be via FC, we remember the type at declaration and then point the usage back to the declaration (FC -> FC). We could dump all of this. (If we're still doing json.) 95 97 - This information _could_ support renaming, too (but there may be indentation issues). 96 98 - Do we want to (maybe later) keep the scope as a FC? We could do scope at point then. 97 - - But ideally we'd switch to a server/repl, so we don't have to mess around with serializing stuff. 98 99 - [ ] LSP and/or more editor support 99 100 - [ ] refactor to query based? E.g. importing a module 100 - - [ ] would be nice to have "add missing cases" and "case split" 101 + - [x] would be nice to have "add missing cases" and "case split" 101 102 - [x] Probably need ranges for FC 102 - - [ ] leave an interactive process running 103 + - [x] leave an interactive process running 103 104 - [ ] restart mid file (we could save state per top level decl) 104 105 - [ ] rename in editor (need to accumulate all names and what they reference) 105 106 - [ ] who calls X? We can only do this scoped to the current context for now. Someday whole source dir. #lsp 106 107 - [ ] Pretty print 107 108 - Can we format code? Maybe pull nearby comments or attach them like FC to tokens? 108 109 - We would need to address stack and laziness issues in prettier printer (or make it merely pretty) 109 - - [ ] Look into descriptions, etc. 110 - - Can generating descriptions help with automatic "show" implementations 111 - - We lost debug printing when switching to numeric tags 112 - - Where did I see the idea of generating descriptions for inductive types? 113 110 - [ ] Add info to Ref/VRef (is dcon, arity, etc) 114 111 - To save lookups during compilation and it might make eval faster 115 112 - [x] number tags for data constructors ··· 123 120 - [ ] Maybe add qualified names to surface syntax and allow / detect conflicts on reference 124 121 - [ ] Add `export` keywords 125 122 - [x] vscode - run newt when switching editors 126 - - [ ] case split 123 + - [x] case split 127 124 - We could fake this up: 128 125 - given a name and a point in the editor 129 126 - walk through the function looking for the binder ··· 131 128 - enumerate valid constructors (and their arity) 132 129 - Repeat the line with each, applied to args 133 130 - For `<-` or `let` we'd want to fudge some `|` lines 131 + - [ ] `let` has issues for multiline split / add missing 132 + - [ ] `derive` has phantom splits in it 134 133 - [x] Support "Add missing cases" 135 134 - This has been hakced together 135 + - LSP version now. 136 136 - We could possibly fake up missing cases, too. Since they're listed and have an FC pointing at the first one 137 137 - [x] inline struct getters during code generation (We'd like `x.h1.h2`) 138 138 - [ ] Better FC for parse errors (both EOF and the ones that show up just after the error) ··· 149 149 - [x] Maybe tag some functions as inline 150 150 - [x] Eq Nat is not tail recursive because of the call to `==` 151 151 - [ ] Eq Nat does things the hard way, can we turn it into `==`? 152 + - We could have a compile time substitution for the function 153 + - Maybe this could reify how we're hard coding functions to js operators 152 154 - [x] use hint table for auto solving. (I think walking the `toList` is a big chunk of performance in `Elab.newt`.) 153 155 - [x] implement string enum (or number, but I'm using strings for tags at the moment) 154 156 - [x] use monaco input method instead of lean's 155 157 - [x] `Def` is shadowed between Types and Syntax (TCon vs DCon), detect this 156 - - [ ] constructor magic for Bool? 158 + - [x] constructor magic for Bool? 157 159 - We'd have to make assumptions about order. 158 160 - we could special case some translations 159 161 - extra code. ··· 161 163 - Two issues 162 164 - I'm rewriting stuff in the context, leaving it in a bad state (forward references). I think I can avoid this. 163 165 - The variables at the end of pattern matching have types with references in the wrong order. I think we can reorder them on dependencies. 164 - - should w 166 + - In some cases Idris stuffs Erased into types. 165 167 - Improve `auto` 166 168 - [ ] Improve cases where the auto isn't solved because of a type error 167 169 - [ ] Handle `Foo Blah`, `Foo a => Bar a` vs `Bar Blah` 168 170 - [ ] Add some optimizations 169 - - [ ] see if we can make the typeclass stuff a little leaner, e.g. inline a projection of a static record. 171 + - [ ] see if we can make the typeclass stuff a little leaner, e.g. inline a projection of a static record. (Maybe done now with the inlining, but verify.) 170 172 - It would be nice if IO looked like imperative JS, but that might be a bit of a stretch. 171 - 172 - 173 173 - [ ] warn on unused imports? 174 174 - Probably have to mark on name lookup, maybe wait until we have query-based 175 175 - [x] redo code to determine base path ··· 185 185 - [x] get port to run 186 186 - [x] something goes terribly wrong with traverse_ and for_ (related to erasure, I think) 187 187 - [x] ~~don't use `take` - it's not stack safe~~ The newt version is stack safe 188 - - [ ] show user hole info even in case of error 188 + - [x] show user hole info even in case of error 189 189 - [x] tokenizer that can be ported to newt 190 190 - [ ] Add default path for library, so we don't need symlinks everywhere and can write tests for the library 191 191 - We need this to work for tests / dev and for installed newt. 192 + - The new `FileSource` mechanism might help here. 192 193 - [x] string interpolation? 193 194 - The tricky part here is the `}` - I need to run the normal tokenizer in a way that treats `}` specially. 194 195 - Idris handles `putStrLn "done \{ show $ add {x=1} 2}"` - it recurses for `{` `}` pairs. Do we want that complexity? ··· 202 203 - [x] record update sugar 203 204 - [x] Change `Ord` to be more like Idris - LT / EQ / GT (and entail equality) 204 205 - [ ] Consider making `<` independent of `Ord`, so we get the `<` oper in the javascript. 206 + - Maybe a "default implementation" deal. 205 207 - [x] Keep a `compare` function on `SortedMap` (like lean) 206 208 - `emptyMap` helper defaults to `compare` from `Ord a` 207 209 - [x] keymap for monaco ··· 258 260 - Probably fixed by trying to solve auto immediately 259 261 - [x] Can't skip an auto. We need `{{_}}` to be auto or have a `%search` syntax. 260 262 - [x] add filenames to FC 261 - - [ ] Add full ranges to FC 263 + - [x] Add full ranges to FC 264 + - [ ] Done, but we need to fix a bunch of FC in the parser 262 265 - [x] maybe use backtick for javascript so we don't highlight strings as JS 263 266 - [x] dead code elimination 264 267 - [x] imported files leak info messages everywhere