mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
Merge pull request #3589 from rtfeldman/can-abilities3
Canonicalize syntactic abilities: Part 3 - solving
This commit is contained in:
commit
6b6f240acb
21 changed files with 594 additions and 274 deletions
|
@ -47,7 +47,8 @@ const SYMBOL_HAS_NICHE: () =
|
|||
#[cfg(debug_assertions)]
|
||||
const PRETTY_PRINT_DEBUG_SYMBOLS: bool = true;
|
||||
|
||||
pub const BUILTIN_ABILITIES: &[Symbol] = &[Symbol::ENCODE_ENCODING];
|
||||
pub const DERIVABLE_ABILITIES: &[(Symbol, &[Symbol])] =
|
||||
&[(Symbol::ENCODE_ENCODING, &[Symbol::ENCODE_TO_ENCODER])];
|
||||
|
||||
/// In Debug builds only, Symbol has a name() method that lets
|
||||
/// you look up its name in a global intern table. This table is
|
||||
|
@ -86,8 +87,12 @@ impl Symbol {
|
|||
self.module_id().is_builtin()
|
||||
}
|
||||
|
||||
pub fn is_builtin_ability(self) -> bool {
|
||||
BUILTIN_ABILITIES.contains(&self)
|
||||
pub fn is_derivable_ability(self) -> bool {
|
||||
self.derivable_ability().is_some()
|
||||
}
|
||||
|
||||
pub fn derivable_ability(self) -> Option<&'static (Symbol, &'static [Symbol])> {
|
||||
DERIVABLE_ABILITIES.iter().find(|(name, _)| *name == self)
|
||||
}
|
||||
|
||||
pub fn module_string<'a>(&self, interns: &'a Interns) -> &'a ModuleName {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue