Skip to content

Commit b3c6f7e

Browse files
Merge pull request #12 from moonbit-community/ai-fix-1763625568345
Fix moon check errors and warnings
2 parents 761623c + fdbf39c commit b3c6f7e

3 files changed

Lines changed: 40 additions & 7 deletions

File tree

src/fuzzy_match.mbt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
///| fuzzy match
1+
///|
2+
/// fuzzy match
23
///
34
/// This implementation refers to
45
/// [Ocaml janestreet fuzzy_match](https://github.com/janestreet/fuzzy_match/blob/master/match/src/fuzzy_match.ml)
56
pub fn[Pattern : StringLike, Text : StringLike] is_match(
6-
char_equal~ : (Char, Char) -> Bool = Char::op_equal,
7+
char_equal? : (Char, Char) -> Bool = Char::equal,
78
pattern~ : Pattern,
89
text~ : Text,
910
) -> Bool {

src/pkg.generated.mbti

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Generated using `moon info`, DON'T EDIT IT
2+
package "illusory0x0/fuzzy_match"
3+
4+
// Values
5+
fn[Pattern : StringLike, Text : StringLike] is_match(char_equal? : (Char, Char) -> Bool, pattern~ : Pattern, text~ : Text) -> Bool
6+
7+
fn score_upper_bound(query_length~ : Int) -> Int
8+
9+
// Errors
10+
11+
// Types and methods
12+
type Query
13+
fn[Item : StringLike] Query::matching_indices(Self, item~ : Item) -> Array[Int]?
14+
fn Query::new(String) -> Self
15+
fn[Item : StringLike] Query::score(Self, item~ : Item) -> Int
16+
fn[Item : StringLike + Compare] Query::search(Self, items~ : Array[Item]) -> Array[StringView]
17+
fn[Item : StringLike] Query::split_by_matching_sections(Self, item~ : Item) -> Array[(Bool, StringView)]?
18+
19+
// Type aliases
20+
21+
// Traits
22+
pub(open) trait StringLike {
23+
length(Self) -> Int
24+
op_get(Self, Int) -> Char
25+
is_empty(Self) -> Bool = _
26+
to_string(Self) -> String
27+
view(Self, Int, Int) -> StringView
28+
}
29+
impl StringLike for String
30+
impl StringLike for StringView
31+

src/query.mbt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn Query::new(query : String) -> Query {
2727
}
2828

2929
///|
30-
pub fn[Item : StringLike] split_by_matching_sections(
30+
pub fn[Item : StringLike] Query::split_by_matching_sections(
3131
self : Query,
3232
item~ : Item,
3333
) -> Array[(Bool, @string.View)]? {
@@ -63,11 +63,12 @@ pub fn[Item : StringLike] split_by_matching_sections(
6363
}
6464
}
6565

66-
///| fuzzy_search
66+
///|
67+
/// fuzzy_search
6768
///
6869
/// This implementation refers to
6970
/// [Ocaml janestreet fuzzy_match](https://github.com/janestreet/fuzzy_match/blob/master/search/src/fuzzy_search.ml)
70-
pub fn[Item : StringLike + Compare] search(
71+
pub fn[Item : StringLike + Compare] Query::search(
7172
self : Query,
7273
items~ : Array[Item],
7374
) -> Array[@string.View] {
@@ -85,7 +86,7 @@ pub fn[Item : StringLike + Compare] search(
8586
}
8687

8788
///|
88-
pub fn[Item : StringLike] matching_indices(
89+
pub fn[Item : StringLike] Query::matching_indices(
8990
self : Query,
9091
item~ : Item,
9192
) -> Array[Int]? {
@@ -110,7 +111,7 @@ pub fn[Item : StringLike] matching_indices(
110111
}
111112

112113
///|
113-
pub fn[Item : StringLike] score(self : Query, item~ : Item) -> Int {
114+
pub fn[Item : StringLike] Query::score(self : Query, item~ : Item) -> Int {
114115
match (item.is_empty(), self.is_empty()) {
115116
(true, _) => 0
116117
(_, true) => 1

0 commit comments

Comments
 (0)