AoC todos and tweaks

This commit is contained in:
2025-12-13 14:51:26 -08:00
parent c938a2e3cd
commit fe3e25f009
8 changed files with 33 additions and 4 deletions

View File

@@ -4,3 +4,5 @@ end_of_line = lf
insert_final_newline = true
indent_size = 2
indent_style = space
[Makefile]
indent_style = tab

14
TODO.md
View File

@@ -1,6 +1,19 @@
## TODO
- [ ] Show Either
- [ ] `local` for `where`-like `let` clauses? (I want a `where` that closes over more stuff)
- [ ] Erasure checking happens at compile time and isn't surfaced to editor..
- [ ] Add Foldable?
- [ ] "Failed to unify %var0 and %var1" - get names in there
- Need fancier `Env`
- [ ] add missing cases should skip indented lines
- [ ] add missing cases should handle `_::_`
- [ ] "Not in scope" should offer to import
- [ ] Dependent records (I guess I missed that bit)
- [ ] Arguments on records
- [ ] Add sugar for type aliases (maybe infer arguments)
- [ ] see if we can get a better error on `for` instead of `for_` in do blocks
- [ ] Maybe make the editor json more compact
- [ ] Remove erased args from primitive functions
- But we need separate `+` functions rather than the magic `∀ a. a -> a -> a` to support other backends
@@ -28,6 +41,7 @@
- [ ] Look into using holes for errors (https://types.pl/@AndrasKovacs/115401455046442009)
- This would let us hit more cases in a function when we hit an error.
- I've been wanting to try holes for parse errors too.
- [ ] Missing `∀ k` in type is error -> no declaration for, if we insert a hole, we can get the declaration.
- [ ] in-scope type at point in vscode
- 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.)
- This information _could_ support renaming, too (but there may be indentation issues).

View File

@@ -29,6 +29,8 @@ export const ABBREV: Record<string, string> = {
"\\Gs": "σ",
"\\Gt": "τ",
"\\GD": "Δ",
"\\GS": "Σ",
"\\GP": "∏",
"\\[[": "⟦",
"\\]]": "⟧",
};

View File

@@ -3,6 +3,10 @@
"name": "newt",
"scopeName": "source.newt",
"patterns": [
{
"name": "invalid.illegal.trace",
"match": "\\b(trace|fatalError)\\b"
},
{
"name": "comment.block.newt",
"begin": "/-",

View File

@@ -526,6 +526,7 @@ unify env mode t u = do
unifyVar : Val -> Val -> M UnifyResult
unifyVar t'@(VVar fc k sp) u'@(VVar fc' k' sp') =
if k == k' then unifySpine env mode (k == k') sp sp'
-- FIXME - get some names in here.
else error fc "Failed to unify \{show t'} and \{show u'}"
unifyVar t'@(VVar fc k Lin) u = do

View File

@@ -44,8 +44,10 @@ eraseSpine env t ((fc, arg) :: args) _ = do
eraseSpine env (App fc t u) args Nothing
doAlt : EEnv -> CaseAlt -> M CaseAlt
-- REVIEW do we extend env?
-- REVIEW we're sticking Erased on RHS for impossible, might want a runtime error or elide the case.
doAlt env (CaseDefault (Erased fc)) = pure $ CaseDefault (Erased fc)
doAlt env (CaseDefault t) = CaseDefault <$> erase env t Nil
doAlt env (CaseCons name args (Erased fc)) = pure (CaseCons name args (Erased fc))
doAlt env (CaseCons name args t) = do
top <- getTop
let (Just (MkEntry _ str type def _)) = lookup name top

View File

@@ -56,6 +56,7 @@ quoteTokenise ts@(TS el ec toks chars) startl startc acc = case chars of
-- TODO newline in string should be an error
'\n' :: cs => Left $ E (MkFC "" (MkBounds el ec el ec)) "Newline in string"
'\\' :: 'n' :: cs => quoteTokenise (TS el (ec + 2) toks cs) startl startc (acc :< '\n')
'\\' :: 't' :: cs => quoteTokenise (TS el (ec + 2) toks cs) startl startc (acc :< chr 9)
'\\' :: c :: cs => quoteTokenise (TS el (ec + 2) toks cs) startl startc (acc :< c)
c :: cs => quoteTokenise (TS el (ec + 1) toks cs) startl startc (acc :< c)
Nil => Left $ E (MkFC "" (MkBounds el ec el ec)) "Expected '\"' at EOF"
@@ -103,7 +104,10 @@ rawTokenise ts@(TS sl sc toks chars) = case chars of
'_' :: ',' :: '_' :: cs => rawTokenise (TS sl (sc + 3) (toks :< mktok False sl (sc + 3) MixFix "_,_") cs)
'_' :: '.' :: '_' :: cs => rawTokenise (TS sl (sc + 3) (toks :< mktok False sl (sc + 3) MixFix "_._") cs)
'\'' :: '\\' :: c :: '\'' :: cs =>
let ch = ite (c == 'n') '\n' c
let ch = case c of
'n' => '\n'
't' => chr 9
c => c
in rawTokenise (TS sl (sc + 4) (toks :< mktok False sl (sc + 4) Character (singleton ch)) cs)
'\'' :: c :: '\'' :: cs => rawTokenise (TS sl (sc + 3) (toks :< mktok False sl (sc + 3) Character (singleton c)) cs)
'#' :: cs => doRest (TS sl (sc + 1) toks cs) Pragma isIdent (Lin :< '#')

View File

@@ -787,7 +787,7 @@ instance Cast Int Nat where
cast n = intToNat n
instance Show Char where
show c = jsShow c
show c = "'\{jsShow c}'"
swap : a b. a × b b × a
swap (a,b) = (b,a)
@@ -885,7 +885,7 @@ ignore = map (const MkUnit)
instance a. {{Show a}} Show (Maybe a) where
show Nothing = "Nothing"
show (Just a) = "Just {show a}"
show (Just a) = "Just \{show a}"
pfunc isPrefixOf uses (True False): String String Bool := `(pfx, s) => s.startsWith(pfx) ? Prelude_True : Prelude_False`
pfunc isSuffixOf uses (True False): String String Bool := `(pfx, s) => s.endsWith(pfx) ? Prelude_True : Prelude_False`