<theruran>has anyone used guile-log? the logic programming framework <theruran>stis: that's awesome! I wanted to try it out but I don't see it in guix <theruran>ok. I can probably get it to work in a guix ad-hoc environment <stis>make sure to take out a tag, also it is not tested against recent guile versions <stis>darn, havent worked on it for so9me time. recent year has bin into guile-python <stis>or python-on-guile as it is called <theruran>I am wondering about building a compiler using guile-log <stis>prolog is nice for that indeed <stis>I use stis-parser when I make compilers <theruran>wow so that can make parsers for LR(1) grammars? looking at parsing Ada <theruran>there is a complete BNF grammar for Ada in the standard, so it seemed best to me to try to parse that to generate an Ada parser <stis>should be able to do that, not fast, but in my experience the compilatioin still takes longer. but chunking large set of source code semantics you probably need something else <theruran>do you mean some finer control would be needed to parse a source file properly? not only quickly. <stis>the fastes is to use a parser generator if these are applicable, like yacc or guile versions. But if you want more power I would use something else like stis-parser ot the guile PEG parser <stis>the parser generators usuale can take BNF like inputs. <stis>there are an example of a complete python parser in stis-parser <stis>and a few other examples <stis>I think that I should document it better though <theruran>awesome! well I got stis-parser to build, anyway <theruran>thanks - I will try to learn from these examples ***sneek_ is now known as sneek
<theruran>so Guile doesn't have design-by-contract or data schemas? <lilyp>theruran: You could add contracts add runtime by wrapping functions in pre- and postconditions. <lilyp>but otherwise yeah, quickcheck is fun <theruran>I saw a Guix thing that can convert CHICKEN eggs for Guile? there is a design-by-contract egg <muradm>hi guile, is there path join function in library? can't find.. <muradm>like (path-join "/some/dir" "some-file") => "/some/dir/some-file" <muradm>that will take care of necessary trailing slashes etc. (not a guix :) ) <xd1le>muradm: maybe can use canonicalize-path and system-file-name-convention as starting points to implement it <muradm>xd1le: canonicalize-path raises exception, i suppose it is doing (stat.. under the hood <xd1le>i have not used or tested it <xd1le>but the path-join function looks like it is using string-trim-right instead of canonicalize-path <muradm>this is from guile manual "Web Server" section <muradm>it says "... or it can return a procedure ..." <muradm>whole request handler? so i have to write response/headers my self? <muradm>i can't figure it out (define (static-send-file file size) (lambda (outer) ...)) <muradm>both cases raise: Too few values returned to continuation <xd1le>muradm: sorry I'm going to sleep now <xd1le>but your code seems to be in the right direction <xd1le>the respond-static-asset function might interest you <xd1le>oh and to answer you question, yeah it does seem like you have to write this yourself from reading the web server section <xd1le>maybe search if someone made a higher level web framework, I have not used web servers in guile myself <muradm>yes, i'm staring at it whole day, but it is complex to understand for now :) <muradm>what does "Too few values returned to continuation" means? <maximed>muradm: (receive (x y) 'z SOMETHING) --> too few values <maximed>because the expression 'z evaluates to a szingle value <maximed>but two were expected (to be named 'x' and 'y') <rlb>civodul: I'm confused again with respect to the gmp settings we should have in debian. It looks like mini-gmp is disabled by default and that disables scm_install_gmp_memory_functions, so things should be safe by default? In which case we don't have to have --enable-mini-gmp in debian, and I'm not sure we could for 3.0, even if we wanted to, since we've been shipping 3.0 for a while without it, and it breaks the abi? <rlb>i.e. 3.0's been in testing for a while and has now shipped in stable (bullseye), so I suspect we might have to wait until a soname change to change that in debian. <muradm>maximed: thanks, figured that out now! <muradm>suppose i have out string port, and file to write to it, now i do like open-input-file, get-string-all, write out <muradm>is there more simple/efficient way of doing that, or i have to follow this way <maximed>muradm: what are you trying to do exactly? <maximed>If so, maybe get-bytevector-some and put-bytevector are useful <muradm>for now don't want loop, at least want to see it working <RhodiumToad>(I don't think you actually need apply there, (writer out read-in) should suffice, but that's probably not your problem) <muradm>still i get that "Too few.." (face palm) <RhodiumToad>you didn't answer the question, what actual procedure is the value of "writer" when the error occurs? <muradm>there is no writer reader any more <muradm>in before it was either get-string-n or get-bytevector-n for text and binary respectively <muradm>now i don't even pass the procedure to web server, i read in one shot and give it plain data <muradm>it happens after my handler returns <maximed>muradm: I wonder if 'static-file' is allowed to return a single value? <maximed>Maybe replace #f with (values #f #f)? <RhodiumToad>muradm: in the handler you pass to run-server, you're returning only one of static-file's two results <RhodiumToad>you need to use a let-values or receive or one of the other multi-value binding syntaxes in place of let <muradm>maximed: that return value is used only in if, but i tried your guess, same thing <maximed>muradm: (receive (x y) (static-file ...) (if x (values x y) (not-found ...))) <maximed>(to bind multiple values, as RhodiumToad suggests) <muradm>RhodiumToad: (static-file ...) returns either (values ...) or #f, this is not allowed? <muradm>why do i need to unpack and pack (values if i don't need them <RhodiumToad>(let ((res (foo))) ...) binds res to only the first result of (foo) and discards the rest <RhodiumToad>a less obvious way to do it would be something like, <RhodiumToad>(cond ((static-file ...) (lambda (res . _) res) => values) (else (not-found ...))) <rndd>i have problem with compiling an example of using libguile <rndd>i found that header files are located in /usr/include/guile/3.0/ (on ubuntu) <rndd>but where are actual .so files? <rndd>RhodiumToad: i tried pkg-config --libs guile-3.0 <rndd>but i got "no package guile-3.0 found" <RhodiumToad>muradm: dealing with multiple values always seems to involve some amount of friction <muradm>which feels very uncomfortable, what if tomorrow 3 or 4 values, which one would mean what? :) <RhodiumToad>muradm: the version I showed with cond doesn't assume any number of values <muradm>both should be false to signal failure <RhodiumToad>then (cond ((static-file ...) (lambda (res body . _) (or res body)) => values) (else (not-found ...))) <RhodiumToad>(that's srfi-61 syntax for (cond), but in guile it's available by default) <rndd>RhodiumToad: i dont know <RhodiumToad>rndd: there should be a way to see the files installed by the package *RhodiumToad not linux user, doesn't know the commands offhand <muradm>i can return "string/record/list/vector/etc. or #f" but cant "values or #f" very unintuitive, killed like 3 hours to get that .. :D <tohoyn> rndd: try to run "dpkg -L guile-3.0-dev | grep .so" <tohoyn>rndd: and rndd: try to run "dpkg -L guile-3.0-dev | grep .pc" <muradm>RhodiumToad: yeah, cond looks better of course, thanks :) <muradm>rndd: "guile-config link" "guile-config compile" .. <muradm>and your libs should be in standard place of your distro <muradm>there are 2 of them guile-3.0 and gc <muradm>then you can use guile-config tool in your build tool (Makefile, CMakeLists.txt etc.) <RhodiumToad>it's kind of unfortunate that you can't do (cond ((foo) or => values) ...) <RhodiumToad>(it doesn't work because (or) is syntax and not a function) <RhodiumToad>the main thing that annoys me with multiple values is that it's often not possible to avoid converting them to lists and back <muradm>RhodiumToad: twice heart breaking then... as far as i see from (web server) code it was not revised for long time... <muradm>first time i saw (values ...) here in (web server) <RhodiumToad>returning a single list rather than multiple values can lead to more consing <muradm>can't even properly serve binary file, as it only seems to support bytevector for it <muradm>but i always get this: In procedure sendfile: Wrong type argument in position 1 (expecting open file port): #<output: string 7f69a26eacb0> <muradm>RhodiumToad: regarding returning multiple values, for me it is at most tuple, where '(val1 . val2) works pretty well <muradm>(match exp ((v1 . v2) ... ) does good job <muradm>hmm.. good to learn the difference <muradm>may be i have to look at call-with-with-values, as (web server) code is full of them <muradm>to understand the pattern for (values ...) usage <RhodiumToad>call-with-values is the underlying primitive, you need to know how it works but usually you can avoid using it <RhodiumToad>(call-with-values a b) calls a with no args, and then the return values of a become the args passed to b <muradm>as far as i understand values cannot be matched either with (ice-9 match)... <RhodiumToad>but again, that's forcing the construction of a list of the values <muradm>yes, there is no code path to output binary with port <muradm>but (stat:size ...) reported size is not matching to what (get-bytevector-n ...) returns