Coder Social home page Coder Social logo

Comments (11)

fabric-and-ink avatar fabric-and-ink commented on September 26, 2024 1

Working on it.

from chalk.

fabric-and-ink avatar fabric-and-ink commented on September 26, 2024 1

Slow but steady progress... :)

from chalk.

scalexm avatar scalexm commented on September 26, 2024 1

@fabric-and-ink niko is not extremely available right now, but I'll try to help you soon :)

from chalk.

scalexm avatar scalexm commented on September 26, 2024 1

@fabric-and-ink How about:

pub struct FolderRef<'f, F> where F: 'f + ?Sized {
    folder: &'f mut F,
}

impl<'f, F: ?Sized> FolderRef<'f, F> {
    pub fn new(folder: &'f mut F) -> Self {
        FolderRef {
            folder,
        }
    }
}

impl<'f, F: Folder + ?Sized> Folder for FolderRef<'f, F> {
    fn fold_ty(&mut self, ty: &Ty, binders: usize) -> Result<Ty> {
        self.folder.fold_ty(ty, binders)
    }

    fn fold_lifetime(&mut self, lifetime: &Lifetime, binders: usize) -> Result<Lifetime> {
        self.folder.fold_lifetime(lifetime, binders)
    }
}

and then you use it like that:

impl<T: Fold> Fold for Shifted<T> {
    type Result = T::Result;

    fn fold_with(&self, folder: &mut Folder, binders: usize) -> Result<Self::Result> {
        // I... think this is right if binders is not zero, but not sure,
        // and don't care to think about it.
        assert_eq!(binders, 0);

        // First up-shift any variables. i.e., if `self.value`
        // contains a free var with index 0, and `self.adjustment ==
        // 2`, we will translate it to a free var with index 2; then
        // we will fold *that* through `folder`.
        let mut new_folder = (Shifter::new(self.adjustment), FolderRef::new(folder));
        self.value.fold_with(&mut new_folder, binders)
    }
}

With that I think you should be good :)

from chalk.

nikomatsakis avatar nikomatsakis commented on September 26, 2024

@fabric-and-ink cool, feel free to come to gitter channel with questions, if any arise

from chalk.

fabric-and-ink avatar fabric-and-ink commented on September 26, 2024

I followed your suggestion to implement a bridge trait. Now I am stuck at connecting both kinds of folders at this point:

    fn fold_lifetime(&mut self, lifetime: &Lifetime, binders: usize) -> Result<Lifetime> {
        match *lifetime {
            Lifetime::Var(ref var) => self.fold_free_lifetime_var(*var, binders),
            Lifetime::ForAll(universe_index) => {
                unimplemented!();
            },
        }
    }

I don't know what a universe is in this context (see #51) and therefore don't now how to proceed. Any hints? :)

from chalk.

nikomatsakis avatar nikomatsakis commented on September 26, 2024

@fabric-and-ink sorry, missed these comments! Maybe post your branch somewhere I can see it?

from chalk.

fabric-and-ink avatar fabric-and-ink commented on September 26, 2024

There you go: https://github.com/fabric-and-ink/chalk/commit/649689f2c5843a59ef941316e11641de78c6be13

Nevermind, I got it. 🤦‍

from chalk.

fabric-and-ink avatar fabric-and-ink commented on September 26, 2024

Replaced the old Folder trait (now FolderVar) with the new Folder. Now I am at this point. The "bridge" impl and the impl for Folder + ?Sized ... are in conflict. But the second impl is necessary to make for example this work.

from chalk.

fabric-and-ink avatar fabric-and-ink commented on September 26, 2024

@nikomatsakis any hints on how to solve the trait conflict? (See last comment.)

from chalk.

fabric-and-ink avatar fabric-and-ink commented on September 26, 2024

Nice! Thank you! That worked well :)

from chalk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.