drym-org / qi

An embeddable flow-oriented language.
59 stars 12 forks source link

Can't install using just raco pkg install #13

Closed jo-sm closed 2 years ago

jo-sm commented 2 years ago

I'm quite interested in learning how to use Qi šŸ™‚ and am going to try to use it in some of my small personal projects or coding exercises. Thanks for creating it!

I tried to install it using raco pkg install but it seems to fail:

> raco pkg install qi-lib
Resolving "qi-lib" via https://download.racket-lang.org/releases/8.2/catalog/
Resolving "qi-lib" via https://pkgs.racket-lang.org
Downloading repository https://github.com/countvajhula/qi.git?path=qi-lib#reorganize-package-as-lib-test-doc-redux
git: could not find requested reference
  reference: master
  repo: countvajhula/qi.git
  context...:
   /opt/homebrew/Cellar/minimal-racket/8.2/share/racket/collects/net/git-checkout.rkt:403:0: select-commits
   [repeats 1 more time]
   /opt/homebrew/Cellar/minimal-racket/8.2/share/racket/collects/net/git-checkout.rkt:73:8
   /opt/homebrew/Cellar/minimal-racket/8.2/share/racket/collects/net/git-checkout.rkt:54:2: retry-loop
   /opt/homebrew/Cellar/minimal-racket/8.2/share/racket/collects/pkg/private/download.rkt:102:2: download!
   /opt/homebrew/Cellar/minimal-racket/8.2/share/racket/collects/file/cache.rkt:63:2: fetch-and-continue

I did get it to work by running the command raco pkg install --type git-url "https://github.com/countvajhula/qi.git?path=qi-lib#reorganize-package-as-lib-test-doc-redux" but this isn't great UX. Any thoughts?


Also, I'm trying to play around with it a bit with parsing one of the inputs for the second Advent of Code challenge this year and I'm having some difficulty understanding how to approach the problem (specifically around dealing with two inputs in a flow). Is there some place that would be good to ask about it for some help or insight?

countvajhula commented 2 years ago

Hi, thanks for the report. I've raised this issue on the Discourse forum, hope we can get some answers there. You should just be able to use the main branch, FWIW, rather than the "redux" branch. Not that you should have to do this manually, of course!

Re: questions on writing flows, I haven't been doing AoC but I've been thinking about joining. In the meantime, feel free to post your question either on the Discourse or on IRC and I'm happy to help!

Another resource you could look at if I / others are not available is the interactive qi tutorial.

To install it, follow these steps:

raco pkg install from-template
raco new qi-tutorial

And open the file tutorial.rkt start.rkt.

This is a more comprehensive tutorial than the Scribble docs at the moment (though they will eventually be kept up to date wrt each other) and I think it's a great format for learning a language.

countvajhula commented 2 years ago

@jo-sm It should work now. Could you please try again?

jo-sm commented 2 years ago

@countvajhula it works now, thanks for taking a look!

As far as the tutorial, I looked at the tutorial and I still didn't quite get how I would approach my problem so I'll reach out on Discourse or IRC soon šŸ™‚

countvajhula commented 2 years ago

@jo-sm Great! Let me know šŸ‘

countvajhula commented 2 years ago

btw @jo-sm , I might have missed you in the Racket Discord during AoC, but I just noticed your repo and saw this comment:

If you wanted to "mapmap" using Qi, you could use >< as you mentioned:

(define (mapmap f lst)
    (~> (lst) ā–³ (>< (map f _)) ā–½))

(define lst (list (list 1 2 3) (list 2 3 4) (list 3 4 5)))
(mapmap add1 lst) ; => '((2 3 4) (3 4 5) (4 5 6))

You could also avoid the map altogether:

(define (mapmap f lst)
    (~> (lst) ā–³ (>< (~> ā–³ (>< f) ā–½)) ā–½))

Your main parser function could also be done in one combined flow, something like:

(define-flow parser
  (~> (string-split "\n")
      (-< (~>> car
               (string-split _ ",")
               (map string->number))
          (~>> cdr
               (chunk _ 6)
               (map cdr)
               (mapmap (ā˜Æ (~>> string-split (map string->number))))))
      list))

You could also do the mapmap part directly as part of the combined flow. Lots of options! šŸ˜