Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
LordMZTE
@lordmzte:matrix.org
[m]
that documentation seems to assume a lot of knowledge from the readers and leaves some things unexplained like
  • what exactly the run_lift and eval_state functions do
  • how the modify and get functions know which effect to use
  • what let eff_open : Eff [| eff_1 : Eff1 | r |] () = ... means. what does the () at the end of the type mean, and is ... some kind of expression or a placeholder?
marwes
@marwes:matrix.org
[m]

what exactly the run_lift and eval_state functions do

They run/evaluate the effects and output (return) the result

how the modify and get functions know which effect to use

That is encoded in their type signature https://gluon-lang.org/doc/nightly/std/std/effect/state.html#value.modify

1 reply
LordMZTE
@lordmzte:matrix.org
[m]
well, i was wondering more how they work internally. what is the type of their parameters, and how exactly do they access the effects
1 reply
marwes
@marwes:matrix.org
[m]

what let eff_open : Eff [| eff_1 : Eff1 | r |] () = ... means. what does the () at the end of the type mean, and is ... some kind of expression or a placeholder?

Eff a is a monad just like IO is a monad, so Eff a b is a monad that evaluates to b just as IO b is a monad that evaluates to b

But you can try to check the source code I guess
Not sure exactly what it is you are looking for
Yes
LordMZTE
@lordmzte:matrix.org
[m]
i dont think the docs mention that
1 reply
marwes
@marwes:matrix.org
[m]
The row "states" which effects are needed
LordMZTE
@lordmzte:matrix.org
[m]
well, im just saying that the docs could be a little more clear is all :D
marwes
@marwes:matrix.org
[m]
Opening an issue for things that are uclear would be helpful, else I may forget it
LordMZTE
@lordmzte:matrix.org
[m]
sure!
LordMZTE
@lordmzte:matrix.org
[m]
gluon-lang/gluon#913 these are some things i was confused about.
Snarpix
@Snarpix
Hi! How can I add global function to a RootedThread?
Nearest I have got is:
load_script("smth", "let func x = 1 in func");
run_expr("123", "import! smth");
I want something like:
load_script("1", "let func x = 1 in ()");
run_expr("2", "func");
4 replies
Snarpix
@Snarpix

I want to type-check a Gluon function with runtime-defined simple record type.
So I iterate over function arguments and compare them using ==.
It works with basic types but not with records.
If I print both expected and function ArcTypes with Debug fmt, I see that both are the same, only Symbol addresses are different.
I generate expected ArcType using following code:

pub fn get_gluon_type(vm: &Thread, t: &ConfigArgsType) -> ArcType {
.......
        ConfigArgsType::Struct(item_types) => {
            let mut fields = Vec::new();
            for i in item_types {
                let name = gluon::base::symbol::Symbol::from(i.name.as_str());
                fields.push(gluon::base::types::Field::new(
                    name,
                    get_gluon_type(vm, &i.arg_type),
                ));
            }
            let type_cache = vm.global_env().type_cache();
            type_cache.record(Vec::new(), fields)
        }
......
}

What am I doing wrong?

