···20202121infixr 4 _::_
2222data Vec : U → Nat → U where
2323- Nil : {a} → Vec a Z
2424- _::_ : {a k} → a → Vec a k → Vec a (S k)
2323+ Nil : ∀ a. Vec a Z
2424+ _::_ : ∀ a k. a → Vec a k → Vec a (S k)
25252626infixl 5 _++_
2727-_++_ : {a n m} → Vec a n → Vec a m → Vec a (n + m)
2727+_++_ : ∀ a n m. Vec a n → Vec a m → Vec a (n + m)
2828Nil ++ ys = ys
2929(x :: xs) ++ ys = x :: (xs ++ ys)
30303131-map : {a b n} → (a → b) → Vec a n → Vec b n
3131+map : ∀ a b n. (a → b) → Vec a n → Vec b n
3232map f Nil = Nil
3333map f (x :: xs) = f x :: map f xs
3434···5757 MkUnit : Unit
58585959data Either : U -> U -> U where
6060- Left : {A B} → A → Either A B
6161- Right : {A B} → B → Either A B
6060+ Left : ∀ a b. a → Either a b
6161+ Right : ∀ a b. b → Either a b
62626363infixr 4 _,_
6464data Both : U → U → U where
6565- _,_ : {A B} → A → B → Both A B
6565+ _,_ : ∀ a b. a → b → Both a b
66666767typ : E → U
6868typ Zero = Empty
···8585ex1 : BothBoolBool
8686ex1 = (false, true)
87878888-enumAdd : {a b m n} → Vec a m → Vec b n → Vec (Either a b) (m + n)
8888+enumAdd : ∀ a b m n. Vec a m → Vec b n → Vec (Either a b) (m + n)
8989enumAdd xs ys = map Left xs ++ map Right ys
90909191-- for this I followed the shape of _*_, the lecture was slightly different
9292-enumMul : {a b m n} → Vec a m → Vec b n → Vec (Both a b) (m * n)
9292+enumMul : ∀ a b m n. Vec a m → Vec b n → Vec (Both a b) (m * n)
9393enumMul Nil ys = Nil
9494enumMul (x :: xs) ys = map (_,_ x) ys ++ enumMul xs ys
9595···111111-- for now, I'll define ≡ to check
112112113113infixl 2 _≡_
114114-data _≡_ : {A} → A → A → U where
115115- Refl : {A} {a : A} → a ≡ a
114114+data _≡_ : ∀ a. a → a → U where
115115+ Refl : ∀ a. {x : a} → x ≡ x
116116117117test2' : test2 ≡ false :: true :: Nil
118118test2' = Refl
+1-1
playground/samples/Lists.newt
···8787-- same thing, but using `replace` in the proof
8888reverse-++-distrib' : ∀ A. (xs ys : List A) -> reverse (xs ++ ys) ≡ reverse ys ++ reverse xs
8989reverse-++-distrib' Nil ys = sym (++-identity (reverse ys))
9090-reverse-++-distrib' {A} (x :: xs) ys =
9090+reverse-++-distrib' {a} (x :: xs) ys =
9191 replace (\ z => (reverse (xs ++ ys) ++ (x :: Nil)) ≡ z)
9292 (sym (++-associative (reverse ys) (reverse xs) (x :: Nil)))
9393 (replace (\ z => (reverse (xs ++ ys)) ++ (x :: Nil) ≡ z ++ (x :: Nil)) (reverse-++-distrib' xs ys) Refl)
+8-9
playground/samples/Tree.newt
···33-- adapted from Conor McBride's 2-3 tree example
44-- youtube video: https://youtu.be/v2yXrOkzt5w?t=3013
5566-76data Nat : U where
87 Z : Nat
98 S : Nat -> Nat
···1615infixl 4 _+_
17161817data _+_ : U -> U -> U where
1919- inl : {A B} -> A -> A + B
2020- inr : {A B} -> B -> A + B
1818+ inl : ∀ a b. a -> a + b
1919+ inr : ∀ a b. b -> a + b
21202221infix 4 _<=_
2322···4746_ <<= _ = Void
48474948data Intv : Bnd -> Bnd -> U where
5050- intv : {l u} (x : Nat) (lx : l <<= N x) (xu : N x <<= u) -> Intv l u
4949+ intv : ∀ l u. (x : Nat) (lx : l <<= N x) (xu : N x <<= u) -> Intv l u
51505251data T23 : Bnd -> Bnd -> Nat -> U where
5353- leaf : {l u} (lu : l <<= u) -> T23 l u Z
5454- node2 : {l u h} (x : _)
5252+ leaf : ∀ l u. (lu : l <<= u) -> T23 l u Z
5353+ node2 : ∀ l u h. (x : _)
5554 (tlx : T23 l (N x) h) (txu : T23 (N x) u h) ->
5655 T23 l u (S h)
5757- node3 : {l u h} (x y : _)
5656+ node3 : ∀ l u h. (x y : _)
5857 (tlx : T23 l (N x) h) (txy : T23 (N x) (N y) h) (tyu : T23 (N y) u h) ->
5958 T23 l u (S h)
6059···6665 _,_ : {A : U} {B : A -> U} -> (a : A) -> B a -> Sg A B
67666867_*_ : U -> U -> U
6969-A * B = Sg A (\ _ => B)
6868+a * b = Sg a (\ _ => b)
70697170TooBig : Bnd -> Bnd -> Nat -> U
7271TooBig l u h = Sg Nat (\ x => T23 l (N x) h * T23 (N x) u h)
73727474-insert : {l u h} -> Intv l u -> T23 l u h -> TooBig l u h + T23 l u h
7373+insert : ∀ l u h. Intv l u -> T23 l u h -> TooBig l u h + T23 l u h
7574insert (intv x lx xu) (leaf lu) = inl (x , (leaf lx , leaf xu))
7675insert (intv x lx xu) (node2 y tly tyu) = case cmp x y of
7776 -- u := N y is not solved at this time
+2-2
playground/samples/TypeClass.newt
···55 pure : ∀ a. a → m a
6677infixl 1 _>>=_ _>>_
88-_>>=_ : {0 m} {{Monad m}} {0 a b} -> (m a) -> (a -> m b) -> m b
88+_>>=_ : ∀ m. {{Monad m}} {0 a b : _} -> (m a) -> (a -> m b) -> m b
99ma >>= amb = bind ma amb
10101111_>>_ : ∀ m a b. {{Monad m}} -> m a -> m b -> m b
···1515 Left : ∀ A B. A -> Either A B
1616 Right : ∀ A B. B -> Either A B
17171818-instance {a} -> Monad (Either a) where
1818+instance ∀ a. Monad (Either a) where
1919 bind (Left a) amb = Left a
2020 bind (Right b) amb = amb b
2121
+1-1
scripts/aoc25
···2525 if ! diff -q tmp/${bn}.out ${fn}.golden; then
2626 echo "Output mismatch for $fn"
2727 failed=$((failed + 1))
2828- if [ $1 = "--fix" ]; then
2828+ if [ "$1" = "--fix" ]; then
2929 cp tmp/${bn}.out ${fn}.golden
3030 fi
3131 fi
+4-3
src/Lib/Parser.newt
···314314caseAlt : Parser RCaseAlt
315315caseAlt = do
316316 pure MkUnit
317317- pat <- typeExpr
317317+ pat <- term
318318 t <- optional (keyword "=>" >> term)
319319 pure $ MkAlt pat t
320320···364364 keyword "="
365365 sc <- typeExpr
366366 alts <- startBlock $ manySame $ symbol "|" *> caseAlt
367367+ -- REVIEW why am I collecting the rest here?
367368 bodyFC <- getPos
368369 body <- RDo <$> getPos <*> someSame doStmt
369370 pure $ DoExpr fc (RCase fc sc Nothing (MkAlt pat (Just body) :: alts))
···457458 symbol "{"
458459 quant <- quantity
459460 names <- (some (addPos varname))
460460- ty <- optional (symbol ":" *> typeExpr)
461461+ ty <- symbol ":" *> typeExpr
461462 symbol "}"
462462- pure $ map (makeBind quant ty) names
463463+ pure $ map (makeBind quant (Just ty)) names
463464 where
464465 makeBind : Quant → Maybe Raw → FC × String → BindInfo × Raw
465466 makeBind quant ty (pos, name) = (BI pos name Implicit quant, fromMaybe (RImplicit pos) ty)
+7-4
src/Prelude.newt
···146146 map : ∀ a b. (a → b) → m a → m b
147147148148infixr 4 _<$>_ _<$_
149149-_<$>_ : ∀ f. {{Functor f}} {0 a b} → (a → b) → f a → f b
149149+_<$>_ : ∀ f. {{Functor f}} {0 a b : _} → (a → b) → f a → f b
150150f <$> ma = map f ma
151151152152_<$_ : ∀ f a b. {{Functor f}} → b → f a → f b
···214214215215infixr 2 _<|>_
216216class Alternative (m : U → U) where
217217- _<|>_ : {0 a} → m a → m a → m a
217217+ _<|>_ : ∀ a. m a → m a → m a
218218219219instance Alternative Maybe where
220220 Nothing <|> x = x
···368368369369370370-- This is traverse, but we haven't defined Traversable yet
371371-mapA : ∀ m. {{Applicative m}} {0 a b} → (a → m b) → List a → m (List b)
371371+mapA : ∀ m. {{Applicative m}} {0 a b : _} → (a → m b) → List a → m (List b)
372372mapA f Nil = return Nil
373373mapA f (x :: xs) = return _::_ <*> f x <*> mapA f xs
374374375375376376-mapM : ∀ m. {{Monad m}} {0 a b} → (a → m b) → List a → m (List b)
376376+mapM : ∀ m. {{Monad m}} {0 a b : _} → (a → m b) → List a → m (List b)
377377mapM f Nil = pure Nil
378378mapM f (x :: xs) = do
379379 b <- f x
···433433}
434434`
435435436436+-- FIXME this no longer works with numeric tags
437437+-- we could take the best of both worlds and have a debug flag to add extra information
438438+-- but also we could derive Show...
436439pfunc debugStr uses (natToInt listToArray) : ∀ a. a → String := `(_, obj) => {
437440 const go = (obj) => {
438441 if (obj === null) return "_"
+7-8
tests/Tree.newt
···33-- adapted from Conor McBride's 2-3 tree example
44-- youtube video: https://youtu.be/v2yXrOkzt5w?t=3013
5566-76data Nat : U where
87 Z : Nat
98 S : Nat -> Nat
···1615infixl 4 _+_
17161817data _+_ : U -> U -> U where
1919- inl : {A B} -> A -> A + B
2020- inr : {A B} -> B -> A + B
1818+ inl : ∀ a b. a -> a + b
1919+ inr : ∀ a b. b -> a + b
21202221infix 4 _<=_
2322···4746_ <<= _ = Void
48474948data Intv : Bnd -> Bnd -> U where
5050- intv : {l u} (x : Nat) (lx : l <<= N x) (xu : N x <<= u) -> Intv l u
4949+ intv : ∀ l u. (x : Nat) (lx : l <<= N x) (xu : N x <<= u) -> Intv l u
51505251data T23 : Bnd -> Bnd -> Nat -> U where
5353- leaf : {l u} (lu : l <<= u) -> T23 l u Z
5454- node2 : {l u h} (x : _)
5252+ leaf : ∀ l u. (lu : l <<= u) -> T23 l u Z
5353+ node2 : ∀ l u h. (x : _)
5554 (tlx : T23 l (N x) h) (txu : T23 (N x) u h) ->
5655 T23 l u (S h)
5757- node3 : {l u h} (x y : _)
5656+ node3 : ∀ l u h. (x y : _)
5857 (tlx : T23 l (N x) h) (txy : T23 (N x) (N y) h) (tyu : T23 (N y) u h) ->
5958 T23 l u (S h)
6059···7170TooBig : Bnd -> Bnd -> Nat -> U
7271TooBig l u h = Sg Nat (\ x => T23 l (N x) h * T23 (N x) u h)
73727474-insert : {l u h} -> Intv l u -> T23 l u h -> TooBig l u h + T23 l u h
7373+insert : ∀ l u h. Intv l u -> T23 l u h -> TooBig l u h + T23 l u h
7574insert (intv x lx xu) (leaf lu) = inl (x , (leaf lx , leaf xu))
7675insert (intv x lx xu) (node2 y tly tyu) = case cmp x y of
7776 -- u := N y is not solved at this time