From 30fb13b39bf4f8067c60491a9a7bb89e2c14a952 Mon Sep 17 00:00:00 2001 From: zihang Date: Wed, 3 Dec 2025 14:26:28 +0800 Subject: [PATCH 1/3] Fix deprecation warnings and improve code quality - Replace @string.View with StringView in types.mbt and utils.mbt - Fix deprecated typealias syntax: use 'type Name = String' instead of 'typealias String as Name' - Fix deprecated fnalias syntax: use 'using @list {cons, empty}' instead of 'fnalias @list.(cons, empty)' - Fix deprecated method syntax: use 'fn Type::method' instead of 'fn method(self : Type)' - Replace deprecated function calls: Int::op_add -> Int::add, Int::op_sub -> Int::sub, etc. - Replace deprecated Eq::op_equal with lambda function for equality check - Replace deprecated or_error with unwrap_or_error - Rename duplicate test 'between' to 'between/spaces' - Suppress fnalias deprecation warnings (code 27) in moon.pkg.json All tests pass (23/23). moon check passes with no errors. Co-authored-by: openhands --- src/ex_lisp_test.mbt | 14 +++--- src/ex_test.mbt | 10 ++-- src/moon.pkg.json | 2 +- src/pkg.generated.mbti | 108 +++++++++++++++++++++++++++++++++++++++++ src/types.mbt | 2 +- src/utils.mbt | 2 +- 6 files changed, 123 insertions(+), 15 deletions(-) create mode 100644 src/pkg.generated.mbti diff --git a/src/ex_lisp_test.mbt b/src/ex_lisp_test.mbt index 8de6790..cc63cad 100644 --- a/src/ex_lisp_test.mbt +++ b/src/ex_lisp_test.mbt @@ -1,5 +1,5 @@ ///| -typealias String as Name +type Name = String ///| enum Raw { @@ -40,7 +40,7 @@ impl Show for Raw with output(self, logger) { } ///| -fnalias @list.(cons, empty) +using @list {cons, empty} ///| impl Show for Tm with output(self, logger) { @@ -112,7 +112,7 @@ test "parse" { } ///| -typealias @list.List[Val] as Env +type Env = @list.List[Val] ///| enum Closure { @@ -206,8 +206,8 @@ fn Raw::to_tm(self : Raw) -> Tm raise { RVar(name) => Ix( ns - .find_index(Eq::op_equal(_, name)) - .or_error(ScopeError(pos, name, ns)), + .find_index(fn(x) { x == name }) + .unwrap_or_error(ScopeError(pos, name, ns)), ) RSrcPos(pos, e) => SrcPos(pos, dfs(e, ns, pos)) } @@ -258,7 +258,7 @@ fn[T : Compare] max(x : T, y : T) -> T { } ///| -fn srcpos_depth(self : Raw) -> Int { +fn Raw::srcpos_depth(self : Raw) -> Int { match self { RLam(_, t) => t.srcpos_depth() RApp(t, u) => max(t.srcpos_depth(), u.srcpos_depth()) @@ -268,7 +268,7 @@ fn srcpos_depth(self : Raw) -> Int { } ///| -fn collect_srcpos(self : Raw) -> Array[SourcePos] { +fn Raw::collect_srcpos(self : Raw) -> Array[SourcePos] { let res = [] fn dfs(self) { match self { diff --git a/src/ex_test.mbt b/src/ex_test.mbt index 668a989..f413587 100644 --- a/src/ex_test.mbt +++ b/src/ex_test.mbt @@ -56,10 +56,10 @@ test "calculator" { pure((acc, x) => acc * 10 + (Char::to_int(x) - '0'.to_int())), ) inspect(integer.run(input), content="123456") - let add = char('+').discard_left(pure(Int::op_add)) - let sub = char('-').discard_left(pure(Int::op_sub)) - let mul = char('*').discard_left(pure(Int::op_mul)) - let div = char('/').discard_left(pure(Int::op_div)) + let add = char('+').discard_left(pure(Int::add)) + let sub = char('-').discard_left(pure(Int::sub)) + let mul = char('*').discard_left(pure(Int::mul)) + let div = char('/').discard_left(pure(Int::div)) letrec expr = fn(input) -> (Int, Input) raise ParseError { foldl1(term, add | sub)(input) } @@ -214,7 +214,7 @@ test "pure" { } ///| -test "between" { +test "between/spaces" { let x = pure(0).round_bracket() inspect(x.run(input("()")), content="0") inspect(x.run(input(" ()")), content="0") diff --git a/src/moon.pkg.json b/src/moon.pkg.json index 2f58fac..e33f284 100644 --- a/src/moon.pkg.json +++ b/src/moon.pkg.json @@ -1,3 +1,3 @@ { - "warn-list": "-1-2-3-5-6-7-8-9-10-29" + "warn-list": "-1-2-3-5-6-7-8-9-10-27-29" } diff --git a/src/pkg.generated.mbti b/src/pkg.generated.mbti new file mode 100644 index 0000000..0eda7f6 --- /dev/null +++ b/src/pkg.generated.mbti @@ -0,0 +1,108 @@ +// Generated using `moon info`, DON'T EDIT IT +package "illusory0x0/simple_parserc" + +import( + "moonbitlang/core/list" +) + +// Values +pub let alphabetic : Parser[Char] + +pub let any : Parser[Char] + +pub let digit : Parser[Char] + +pub let space : Parser[Char] + +pub let space1 : Parser[Char] + +pub let spaces : Parser[Char] + +// Errors +pub(all) suberror ParseError { + ParseError(SourcePos, @list.List[String]) +} +pub fn ParseError::cons(Self, String) -> Self +pub fn ParseError::expect(row~ : Int, col~ : Int, String) -> Self +fnalias ParseError::expect +pub fn ParseError::source_pos(Self) -> SourcePos +pub impl Show for ParseError + +// Types and methods +pub(all) struct Input { + chars : StringView + row : Int + col : Int +} +pub fn Input::new(StringView) -> Self +pub impl Show for Input + +pub(all) struct Parser[A]((Input) -> (A, Input) raise ParseError) +pub fn[A, B, C] Parser::between(Self[A], open~ : Self[B], close~ : Self[C]) -> Self[A] +fnalias Parser::between +pub fn[A, B] Parser::bind(Self[A], (A) -> Self[B]) -> Self[B] +fnalias Parser::bind +pub fn Parser::char(Char) -> Self[Char] +fnalias Parser::char +pub fn[A] Parser::curly_bracket(Self[A]) -> Self[A] +fnalias Parser::curly_bracket +pub fn[A, B] Parser::discard_left(Self[A], Self[B]) -> Self[B] +fnalias Parser::discard_left +pub fn[A, B] Parser::discard_right(Self[A], Self[B]) -> Self[A] +fnalias Parser::discard_right +pub fn[A] Parser::discard_spaces(Self[A]) -> Self[A] +fnalias Parser::discard_spaces +pub fn[A] Parser::eof(A) -> Self[A] +fnalias Parser::eof +pub fn[A, B] Parser::foldl(Self[A], Self[B], Self[(B, A) -> B]) -> Self[B] +fnalias Parser::foldl +pub fn[A] Parser::foldl1(Self[A], Self[(A, A) -> A]) -> Self[A] +fnalias Parser::foldl1 +pub fn[A, B] Parser::foldr(Self[A], Self[B], Self[(B, A) -> B]) -> Self[B] +fnalias Parser::foldr +pub fn[A] Parser::foldr1(Self[A], Self[(A, A) -> A]) -> Self[A] +fnalias Parser::foldr1 +#deprecated +pub fn[A] Parser::inner(Self[A]) -> (Input) -> (A, Input) raise ParseError +pub fn[A] Parser::label(Self[A], String) -> Self[A] +fnalias Parser::label +pub fn[A] Parser::many(Self[A]) -> Self[Array[A]] +fnalias Parser::many +pub fn[A] Parser::many_each(Self[A], (A) -> Unit) -> Self[Unit] +fnalias Parser::many_each +pub fn[A, B] Parser::map(Self[A], (A) -> B) -> Self[B] +fnalias Parser::map +pub fn[A, B] Parser::map_srcpos(Self[A], (SourcePos, A) -> B) -> Self[B] +fnalias Parser::map_srcpos +pub fn Parser::none_of(String) -> Self[Char] +fnalias Parser::none_of +pub fn Parser::one_of(String) -> Self[Char] +fnalias Parser::one_of +pub fn[A] Parser::or(Self[A], Self[A]) -> Self[A] +fnalias Parser::or +pub fn[A] Parser::pure(A) -> Self[A] +fnalias Parser::pure +pub fn[A] Parser::round_bracket(Self[A]) -> Self[A] +fnalias Parser::round_bracket +pub fn[A] Parser::run(Self[A], Input) -> A raise ParseError +fnalias Parser::run +pub fn Parser::satisfy((Char) -> Bool, label~ : String) -> Self[Char] +fnalias Parser::satisfy +pub fn[A] Parser::square_bracket(Self[A]) -> Self[A] +fnalias Parser::square_bracket +pub fn Parser::string(String) -> Self[String] +fnalias Parser::string +pub impl[A] BitOr for Parser[A] + +pub(all) struct SourcePos { + row : Int + col : Int +} +pub impl Compare for SourcePos +pub impl Eq for SourcePos +pub impl Show for SourcePos + +// Type aliases + +// Traits + diff --git a/src/types.mbt b/src/types.mbt index 3c6d2c9..cb6801f 100644 --- a/src/types.mbt +++ b/src/types.mbt @@ -6,7 +6,7 @@ pub(all) struct SourcePos { ///| pub(all) struct Input { - chars : @string.View + chars : StringView row : Int col : Int } derive(Show) diff --git a/src/utils.mbt b/src/utils.mbt index baaae96..586d095 100644 --- a/src/utils.mbt +++ b/src/utils.mbt @@ -1,5 +1,5 @@ ///| -pub fn Input::new(chars : @string.View) -> Input { +pub fn Input::new(chars : StringView) -> Input { Input::{ chars, row: 0, col: 0 } } From e19baacb24cdb4368a4b220bc186fb22d45c0555 Mon Sep 17 00:00:00 2001 From: zihang Date: Fri, 5 Dec 2025 15:22:10 +0800 Subject: [PATCH 2/3] Fix all warnings by replacing deprecated fnalias syntax with #as_free_fn attribute - Replace deprecated fnalias syntax with #as_free_fn attribute on method declarations - Remove unused SrcPos constructor from Tm enum (warning 0007) - Remove unused variable assignment in test (warning 0002) - Remove unused functions srcpos_depth and collect_srcpos (warning 0001) - Replace fnalias Input::new as input with regular function definition - Remove warn-list from moon.pkg.json to properly fix warnings instead of suppressing them All tests pass (23/23). moon check passes with no warnings or errors. Co-authored-by: openhands --- src/between.mbt | 4 +++ src/combinator.mbt | 1 + src/consumer.mbt | 6 +++++ src/ex_lisp_test.mbt | 47 +----------------------------------- src/ex_test.mbt | 4 ++- src/fold.mbt | 6 +++++ src/monadic.mbt | 6 +++++ src/moon.pkg.json | 1 - src/pkg.generated.mbti | 55 +++++++++++++++++++++--------------------- src/utils.mbt | 38 ++++------------------------- 10 files changed, 60 insertions(+), 108 deletions(-) diff --git a/src/between.mbt b/src/between.mbt index 5657864..24bb5ae 100644 --- a/src/between.mbt +++ b/src/between.mbt @@ -1,4 +1,5 @@ ///| +#as_free_fn pub fn[A, B, C] Parser::between( self : Parser[A], open~ : Parser[B], @@ -12,16 +13,19 @@ pub fn[A, B, C] Parser::between( } ///| +#as_free_fn pub fn[A] Parser::round_bracket(self : Parser[A]) -> Parser[A] { self.between(open=char('('), close=char(')')) } ///| +#as_free_fn pub fn[A] Parser::square_bracket(self : Parser[A]) -> Parser[A] { self.between(open=char('['), close=char(']')) } ///| +#as_free_fn pub fn[A] Parser::curly_bracket(self : Parser[A]) -> Parser[A] { self.between(open=char('{'), close=char('}')) } diff --git a/src/combinator.mbt b/src/combinator.mbt index d8d448b..f24ab63 100644 --- a/src/combinator.mbt +++ b/src/combinator.mbt @@ -11,6 +11,7 @@ pub impl[A] BitOr for Parser[A] with lor(x, y) { } ///| +#as_free_fn pub fn[A] Parser::label(x : Parser[A], msg : String) -> Parser[A] { fn(input) { x(input) catch { ParseError(_) as e => raise e.cons(msg) } } } diff --git a/src/consumer.mbt b/src/consumer.mbt index a645ec0..26e2bcc 100644 --- a/src/consumer.mbt +++ b/src/consumer.mbt @@ -1,4 +1,5 @@ ///| +#as_free_fn pub fn Parser::satisfy(f : (Char) -> Bool, label~ : String) -> Parser[Char] { fn(input) { let { chars, row, col } = input @@ -15,16 +16,19 @@ pub fn Parser::satisfy(f : (Char) -> Bool, label~ : String) -> Parser[Char] { } ///| +#as_free_fn pub fn Parser::char(ch : Char) -> Parser[Char] { satisfy(c => c == ch, label=ch.to_string()) } ///| +#as_free_fn pub fn Parser::one_of(xs : String) -> Parser[Char] { satisfy(String::contains_char(xs, _), label="one of \{xs.iter()}}") } ///| +#as_free_fn pub fn Parser::none_of(xs : String) -> Parser[Char] { satisfy( ch => not(String::contains_char(xs, ch)), @@ -33,6 +37,7 @@ pub fn Parser::none_of(xs : String) -> Parser[Char] { } ///| +#as_free_fn pub fn Parser::string(str : String) -> Parser[String] { fn(input) { guard not(str.contains_char('\n')) else { panic() } @@ -49,6 +54,7 @@ pub fn Parser::string(str : String) -> Parser[String] { } ///| +#as_free_fn pub fn[A] Parser::eof(x : A) -> Parser[A] { fn(input) { let { chars, row, col } = input diff --git a/src/ex_lisp_test.mbt b/src/ex_lisp_test.mbt index cc63cad..0b22b6b 100644 --- a/src/ex_lisp_test.mbt +++ b/src/ex_lisp_test.mbt @@ -14,7 +14,6 @@ enum Tm { Ix(Int) Lam(Name, Tm) App(Tm, Tm) - SrcPos(SourcePos, Tm) } ///| @@ -64,7 +63,6 @@ impl Show for Tm with output(self, logger) { let name = ns.nth(ix).unwrap() logger.write_string(name) } - SrcPos(_, e) => dfs(e, ns) } } @@ -165,7 +163,6 @@ fn Tm::eval(self : Tm, env : Env) -> Val { } Lam(x, t) => VLam(x, Closure(env, t)) Ix(x) => env.nth(x).unwrap() - SrcPos(_, e) => e.eval(env) } } @@ -209,7 +206,7 @@ fn Raw::to_tm(self : Raw) -> Tm raise { .find_index(fn(x) { x == name }) .unwrap_or_error(ScopeError(pos, name, ns)), ) - RSrcPos(pos, e) => SrcPos(pos, dfs(e, ns, pos)) + RSrcPos(pos, e) => dfs(e, ns, pos) } } @@ -235,7 +232,6 @@ test "chunch" { let five = five.to_tm() let add = add.to_tm() let mul = mul.to_tm() - let succ = succ.to_tm() let ten = App(App(add, five), five).nf(empty()) inspect( ten, @@ -248,47 +244,6 @@ test "chunch" { ) } -///| -fn[T : Compare] max(x : T, y : T) -> T { - if x > y { - x - } else { - y - } -} - -///| -fn Raw::srcpos_depth(self : Raw) -> Int { - match self { - RLam(_, t) => t.srcpos_depth() - RApp(t, u) => max(t.srcpos_depth(), u.srcpos_depth()) - RVar(_) => 0 - RSrcPos(_, e) => 1 + e.srcpos_depth() - } -} - -///| -fn Raw::collect_srcpos(self : Raw) -> Array[SourcePos] { - let res = [] - fn dfs(self) { - match self { - RLam(_, t) => dfs(t) - RApp(t, u) => { - dfs(t) - dfs(u) - } - RVar(_) => () - RSrcPos(pos, e) => { - res.push(pos) - dfs(e) - } - } - } - - dfs(self) - res -} - ///| test "scope error" { let e1 = parser.run(input("(fun x y)")) diff --git a/src/ex_test.mbt b/src/ex_test.mbt index f413587..8a18281 100644 --- a/src/ex_test.mbt +++ b/src/ex_test.mbt @@ -1,5 +1,7 @@ ///| -fnalias Input::new as input +fn input(chars : StringView) -> Input { + Input::new(chars) +} ///| test "foldr/none" { diff --git a/src/fold.mbt b/src/fold.mbt index 0551512..1e034c5 100644 --- a/src/fold.mbt +++ b/src/fold.mbt @@ -1,4 +1,5 @@ ///| +#as_free_fn pub fn[A, B] Parser::foldl( x : Parser[A], z : Parser[B], @@ -17,6 +18,7 @@ pub fn[A, B] Parser::foldl( } ///| +#as_free_fn pub fn[A, B] Parser::foldr( x : Parser[A], z : Parser[B], @@ -40,16 +42,19 @@ pub fn[A, B] Parser::foldr( } ///| +#as_free_fn pub fn[A] Parser::foldr1(x : Parser[A], f : Parser[(A, A) -> A]) -> Parser[A] { foldr(x, x, f) } ///| +#as_free_fn pub fn[A] Parser::foldl1(x : Parser[A], f : Parser[(A, A) -> A]) -> Parser[A] { foldl(x, x, f) } ///| +#as_free_fn pub fn[A] Parser::many_each(x : Parser[A], f : (A) -> Unit) -> Parser[Unit] { fn(input) { let r = x(input) @@ -64,6 +69,7 @@ pub fn[A] Parser::many_each(x : Parser[A], f : (A) -> Unit) -> Parser[Unit] { } ///| +#as_free_fn pub fn[A] Parser::many(self : Parser[A]) -> Parser[Array[A]] { self.foldl( pure([]), diff --git a/src/monadic.mbt b/src/monadic.mbt index 8fb1ba1..0983b59 100644 --- a/src/monadic.mbt +++ b/src/monadic.mbt @@ -1,4 +1,5 @@ ///| +#as_free_fn pub fn[A, B] Parser::bind(x : Parser[A], f : (A) -> Parser[B]) -> Parser[B] { fn(input) { let (v, rest) = x(input) @@ -7,16 +8,19 @@ pub fn[A, B] Parser::bind(x : Parser[A], f : (A) -> Parser[B]) -> Parser[B] { } ///| +#as_free_fn pub fn[A] Parser::pure(x : A) -> Parser[A] { fn(input) { (x, input) } } ///| +#as_free_fn pub fn[A, B] Parser::map(self : Parser[A], f : (A) -> B) -> Parser[B] { self.bind(x => pure(f(x))) } ///| +#as_free_fn pub fn[A, B] Parser::map_srcpos( self : Parser[A], f : (SourcePos, A) -> B, @@ -29,11 +33,13 @@ pub fn[A, B] Parser::map_srcpos( } ///| +#as_free_fn pub fn[A, B] Parser::discard_left(x : Parser[A], y : Parser[B]) -> Parser[B] { x.bind(_ => y) } ///| +#as_free_fn pub fn[A, B] Parser::discard_right(x : Parser[A], y : Parser[B]) -> Parser[A] { x.bind(r => y.bind(_ => pure(r))) } diff --git a/src/moon.pkg.json b/src/moon.pkg.json index e33f284..2c63c08 100644 --- a/src/moon.pkg.json +++ b/src/moon.pkg.json @@ -1,3 +1,2 @@ { - "warn-list": "-1-2-3-5-6-7-8-9-10-27-29" } diff --git a/src/pkg.generated.mbti b/src/pkg.generated.mbti index 0eda7f6..c729458 100644 --- a/src/pkg.generated.mbti +++ b/src/pkg.generated.mbti @@ -23,8 +23,8 @@ pub(all) suberror ParseError { ParseError(SourcePos, @list.List[String]) } pub fn ParseError::cons(Self, String) -> Self +#as_free_fn pub fn ParseError::expect(row~ : Int, col~ : Int, String) -> Self -fnalias ParseError::expect pub fn ParseError::source_pos(Self) -> SourcePos pub impl Show for ParseError @@ -34,64 +34,65 @@ pub(all) struct Input { row : Int col : Int } +#as_free_fn pub fn Input::new(StringView) -> Self pub impl Show for Input pub(all) struct Parser[A]((Input) -> (A, Input) raise ParseError) +#as_free_fn pub fn[A, B, C] Parser::between(Self[A], open~ : Self[B], close~ : Self[C]) -> Self[A] -fnalias Parser::between +#as_free_fn pub fn[A, B] Parser::bind(Self[A], (A) -> Self[B]) -> Self[B] -fnalias Parser::bind +#as_free_fn pub fn Parser::char(Char) -> Self[Char] -fnalias Parser::char +#as_free_fn pub fn[A] Parser::curly_bracket(Self[A]) -> Self[A] -fnalias Parser::curly_bracket +#as_free_fn pub fn[A, B] Parser::discard_left(Self[A], Self[B]) -> Self[B] -fnalias Parser::discard_left +#as_free_fn pub fn[A, B] Parser::discard_right(Self[A], Self[B]) -> Self[A] -fnalias Parser::discard_right +#as_free_fn pub fn[A] Parser::discard_spaces(Self[A]) -> Self[A] -fnalias Parser::discard_spaces +#as_free_fn pub fn[A] Parser::eof(A) -> Self[A] -fnalias Parser::eof +#as_free_fn pub fn[A, B] Parser::foldl(Self[A], Self[B], Self[(B, A) -> B]) -> Self[B] -fnalias Parser::foldl +#as_free_fn pub fn[A] Parser::foldl1(Self[A], Self[(A, A) -> A]) -> Self[A] -fnalias Parser::foldl1 +#as_free_fn pub fn[A, B] Parser::foldr(Self[A], Self[B], Self[(B, A) -> B]) -> Self[B] -fnalias Parser::foldr +#as_free_fn pub fn[A] Parser::foldr1(Self[A], Self[(A, A) -> A]) -> Self[A] -fnalias Parser::foldr1 #deprecated pub fn[A] Parser::inner(Self[A]) -> (Input) -> (A, Input) raise ParseError +#as_free_fn pub fn[A] Parser::label(Self[A], String) -> Self[A] -fnalias Parser::label +#as_free_fn pub fn[A] Parser::many(Self[A]) -> Self[Array[A]] -fnalias Parser::many +#as_free_fn pub fn[A] Parser::many_each(Self[A], (A) -> Unit) -> Self[Unit] -fnalias Parser::many_each +#as_free_fn pub fn[A, B] Parser::map(Self[A], (A) -> B) -> Self[B] -fnalias Parser::map +#as_free_fn pub fn[A, B] Parser::map_srcpos(Self[A], (SourcePos, A) -> B) -> Self[B] -fnalias Parser::map_srcpos +#as_free_fn pub fn Parser::none_of(String) -> Self[Char] -fnalias Parser::none_of +#as_free_fn pub fn Parser::one_of(String) -> Self[Char] -fnalias Parser::one_of +#as_free_fn pub fn[A] Parser::or(Self[A], Self[A]) -> Self[A] -fnalias Parser::or +#as_free_fn pub fn[A] Parser::pure(A) -> Self[A] -fnalias Parser::pure +#as_free_fn pub fn[A] Parser::round_bracket(Self[A]) -> Self[A] -fnalias Parser::round_bracket +#as_free_fn pub fn[A] Parser::run(Self[A], Input) -> A raise ParseError -fnalias Parser::run +#as_free_fn pub fn Parser::satisfy((Char) -> Bool, label~ : String) -> Self[Char] -fnalias Parser::satisfy +#as_free_fn pub fn[A] Parser::square_bracket(Self[A]) -> Self[A] -fnalias Parser::square_bracket +#as_free_fn pub fn Parser::string(String) -> Self[String] -fnalias Parser::string pub impl[A] BitOr for Parser[A] pub(all) struct SourcePos { diff --git a/src/utils.mbt b/src/utils.mbt index 586d095..4d4ca71 100644 --- a/src/utils.mbt +++ b/src/utils.mbt @@ -1,54 +1,29 @@ ///| +#as_free_fn pub fn Input::new(chars : StringView) -> Input { Input::{ chars, row: 0, col: 0 } } ///| +#as_free_fn pub fn[A] Parser::run(self : Parser[A], input : Input) -> A raise ParseError { self(input).0 } ///| +#as_free_fn pub fn[A] Parser::discard_spaces(self : Parser[A]) -> Parser[A] { spaces.discard_left(self) } ///| -pub fnalias Parser::( - between, - bind, - char, - discard_left, - discard_right, - eof, - label, - map, - none_of, - one_of, - round_bracket, - square_bracket, - curly_bracket, - pure, - run, - satisfy, - string, - foldl, - foldr, - foldl1, - foldr1, - discard_spaces, - many, - many_each, - map_srcpos, - or -) - -///| +#as_free_fn pub fn[A] Parser::or(x : Parser[A], y : Parser[A]) -> Parser[A] { x | y } ///| +#as_free_fn pub fn ParseError::expect(row~ : Int, col~ : Int, msg : String) -> ParseError { ParseError({ row, col }, @list.List::singleton(msg)) } @@ -65,6 +40,3 @@ pub fn ParseError::cons(self : ParseError, x : String) -> ParseError { let ParseError(pos, xs) = self ParseError(pos, @list.List::cons(x, xs)) } - -///| -pub fnalias ParseError::expect From d89484343bf7994bbf69d0e0ce5014fe7052cf35 Mon Sep 17 00:00:00 2001 From: zihang Date: Tue, 9 Dec 2025 15:29:11 +0800 Subject: [PATCH 3/3] fix: fmt --- src/moon.pkg.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/moon.pkg.json b/src/moon.pkg.json index 2c63c08..0967ef4 100644 --- a/src/moon.pkg.json +++ b/src/moon.pkg.json @@ -1,2 +1 @@ -{ -} +{}