From: Panicz Maciej Godek <godek.maciek@gmail.com>
To: swedebugia@riseup.net
Cc: Guile User <guile-user@gnu.org>
Subject: Re: Help with lambda-procedure
Date: Sun, 16 Dec 2018 21:31:56 +0100 [thread overview]
Message-ID: <CAMFYt2ZSpNGWT1OVVkHRMYuxdsyvJExQZt7ZMLSLm461iNLwSQ@mail.gmail.com> (raw)
In-Reply-To: <9821320835493e75e12418c00796312c@riseup.net>
Hi,
I don't have much time to look at this, but from a glimpse it seems that
the cluprit is this line:
(let* ((version (split (string-drop version 1)))
it should probably be
(let* ((version (split (string-drop (version) 1)))
- version is a procedure that produces string, and string-drop expects a
string (like the error says), not a procedure.
niedz., 16 gru 2018 o 20:59 <swedebugia@riseup.net> napisał(a):
> I'm trying hard to improve the npm-explorer[1] with a semver-parser.
>
> I get this error when testing in the REPL:
>
> sdb@antelope ~/src/guile-npm-explorer$ guile -s npm-explorer.scm
> >test.dot
> ;;; note: source file /home/sdb/src/guile-npm-explorer/npm-explorer.scm
> ;;; newer than compiled
>
> /home/sdb/.cache/guile/ccache/2.2-LE-4-3.A/home/sdb/src/guile-npm-explorer/npm-explorer.scm.go
> ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
> ;;; or pass the --no-auto-compile argument to disable.
> ;;; compiling /home/sdb/src/guile-npm-explorer/npm-explorer.scm
> ;;; compiled
>
> /home/sdb/.cache/guile/ccache/2.2-LE-4-3.A/home/sdb/src/guile-npm-explorer/npm-explorer.scm.go
> Backtrace:
> 7 (apply-smob/1 #<catch-closure 88f83a0>)
> In ice-9/boot-9.scm:
> 705:2 6 (call-with-prompt _ _ #<procedure default-prompt-handle…>)
> In ice-9/eval.scm:
> 619:8 5 (_ #(#(#<directory (guile-user) 88e9910>)))
> In ice-9/boot-9.scm:
> 2312:4 4 (save-module-excursion _)
> 3831:12 3 (_)
> In /home/sdb/src/guile-npm-explorer/npm-explorer.scm:
> 345:29 2 (generate-dot "mocha" () 0 _)
> 199:8 1 (choose-version #<hash-table 8918540 18/31> #<procedure…>)
> In unknown file:
> 0 (string-prefix? "*" #<procedure version ()> #<undefined> …)
>
> ERROR: In procedure string-prefix?:
> In procedure string-prefix?: Wrong type argument in position 2
> (expecting string): #<procedure version ()>
>
> The offending lambda is this one:
>
> (define (parse-semver hashtable version)
> "return the newest version within the same major or minor version"
> (define (split list)
> (string-split list #\.))
> (define (version-list hashtable)
> (map split
> (map first
> (hash-table->alist (hash-ref hashtable "versions")))))
> (define (major list)
> (first list))
> (define (minor list)
> (second list))
> (define (minor->number list)
> (string->number (minor (split list))))
> ;; Return latest minor with same major version.
>
>
>
> ;; e.g. ^1.1.0 -> 1.4.0 even though 2.0.0 is availiable
>
>
>
> (let* ((version (split (string-drop version 1)))
> (version-list
> (map first
> (hash-table->alist (hash-ref hashtable "versions"))))
> (same-major
> (if (equal? 3 (length version))
> (fold
> ;; recurse through version-list
>
>
>
> (lambda (ver lst)
> (if (string-prefix? (major version) ver)
> (cons ver lst)
> lst))
> '()
> version-list)
> ;; not a version triplet
>
>
>
> #f)))
> ... (se the rest of the sexp in the file attached.
>
> Any ideas whats wrong? I'm still new to lambdas.
>
> --
> Cheers
> Swedebugia
>
> [1]
>
> https://gitlab.com/swedebugia/guile-npm-explorer/blob/master/npm-explorer.scm
prev parent reply other threads:[~2018-12-16 20:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-16 19:48 Help with lambda-procedure swedebugia
2018-12-16 20:18 ` tomas
2018-12-16 20:31 ` Panicz Maciej Godek [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAMFYt2ZSpNGWT1OVVkHRMYuxdsyvJExQZt7ZMLSLm461iNLwSQ@mail.gmail.com \
--to=godek.maciek@gmail.com \
--cc=guile-user@gnu.org \
--cc=swedebugia@riseup.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).