[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fixing "stringly typed" data structures in Artanis

From: Thompson, David
Subject: Re: Fixing "stringly typed" data structures in Artanis
Date: Sun, 13 Dec 2015 14:58:20 -0500

On Sun, Dec 13, 2015 at 2:41 PM, Amirouche Boubekki
<address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]