mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
Make nested datatypes into errors
I was hoping to add nested datatypes into the language, but it turns out doing so is quite tricky and not all that useful with Roc's current compilation model. Basically every implementation strategy I could think of ended up requiring a uniform representation for the data layout (or some ugly workaround). Furhermore it increased the complexity of the checker/mono IR generator a little bit - basically, we must always pass around the alias definitions of nested datatypes and instantiate them at usage sites, rather than being able to unroll aliases as we currently do during canonicalization. So, especially because we don't support polymorphic recursion anyway, I think it may be better to simply disallow any kind of nested datatypes in the language. In any case, Stephanie Weirich [seems to think nested datatypes are not needed](https://www.cis.upenn.edu/~plclub/blog/2020-12-04-nested-datatypes/). Closes #2293
This commit is contained in:
parent
8be1deff97
commit
4e942b3e5d
9 changed files with 284 additions and 59 deletions
|
@ -232,6 +232,16 @@ pub struct AliasHeader<'a> {
|
|||
pub vars: &'a [Loc<Pattern<'a>>],
|
||||
}
|
||||
|
||||
impl<'a> AliasHeader<'a> {
|
||||
pub fn region(&self) -> Region {
|
||||
Region::across_all(
|
||||
[self.name.region]
|
||||
.iter()
|
||||
.chain(self.vars.iter().map(|v| &v.region)),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum Def<'a> {
|
||||
// TODO in canonicalization, validate the pattern; only certain patterns
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue