IRC channel logs

2016-07-31.log

back to list of logs

<mark_weaver>r7rs-wip is my work, although taylan rebased it recently.
<mark_weaver>I agree that detecting cyclic code would be good. that would have to go in the macro expander, I think.
<mark_weaver>because before macro expansion, it's not yet what is code and what is data.
<mark_weaver>and after macro expansion would be too late
<mark_weaver>*not yet known
<mark_weaver>relatively few of us have worked with the psyntax code in recent years, just wingo and me, I think. it would be good if more people would learn :)
<ijp>I do want to do some experimenting with the expander, but it's not a priority
<mark_weaver>the first step to understanding psyntax is to read the paper that is cited in its comments near the top.
<ijp>I have a rough idea of how it works from the beautiful code article
<mark_weaver>*nod* I haven't read that article; maybe it covers the needed concepts.
<paroneayea>speaking of cycles, I learned about the tortise and hare style of detecting cycles by seeing "tortoise" and "hare" show up as locals in the guile debugger today while debugging some code in a map :)
<paroneayea>that was fun for me
<mark_weaver>heh, yeah, it's a good trick :)
<linas>on rare occasions, guile from current git prints "madvise failed: Cannot allocate memory" from libguile/vm.c:893
<linas>rare == very rare, haven't seen this in many months
<amz3>hello
<amirouche>hello
<random-nick>hello
<defanor>hello. i'm looking for a graph library suitable for directed and weighted (and possibly cyclic) graphs, and particularly for shortest path search between two given points. is there one for guile?
<ijp>maybe in guile-lib, but I suspect most graph libs are custom made
<defanor>will look there, thanks
<defanor>only found http://www.nongnu.org/guile-lib/doc/ref/graph.topological-sort/ in the docs, but it's not quite that. perhaps will have to use a custom made one, too
<defanor>what about cairo, are there bindings for guile 2+? i've only found some old ones (for 1+) so far
<ijp>1.9.91 supposedly works with 2
<defanor>oh, that's nice. will try that then
<brendyn>How can I simply open a text file in guile?
<amz3>brendyn: use with-input-from-file
<defanor>+ (info "(guile)File Ports"), or API Reference > Input and Output > Port Types > File Ports
<brendyn>Hmm there is very little in the manual about it
<brendyn>What's a thunk?
<defanor>a function without arguments
<brendyn>That doesn't make much sense to me
<defanor>(lambda () (display "i'm a thunk"))
<brendyn>How can I input the file if it has no arguments?
<defanor>the function description explains that -- current-input-port and current-output-port are getting set
<mark_weaver>brendyn: because thunks, like all other procedures, capture their lexical environments.
<brendyn>(with-input-from-file "foo.txt" (lambda () (display "I'm a silly thunk")))
<mark_weaver>or (with-input-from-file "foo.txt" read)
<defanor>it would make a bit more sense with (with-output-to-file "foo.txt" (lambda () (display "I'm a silly thunk"))), but yeah
<brendyn>I see, I need read.
<brendyn>read will output simply one line?
<mark_weaver>'read' reads one scheme S-expression
<mark_weaver>'read-line' or 'read-string' from (ice-9 rdelim) are other useful examples
<mark_weaver>read-string reads the entire file as a single string
<mark_weaver>best avoided if the file could be huge, but otherwise convenient
<defanor>what would it do if a file is a pipe, btw? read until it's closed?
<mark_weaver>yes, it reads until EOF
<brendyn>Wow, I've finally managed to implement cat after 3 hours
<brendyn>:)
<brendyn>Well, not actually cat. Just displaying a text file
<mark_weaver>(call-with-input-file file-name read-string)
<brendyn>Are (list-tail '(...) 1) and (cdr ...) the same thing?
<mark_weaver>brendyn: (list-tail '(...) 1) and (cdr '(...)) are the same
<brendyn>Well when I swap them I get ERROR: In procedure cdr: Wrong type (expecting pair): filenames
<mark_weaver>brendyn: give me enough information to reproduce this on my end please
<brendyn>My code has all turned to spaghetti now
<mark_weaver>i.e. what expression led to that error, and what are the relevant free variable bindings, etc.
<brendyn>mark_weaver: I got it working, but I feel like it is so messy just to search a file. Any tips?: https://gateway.ipfs.io/ipfs/QmRr4W9L1v8RScSNuG73S86p6x61kNsMxhtyHBikKwKqv6
<mark_weaver>first of all, use 'match'
<brendyn>instead of match:substring?
<mark_weaver>it avoids most uses of 'car', 'cdr', 'list-tail', etc.
<mark_weaver>no, for pattern matching and deconstructing list structure
<mark_weaver>also use 'map' and 'for-each' where appropriate
<mark_weaver>instead of manually iterating over lists
<mark_weaver>also 'fold'
<mark_weaver>and 'append-map'
<mark_weaver>'with-input-from-file' is called incorrectly from 'iter'. only one argument is passed, no thunk.
<mark_weaver>the second clause of the 'cond' is wrong, should be (else (let* ...)) and without the extra layer of parens
<brendyn>Ok, this is getting out of hand.
<brendyn>I don't thing match exists
<brendyn>Do you mean string-match ?
<mark_weaver>no, I mean 'match', from (ice-9 match)
<mark_weaver>it's in the index of the Guile manual
<brendyn>Is this meant to replace regex?
<mark_weaver>no
<mark_weaver>you're also using the name 'file' for a variable that actually contains a string
<brendyn>Well it's hard to invent symbol names
<mark_weaver>I guess I should just rewrite this and show you how it can be done more elegantly
<brendyn>If you don't mind.
<paroneayea>amz3: to reply to your olllld comment,
<paroneayea>I wouldn't suggest a minifree x200 for anything opengl related
<paroneayea>there's a bug in the graphics driver that makes opengl start to slow down dramatically after a short time
<mark_weaver>brendyn: https://www.netris.org/~mhw/parse-urls.scm.txt
<mark_weaver>also, the [(] hack of quoting the ( can also be done as \\\\(
<brendyn>paredit.el keeps intercepting my \\ so I typed that
<brendyn>Alright, I'll try understand this, then I have to complete the regex bit
<mark_weaver>paredit does intercept the \\, but it does the right thing there. what is the difficulty?
<brendyn>Currnently it just returns all the DownloadEpub('C1277') bits
<brendyn>Like when I typed the first line it would go #!/usr/bin/guile \\^M
<mark_weaver>right, it's true that paredit interferes with the \\ in the shebang, but it seems to do the right thing when inserting \\\\( into the regexp string
<brendyn>hmm ok
<mark_weaver>anyway, what do you *want* it to do?
<brendyn>Basically there are these javascript download links on a site that I can't get with wget. in the webpage it has buttons like onClick = DownloadEpub('C1277') where DownloadEpub concatenates some things to make the url as per http://haodoo.net/d.js
<brendyn>Since I have all the html files I wantet to recreate all those links and download the books.
<mark_weaver>in the scheme world, we usually prefer to convert html to sxml using a package called htmlprag.
<brendyn>Would it be better to replace the regex with some proper scheme code?
<mark_weaver>sxml is an S-expression notation for XML that's convenient to work with in scheme, and elegantly avoids issues around proper parsing and quoting within XML/HTML
<mark_weaver>see http://en.wikipedia.org/wiki/SXML and http://okmij.org/ftp/Scheme/xml.html for more on SXML
<brendyn>I guess that would work unless there were malformed files
<mark_weaver>htmlprag aims to tolerate typical HTML in the wild, iirc.
<ijp>it might be an idea to rewrite htmlprag to use the html5 parsing algorithm
<mark_weaver>although I've not had occasion to use htmlprag myself. for my use cases, it sufficed to simply use xml->sxml
<ijp>one day...
<mark_weaver>we use SXML in the generation of the web pages for Guile and Guix, and I've used it for parsing RSS feeds
<brendyn>Hmm ok, how do I load this into guile?
<mark_weaver>ijp: is htmlprag in guildhall?
<mark_weaver>(in your guildhall repo, I mean)
<mark_weaver>sneek: guildhall?
<sneek>guildhall is https://github.com/ijp/guildhall/wiki/Getting-Started
<brendyn>(use-modules (sxml simple))
<ijp>I think it's in guile lib, which I don't remember if I packaged
<ijp>probably did
<mark_weaver>ah yes, it's in guile-lib
<mark_weaver> http://www.nongnu.org/guile-lib/doc/ref/htmlprag/
<brendyn>(xml->sxml "<br>") doesn't work, so I'll probably need the other library
<mark_weaver>*nod*
<brendyn>No code for module htmlprag
<mark_weaver>do you have guile-lib installed?
<brendyn>Installing it now
<davexunit>brendyn: I use a custom sxml->html procedure to render HTML correctly: https://git.dthompson.us/haunt.git/blob/HEAD:/haunt/html.scm
<ijp>I may be the only person that use pre-post-order for that
<mark_weaver>brendyn: anyway, having said all this, it might be that in this particular use case, it's easier to just use regexps, even if not as robust.
<brendyn>Yeah
<mark_weaver>if it's easy to generate the URLs based on strings found by that regexp
<brendyn>It's probably not the best regex anyway.
<brendyn>It seemed impossible to make the regex start matching after a string instead of before
<brendyn>Like this just returns C1277 in python
<brendyn> https://paste.ubuntu.com/21617572/
<brendyn>I need to process DownloadSTRING1('STRING2') and turn it into http://haodoo.net/<string conditional on STRING1>STRING2
<mark_weaver>brendyn: I updated https://www.netris.org/~mhw/parse-urls.scm.txt to show one simple approach
<brendyn>I'm still bewildered over the code
<mark_weaver>where 'type-prefix-table' should be filled appropriately
<brendyn>I don't understand how match works yet
<mark_weaver>when the pattern is (argv0 . file-names), that means that the car is bound to 'argv0' and the cdr is bound to 'file-names'.
<mark_weaver>and the second pattern is _ which means match anything without binding it to a variable
<davexunit>ijp: honestly, I don't know how to use pre-post order. it's probably the "right thing", though.
<mark_weaver>actually, I guess the first pattern will always match in this case, so the second pattern is useless.
<mark_weaver>but this is a very simple pattern for matching argument lists when you don't want to do proper option parsing.
<brendyn>I think you made an error in string-append, maybe
<mark_weaver>what error?
<brendyn> ?: 0 [string-append "http://haodoo.net/" #f "C1277"]
<brendyn>#f is not a string
<mark_weaver>that indicates that the 'type-prefix-table' lacks an entry for the type code in that case.
<mark_weaver>I told you above that 'type-prefix-table' needs to be populated
<mark_weaver>when 'assoc-ref' fails to find an entry, it returns #f
<mark_weaver>you could also just use 'match' directly, instead of using 'assoc-ref' with an explicit table.
<mark_weaver>e.g. (match type (("Updb" "updb-") ("Pdb" "pdb-") ...))
<mark_weaver>'match' raises an exception when none of the patterns match
<mark_weaver>there are many ways to do this, of course
<brendyn>Fantastic. It works
<mark_weaver>:)
<brendyn>Actually, this looks similar to the original Javascript
<mark_weaver>I'm going afk for several hours. happy hacking!
<brendyn>No worries. I'm trying to add an affix now :p
<brendyn>Wow, this make-regexp magic is great
<brendyn>It's like the regex has 3 different kinds of results somehow
<MorrisSzyslak>Hello, What is the header which declare SCM type ?
<MorrisSzyslak>tags.h
<brendyn>mark_weaver: https://ipfs.io/ipfs/QmTk3EdpK4vLiC1U2JyRnfYqeBf6uGx5QqP6H5SgGQovsB
<brendyn>This one works reasonably well. For some reason it outputs a bunch of #<Unspecified>, so I'll figure that out tomorrow.
<daviid>cmhobbs: guile-gnome installs its modules in $prefix/share/guile-gnome-2
<daviid>cmhobbs: in order to make this path 'known' to guile, just (use-modules (gnome-2))
<daviid>cmhobbs: (gnome-2) is installed in (%global-site-dir)
<daviid>cmhobbs: for info, someone mentionned KisĂȘ: it is now part of GNU, but the name name changed, it is now GNU Foliot
<cmhobbs>daviid: i was doing that use modules line but it says it can't find gnome-2
<cmhobbs>it's just not in my guile load path, i don't think
<daviid>cmhobbs: you said you're on debian, using guile-2.0 package right? did you install as root? it could be thgat you missed a reported error at install time
<daviid>of course I'm just shooting here. where did you install guile-gnmome?