[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help with lambda-procedure
From: |
Panicz Maciej Godek |
Subject: |
Re: Help with lambda-procedure |
Date: |
Sun, 16 Dec 2018 21:31:56 +0100 |
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 <address@hidden> 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:
>
> address@hidden ~/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