unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: "Thompson, David" <dthompson2@worcester.edu>
To: Amirouche Boubekki <amirouche@hypermove.net>
Cc: Guile User <guile-user@gnu.org>
Subject: Re: Fixing "stringly typed" data structures in Artanis
Date: Sun, 13 Dec 2015 14:58:20 -0500	[thread overview]
Message-ID: <CAJ=RwfYK_0dVaeFrG3pT=Zk+Xvv1fNijOB49+O3dXbuKtZpTsA@mail.gmail.com> (raw)
In-Reply-To: <36af5fa821c40079b8242e5197208dff@hypermove.net>

On Sun, Dec 13, 2015 at 2:41 PM, Amirouche Boubekki
<amirouche@hypermove.net> wrote:
> Le 2015-12-10 23:02, Thompson, David a écrit :
>>
>> [ Changing the subject for this little rant below ]
>>
>> I guess this is as good a time as any to voice a concern that I have
>> with Artanis before too many people depend on it and its not feasible
>> to change it.
>
> Artanis is alpha nobody expects to code against it without having to change
> things
> here and there.

Sure, which is why I want to get these issues taken care of before
things are stable.

>> For an example that uses more proper Guile
>> Scheme idioms, take a look the source for the 'guix publish' tool in
>> GNU Guix. [0]  By viewing a URI as a list strings, we can represent
>> "/user/1" as the list ("image" "1").  From there, it's easy to use a
>> pattern matcher to match this route:
>>
>>     (match uri (("user" id) (display-user-info id)))
>>
>> From there we can get more advanced and assert various things about
>> "id" in the match expression, as 'guix publish' does with its routes.
>
> It's more proper Guile (Scheme?) idiom but it's not enough. In particular
> the code of guix publish doesn't handle various cases like
>
>   '/article/1337-diy-a-web-framework'
>
> where the split is not only done around slash. I'm not saying it's not
> possible but the solution is not that simple.

The point is that there's a language that we can express with Scheme
code, not strings, that is suitable for the domain of URI routing.  It
need not be simply using (ice-9 match), but generally speaking a
pattern matcher is what we want here.  That said, it's not true that
the above URI wouldn't work with a simple pattern matching strategy.
'guix publish' actually already has an example of this:

              ;; /<hash>.narinfo
              (((= extract-narinfo-hash (? string? hash)))
               (render-narinfo store request hash))

Where 'extract-narinfo-hash' matches a string like
"0001mfr72xdjw284dm1dw067zzylf2p0.narinfo" and extracts just the hash,
or returns #f  if the string doesn't match in which case the route
match fails.

> This is a rather scary mail which would better fit the bug report format.

Scary?  Definitely not the intent.

- Dave



      reply	other threads:[~2015-12-13 19:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-10 22:02 Fixing "stringly typed" data structures in Artanis (Was: Learning Guile web. Stuck on returning an image.) Thompson, David
2015-12-11  3:38 ` Fixing "stringly typed" data structures in Artanis Mike Gerwitz
2015-12-11  7:33 ` Fixing "stringly typed" data structures in Artanis (Was: Learning Guile web. Stuck on returning an image.) Nala Ginrut
2015-12-11 15:25   ` Christopher Allan Webber
2015-12-11 19:16     ` tomas
2015-12-11  7:53 ` tomas
2015-12-11 21:17 ` Fixing "stringly typed" data structures in Artanis Ludovic Courtès
2015-12-13 19:41 ` Amirouche Boubekki
2015-12-13 19:58   ` Thompson, David [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='CAJ=RwfYK_0dVaeFrG3pT=Zk+Xvv1fNijOB49+O3dXbuKtZpTsA@mail.gmail.com' \
    --to=dthompson2@worcester.edu \
    --cc=amirouche@hypermove.net \
    --cc=guile-user@gnu.org \
    /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).