mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
Add Task as a built-in module/type
This commit is contained in:
parent
d47a073634
commit
700c7ae9aa
86 changed files with 925 additions and 2670 deletions
|
@ -7,7 +7,7 @@ use crate::ident::{lowercase_ident, UppercaseIdent};
|
|||
use crate::parser::{byte, specialize_err, EPackageEntry, EPackageName, Parser};
|
||||
use crate::parser::{optional, then};
|
||||
use crate::string_literal;
|
||||
use roc_module::symbol::{ModuleId, Symbol};
|
||||
use roc_module::symbol::ModuleId;
|
||||
use roc_region::all::Loc;
|
||||
use std::fmt::Debug;
|
||||
|
||||
|
@ -44,14 +44,11 @@ pub enum HeaderType<'a> {
|
|||
Hosted {
|
||||
name: ModuleName<'a>,
|
||||
exposes: &'a [Loc<ExposedName<'a>>],
|
||||
generates: UppercaseIdent<'a>,
|
||||
generates_with: &'a [Loc<ExposedName<'a>>],
|
||||
},
|
||||
/// Only created during canonicalization, never actually parsed from source
|
||||
Builtin {
|
||||
name: ModuleName<'a>,
|
||||
exposes: &'a [Loc<ExposedName<'a>>],
|
||||
generates_with: &'a [Symbol],
|
||||
},
|
||||
Package {
|
||||
/// usually something other than `pf`
|
||||
|
@ -101,11 +98,9 @@ impl<'a> HeaderType<'a> {
|
|||
|
||||
pub fn to_maybe_builtin(self, module_id: ModuleId) -> Self {
|
||||
match self {
|
||||
HeaderType::Module { name, exposes } if module_id.is_builtin() => HeaderType::Builtin {
|
||||
name,
|
||||
exposes,
|
||||
generates_with: &[],
|
||||
},
|
||||
HeaderType::Module { name, exposes } if module_id.is_builtin() => {
|
||||
HeaderType::Builtin { name, exposes }
|
||||
}
|
||||
_ => self,
|
||||
}
|
||||
}
|
||||
|
@ -222,8 +217,6 @@ macro_rules! keywords {
|
|||
|
||||
keywords! {
|
||||
ExposesKeyword => "exposes",
|
||||
WithKeyword => "with",
|
||||
GeneratesKeyword => "generates",
|
||||
PackageKeyword => "package",
|
||||
PackagesKeyword => "packages",
|
||||
RequiresKeyword => "requires",
|
||||
|
@ -267,10 +260,6 @@ pub struct HostedHeader<'a> {
|
|||
pub exposes: KeywordItem<'a, ExposesKeyword, Collection<'a, Loc<Spaced<'a, ExposedName<'a>>>>>,
|
||||
|
||||
pub imports: KeywordItem<'a, ImportsKeyword, Collection<'a, Loc<Spaced<'a, ImportsEntry<'a>>>>>,
|
||||
|
||||
pub generates: KeywordItem<'a, GeneratesKeyword, UppercaseIdent<'a>>,
|
||||
pub generates_with:
|
||||
KeywordItem<'a, WithKeyword, Collection<'a, Loc<Spaced<'a, ExposedName<'a>>>>>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
|
@ -349,7 +338,7 @@ pub enum ImportsEntry<'a> {
|
|||
|
||||
/// e.g.
|
||||
///
|
||||
/// printLine : Str -> Effect {}
|
||||
/// printLine : Str -> Result {} *
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub struct TypedIdent<'a> {
|
||||
pub ident: Loc<&'a str>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue