valkyrie-parser 0.2.5

The hand write parser of valkyrie language
Documentation
trait A: Trait + Trait
{

}





trait SemiGroup⟨T⟩ {
    combine (y: T): T
}

trait Monoid⟨T⟩: SemiGroup⟨T⟩{
    unit: T
}

trait SemiGroup {
    combine(self, rhs: Self): Self
}

trait Functor⟨F⟩ {
    map(a: F⟨A⟩, f: Function⟨A, B⟩) -> F⟨B⟩
}

trait Monoid: SemiGroup + Default {
    empty(): Self
}

extends String: Monoid⟨String⟩ {
    combine(self, y: Self) {self.concat(y)}
    unit() {""}
}


trait Functor {
    flat_map⟨A, B⟩(self: Functor⟨A⟩, f: A -> B) -> Functor⟨B⟩;
}

trait Functor {
    flat_map⟨A, B, F: Mutable⟨A⟩ -> B⟩(self: Self⟨A⟩, f: F) -> Self⟨B⟩;
}

extends Option: Functor {
    map⟨A, B, F: FnMut -> B⟩(self: Option⟨A⟩, f: F) -> Option⟨B⟩ {
        match self {
            case Some(a) : Some(f(a)),
            case None:,
        }
    }
}


generic A {}
extends Array⟨A⟩: Functor {
    fmap⟨B⟩(self, f: A -> B) -> Array⟨B⟩ {
        return map(f, self)
    }
}


template A {}
extends Array⟨A⟩: Functor⟨A⟩ {
    // type A = i32
    fmap⟨B⟩(self, f: A -> B) -> Array⟨B⟩ {
        return map(f, self)
    }
}