marwes
@marwes:matrix.org
[m]
Symbol has pointer equality, so having the same stringified name is not enough
Symbol::from should probably be removed, I think it is only used for tests
Though, in records the fields shouldn't actually use Symbol as those should be compared by string
It is just that all other code than == compares them by string
Snarpix
@Snarpix
But type_cache().record() requires Symbol
Maybe I should use Symbol from vm Symbols, so ptr will match
But I don't know how exactly should I get Symbol from vm Symbols cache
Snarpix
@Snarpix
Okay, I've made myself a workaround:
fn gluon_type_compare(got_type: &ArcType, expected_type: &ArcType) -> bool {
    if got_type.is_non_polymorphic_record() && expected_type.is_non_polymorphic_record() {
        let got_type_iter = got_type.row_iter();
        let expected_type_iter = expected_type.row_iter();
        if got_type_iter.len() != expected_type_iter.len() {
            return false;
        }
        for (got, expected) in got_type_iter.zip(expected_type_iter) {
            if !got.name.name_eq(&expected.name) {
                return false;
            }
            if got.typ != expected.typ {
                return false;
            }
        }
    } else {
        if got_type != expected_type {
           return false;
        }
    }
    true
}
Boscop
@Boscop
I need to choose a Rust-embeddable scripting language for a livecoding project. I was trying to find info about gluon's performance, and found this thread:
gluon-lang/gluon#858
In the end it links to this merged PR (gluon-lang/gluon#861), does that mean that gluon is as fast as lua now?

And what about compilation speed/latency for recompilation? I found this comment: https://www.reddit.com/r/rust/comments/rto49q/rune_vs_rhai/hqv3olz/

Gluon is pretty good other than it's not that easy to work with and takes a long time to compile/link.

How long does it take to compile/link a program that consists of N lines (or N symbols/definitions)?

Boscop
@Boscop

:point_up: February 20, 2019 2:12 PM

I'd like to get it to the point that you could load a file of precompiled gluon just as easily as a normal script file
And the standard library should be distributed in precompiled form as well so that user scripts could avoid that cost

So currently the whole std lib is recompiled whenever a user script is recompiled? Does that mean the gluon edit/compile cycle is too slow for livecoding?

Boscop
@Boscop
Is there a way to import all symbols of a module, like use foo::*;? If not, what would need to be done to add this?
Is there a way to add Rust types/functions to the global scope (not add as importable module, but already imported, as if they were in prelude), or a way to extend the prelude or add a custom additional prelude?
Boscop
@Boscop
Does gluon have something like traits or type classes? I don't see them in the book. How can I define a type class and use them as quantification constraints?
brendanzab
@brendanzab:matrix.org
[m]
Gluon has an implicit thing IIRC
1 reply
Boscop
@Boscop
@brendanzab:matrix.org Thanks. Do you also know how I can do glob imports (like use foo::*;) or how I can add my own prelude when embedding gluon in a Rust host?
brendanzab
@brendanzab:matrix.org
[m]
I'm not sure I think that would require adding some sort of glob-style patterns. I think gluon-style is to generally import things explicitly?
Boscop
@Boscop
@brendanzab:matrix.org the explicit imports are a pain in the neck for music live coding :/
How can I inject my own custom prelude?
brendanzab
@brendanzab:matrix.org
[m]
Yeah :( Not sure if there is a workaround you could do via the gluon API - like loading a bunch of stuff into the context before a script is run
cc. marwes 😅
Boscop
@Boscop
@brendanzab:matrix.org I only found a way to add a script that the user code can import. How can I load host-defined symbols into the scope that the user code runs in?
brendanzab
@brendanzab:matrix.org
[m]
yeah I dunno, I worked on some library stuff for gluon, but that was a long time ago. so can't really help with specifics, sorry
Boscop
@Boscop
Btw, another question, how can I cache the compilation of the std lib between reruns of the user script, so that it can just link to the precompiled std lib on every change, instead of having to recompile std every time the user script changes?
Also, how can I precompile/cache any custom .glu script module?
I want the music live coding edit & compile cycle to be as fast as possible. Upon every change of the user script, it should only recompile that, and then it should link it to the precompiled std and my_std libs.
Boscop
@Boscop
@brendanzab:matrix.org I want to provide my users some inspection mechanism like matlab. For this I need to be able to get a list of all symbol names that the user defines in the outermost scope, and their types and values, and the source spans of their definitions. And I need to be able to find out which symbol definition the user's cursor is on. I have the cursor pos and need the spans to look up which symbol the cursor is on, to visualize always that one. How can I get a list of top level user defined symbols with their names, types, values and spans?
Boscop
@Boscop
How can I run an expression in a vm and then get the value AND its type, that the expression evaluates to?
I want to give the user different options for what the type of the last expression in a script can be. But with the run expr function, I already have to specify which type I'm expecting. how can I eval first, AND THEN see which (host-defined) type it is?
naveedpash
@naveedpash:matrix.org
[m]
Hey
Is this project still active or abandoned?
naveedpash
@naveedpash:matrix.org
[m]
I'll take that as abandoned
LordMZTE ⚡️
@lordmzte:mzte.de
[m]
it does seem abandoned right now but im not sure thats permanent
naveedpash
@naveedpash:matrix.org
[m]

Well I'll take a crack at this
I dream of a language that is functional and can do everything that python is currently famous for

Especially data science