mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 08:11:12 +00:00
parse a shortname prefix before Effects
This commit is contained in:
parent
44fd0351be
commit
53afa3c3fc
4 changed files with 12 additions and 1 deletions
|
@ -648,6 +648,7 @@ enum Msg<'a> {
|
||||||
module_docs: Option<ModuleDocumentation>,
|
module_docs: Option<ModuleDocumentation>,
|
||||||
},
|
},
|
||||||
MadeEffectModule {
|
MadeEffectModule {
|
||||||
|
type_shortname: &'a str,
|
||||||
constrained_module: ConstrainedModule,
|
constrained_module: ConstrainedModule,
|
||||||
canonicalization_problems: Vec<roc_problem::can::Problem>,
|
canonicalization_problems: Vec<roc_problem::can::Problem>,
|
||||||
module_docs: ModuleDocumentation,
|
module_docs: ModuleDocumentation,
|
||||||
|
@ -1569,6 +1570,7 @@ fn update<'a>(
|
||||||
constrained_module,
|
constrained_module,
|
||||||
canonicalization_problems,
|
canonicalization_problems,
|
||||||
module_docs,
|
module_docs,
|
||||||
|
type_shortname: _,
|
||||||
} => {
|
} => {
|
||||||
let module_id = constrained_module.module.module_id;
|
let module_id = constrained_module.module.module_id;
|
||||||
|
|
||||||
|
@ -3141,6 +3143,7 @@ fn fabricate_effects_module<'a>(
|
||||||
Ok((
|
Ok((
|
||||||
module_id,
|
module_id,
|
||||||
Msg::MadeEffectModule {
|
Msg::MadeEffectModule {
|
||||||
|
type_shortname: effects.type_shortname,
|
||||||
constrained_module,
|
constrained_module,
|
||||||
canonicalization_problems: module_output.problems,
|
canonicalization_problems: module_output.problems,
|
||||||
module_docs,
|
module_docs,
|
||||||
|
|
|
@ -143,11 +143,13 @@ pub struct PlatformHeader<'a> {
|
||||||
pub after_provides: &'a [CommentOrNewline<'a>],
|
pub after_provides: &'a [CommentOrNewline<'a>],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// e.g. fx.Effects
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub struct Effects<'a> {
|
pub struct Effects<'a> {
|
||||||
pub spaces_before_effects_keyword: &'a [CommentOrNewline<'a>],
|
pub spaces_before_effects_keyword: &'a [CommentOrNewline<'a>],
|
||||||
pub spaces_after_effects_keyword: &'a [CommentOrNewline<'a>],
|
pub spaces_after_effects_keyword: &'a [CommentOrNewline<'a>],
|
||||||
pub spaces_after_type_name: &'a [CommentOrNewline<'a>],
|
pub spaces_after_type_name: &'a [CommentOrNewline<'a>],
|
||||||
|
pub type_shortname: &'a str,
|
||||||
pub type_name: &'a str,
|
pub type_name: &'a str,
|
||||||
pub entries: Vec<'a, Loc<TypedIdent<'a>>>,
|
pub entries: Vec<'a, Loc<TypedIdent<'a>>>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -490,6 +490,11 @@ fn effects<'a>() -> impl Parser<'a, Effects<'a>> {
|
||||||
let (spaces_before_effects_keyword, state) =
|
let (spaces_before_effects_keyword, state) =
|
||||||
skip_second!(space1(0), ascii_string("effects")).parse(arena, state)?;
|
skip_second!(space1(0), ascii_string("effects")).parse(arena, state)?;
|
||||||
let (spaces_after_effects_keyword, state) = space1(0).parse(arena, state)?;
|
let (spaces_after_effects_keyword, state) = space1(0).parse(arena, state)?;
|
||||||
|
|
||||||
|
// e.g. `fx.`
|
||||||
|
let (type_shortname, state) =
|
||||||
|
skip_second!(lowercase_ident(), ascii_char(b'.')).parse(arena, state)?;
|
||||||
|
|
||||||
let ((type_name, spaces_after_type_name), state) =
|
let ((type_name, spaces_after_type_name), state) =
|
||||||
and!(uppercase_ident(), space1(0)).parse(arena, state)?;
|
and!(uppercase_ident(), space1(0)).parse(arena, state)?;
|
||||||
let (entries, state) = collection!(
|
let (entries, state) = collection!(
|
||||||
|
@ -506,6 +511,7 @@ fn effects<'a>() -> impl Parser<'a, Effects<'a>> {
|
||||||
spaces_before_effects_keyword,
|
spaces_before_effects_keyword,
|
||||||
spaces_after_effects_keyword,
|
spaces_after_effects_keyword,
|
||||||
spaces_after_type_name,
|
spaces_after_type_name,
|
||||||
|
type_shortname,
|
||||||
type_name,
|
type_name,
|
||||||
entries,
|
entries,
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,7 +4,7 @@ platform folkertdev/foo
|
||||||
packages {}
|
packages {}
|
||||||
imports [ Task ]
|
imports [ Task ]
|
||||||
provides [ mainForHost ]
|
provides [ mainForHost ]
|
||||||
effects Effect
|
effects fx.Effect
|
||||||
{
|
{
|
||||||
putLine : Str -> Effect {},
|
putLine : Str -> Effect {},
|
||||||
getInt : Effect { value: I64, errorCode: [ A, B ], isError: Bool }
|
getInt : Effect { value: I64, errorCode: [ A, B ], isError: Bool }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue