Re: [racket-users] Defeating Racket’s separate compilation guarantee

2019-04-24 Thread WarGrey Gyoudmon Ju
Great article, thanks.

I like the logging facility, now I see it is more powerful than I known.

On Thu, Apr 25, 2019 at 6:25 AM Gustavo Massaccesi 
wrote:

> We can extract an feature request from the end of the post:
>
> Make the module that define `set` a cross-phase persistent module, so all
> the phases can share the `set`s.
>
> Gustavo
>
>
>
>
> On Sun, Apr 21, 2019 at 7:41 AM Alexis King  wrote:
>
>> Hello all,
>>
>> I just published a blog post on defeating Racket’s separate compilation
>> guarantee. While I don’t imagine such a thing is actually a good idea, I
>> think the path to getting there is interesting anyway, and it touches lots
>> of different parts of the Racket system. For those who are interested, the
>> blog post is available here:
>>
>>
>> https://lexi-lambda.github.io/blog/2019/04/21/defeating-racket-s-separate-compilation-guarantee/
>>
>> Comments welcome,
>> Alexis
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Defeating Racket’s separate compilation guarantee

2019-04-24 Thread Gustavo Massaccesi
We can extract an feature request from the end of the post:

Make the module that define `set` a cross-phase persistent module, so all
the phases can share the `set`s.

Gustavo




On Sun, Apr 21, 2019 at 7:41 AM Alexis King  wrote:

> Hello all,
>
> I just published a blog post on defeating Racket’s separate compilation
> guarantee. While I don’t imagine such a thing is actually a good idea, I
> think the path to getting there is interesting anyway, and it touches lots
> of different parts of the Racket system. For those who are interested, the
> blog post is available here:
>
>
> https://lexi-lambda.github.io/blog/2019/04/21/defeating-racket-s-separate-compilation-guarantee/
>
> Comments welcome,
> Alexis
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: Online IDE’s for Racket ?

2019-04-24 Thread Stephen Foster
Wow!  This is is cool.

Also +1 -- since I'm interested in this very topic and curious to know 
what's out there.

P.S. You probably already know about wescheme.org, right? 

On Tuesday, April 23, 2019 at 5:17:40 AM UTC-7, Stephen De Gabrielle wrote:
>
> Hi
>
> I found that you can run DrRacket on rollApp virtualisation platform[1].
>
> Are there any other online IDE’s for Racket? I’m interested in both 
> in-browser repl/editor combinations or virtualised DrRacket.
>
> Stephen
>
> [1] rollApp DrRacket free version does not permit saving. Signup required. 
> https://www.rollapp.com/app/drracket
>
> -- 
> 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Getting JSON to work with the DB module

2019-04-24 Thread David Storrs
Okay, thanks.  I wonder if this is a problem space that the sql module
could fit into?  Perhaps tag the fields with wrapper functions.

Regardless, I've found a clean way around it by looping through a smart
struct defined using the struct-plus-plus module.


#lang at-exp racket
(require struct-plus-plus db json)

(define db (sqlite3-connect #:database "test.db"))
(query-exec
 db
 @~a{CREATE TEMPORARY TABLE user (id INTEGER PRIMARY KEY,
  name TEXT NOT NULL,
  data JSON NOT NULL DEFAULT '{}')})
(query-exec db "insert into user (name, data) values ('tom jones', '[7]')")
(display "initial rows: ") (query-rows db "select * from user")
(query-exec db "delete from user")

; struct named
user

; id field is optional, defaults to #f, must be #f or
exact-positive-integer?
; name is mandatory, must be string?
; data is optional, defaults to (hash), must be both hash and jsexpr?


(struct++ user
  ([(id #f) (or/c #f exact-positive-integer?)]
   [name string?]
   [(data (hash)) (and/c hash? jsexpr?)] )
  (#:convert-for  (db (#:overwrite
(hash 'data
 (lambda (d)
   (with-output-to-string
 (thunk (write-json
d)))
   #:convert-from (db (vector? (vector id name
   (app (curryr
with-input-from-string
read-json)
data))
   (id name data
  #:transparent)
(define initial (user++ #:name "tom jones"))
(display "initial user struct: ") (println initial)
(define final (user/convert->db (set-user-data initial (hash 'phone
8675309
(display "user data for db: ")(println final)
(query-exec db
   "INSERT INTO user (name, data) VALUES ($1, $2)"
   (hash-ref final 'name) (hash-ref final 'data))
(query-rows db "select * from user")
(db->user++ (query-row db "select id, name, data FROM user"))
;;  EOF

Output:
$ racket test.rkt
initial rows: '(#(1 "tom jones" "[7]"))
initial user struct: (user #f "tom jones" '#hash())
user data for db: '#hash((data . "{\"phone\":8675309}") (id . #f) (name .
"tom jones"))
'(#(1 "tom jones" "{\"phone\":8675309}"))
(user 1 "tom jones" '#hasheq((phone . 8675309)))

On Tue, Apr 23, 2019 at 6:39 PM Ryan Culpepper  wrote:

> It is not possible, unfortunately. You must do the conversion to and
> from strings yourself.
>
> I've thought about adding a hook for additional conversions based on
> declared types, but there's no declared type information at all for
> parameters, and the declared type for results is fragile: a column name
> has a declared type but no other kind of expression does.
>
> Ryan
>
>
> On 4/23/19 20:03, David Storrs wrote:
> > tl;dr  I'm having trouble getting JSON support working in the db module
> > when using SQLite and would really appreciate some direction, or
> > confirmation that it's impossible.  I suspect that it's impossible,
> > since the docs list the accepted Racket types as exact-integer?, real?,
> > string?, and bytes?.  I was hoping that having the JSON extension in
> > would add conversion ability to this, but it looks like not.
> >
> >
> > Longer:
> > SQLite does not natively support JSON, but there's an extension that can
> > be dynamically- or statically linked. https://sqlite.org/json1.html
> >
> > When working with a Postgres database, the DB module will handle
> > transforming things (e.g. hashes) to and from JSON on insert/select,
> > which is insanely useful and convenient.  I'd like to get the same
> > behavior in SQLite, especially since that would let me use the json_agg
> > function which would be a reasonable replacement for Pg's ARAAY_AGG
> > feature, of which I make heavy use.
> >
> >
> >
> > Here's what I've done so far:
> >
> > 0. I've read the docs on the db module carefully, which has me concerned
> > about whether this is possible at all.  Still, optimism!
> > 1. I've compiled the JSON1 extension into the libsqlite.* files
> > 2. I've verified that JSON is working via the sqlite CLI client (i.e.,
> > not the Racket db module)
> > 3. I've put the libsqlite.* files in my /Applications/Racket_v7.1/lib
> > directory (one of the entries in (get-lib-search-dirs)).
> >
> > At this point I tried this:
> >
> >  > (require json db)
> >  > (define db (sqlite3-connect #:database "foo.db"))
> >  > (query db "create temporary table blogsnort (id integer primary key,
> > data json))
> > (simple-result '((insert-id . #f) (affected-rows . 0)))
> >
> >  > (query db "insert into blogsnort (data) values ($1)" (hash 'a 1))
> > ; query: cannot convert given value to SQL type
> > ;   given: '#hash((a . 1))
> > ;   type: parameter
> > ;   dialect: SQLite
> > ; [,bt fo

Re: [racket-users] Concurrent map / andmap / for-each

2019-04-24 Thread Dexter Santucci
  I'm aware, and that's what I intended to do. There's the excellent 
pmap package which uses futures, but I wanted threads for concurrency on 
one CPU. It works very well for launching processes and getting the 
returns all at once.


Dex

On 2019-04-24 6:09 p.m., Robby Findler wrote:

Thanks for working on this, but Racket's `thread` construct is not
parallel (in the sense that you will not see more than one CPU active
on your machine at a time with code that uses `thread`).

Check out places and futures for alternatives that do support parallelism.

Robby

On Wed, Apr 24, 2019 at 10:52 AM Dexter Santucci  wrote:

Hi folks,

I made concurrent (multi-threaded) versions of map, andmap and
for-each for Racket:

https://github.com/DexterLagan/pmap

Because I'm a little slow and lazy, I haven't checked packages for a
proper version.

If this isn't too much asking, can somebody give me some feedback?
The andmap implementation is naive but I haven't found a way to break a
map of threads apart from using exceptions. If anybody can suggest a
more elegant and format version, I'm all ears.

Dex

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Concurrent map / andmap / for-each

2019-04-24 Thread Robby Findler
Thanks for working on this, but Racket's `thread` construct is not
parallel (in the sense that you will not see more than one CPU active
on your machine at a time with code that uses `thread`).

Check out places and futures for alternatives that do support parallelism.

Robby

On Wed, Apr 24, 2019 at 10:52 AM Dexter Santucci  wrote:
>
> Hi folks,
>
>I made concurrent (multi-threaded) versions of map, andmap and
> for-each for Racket:
>
> https://github.com/DexterLagan/pmap
>
>Because I'm a little slow and lazy, I haven't checked packages for a
> proper version.
>
>If this isn't too much asking, can somebody give me some feedback?
> The andmap implementation is naive but I haven't found a way to break a
> map of threads apart from using exceptions. If anybody can suggest a
> more elegant and format version, I'm all ears.
>
> Dex
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Concurrent map / andmap / for-each

2019-04-24 Thread Dexter Santucci

Hi folks,

  I made concurrent (multi-threaded) versions of map, andmap and 
for-each for Racket:


https://github.com/DexterLagan/pmap

  Because I'm a little slow and lazy, I haven't checked packages for a 
proper version.


  If this isn't too much asking, can somebody give me some feedback? 
The andmap implementation is naive but I haven't found a way to break a 
map of threads apart from using exceptions. If anybody can suggest a 
more elegant and format version, I'm all ears.


Dex

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Discovery of a secret society

2019-04-24 Thread David Storrs
This is epic.  Can we get more like this?  It's giving me ideas for plot
hooks in my next novel.

On Wed, Apr 24, 2019 at 11:19 AM  wrote:

> A product has been placed in my body (resembling a gadget well known to
> the general public, but very different) that can be used to locate me,
> listen to me, etc. A Canadian company, for criminal reasons, used this
> technique to try to kill me by piercing my heart.
>
> This company has corrupted several individuals and blackmailed in order to
> recover its right to use this technology.
>
> This company is part of an international community that does not hesitate
> to condone this kind of assassination.
>
> In fact, it's a long story. For reasons that I do not know, this
> technology was put into my body about 40 years ago. At that time, I had
> just left school and was trying to get into the job market. Only questions
> and without the answers, I look like a crazy person.
>
> These are laboratories involved in international security and also dealing
> with the underground economy. It is also an extremely corrupt environment,
> and the word extremely is not exaggerated.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: db module 'query' does not return insert-id

2019-04-24 Thread David Storrs
Yep, thanks.  I've been using RETURNING pretty extensively to get not just
the ID but other fields as well.  It's ridiculously convenient.
Unfortunately, I'm migrating to SQLite now and they don't support RETURNING
so I was trying to use the simple-result struct.  I'm not sure why I used a
Pg connection in the initial email -- senior moment, I guess.

On Wed, Apr 24, 2019 at 11:24 AM Simon Schlee  wrote:

>
> > (require db)
>> > (define db (postgresql-connect  ...args...))
>> > (simple-result-info (query db "insert into collaborations (name) values
>> ('foojalskdsfls')"))
>> '((insert-id . #f) (affected-rows . 1))
>>
>
> With postgresql instead of doing a plain insert you can use returning to
> return your id:
> (assuming your collaborations table has a id field that is automatically
> initialized)
>
> > (query-row db "insert into collaborations (name) values
> ('foojalskdsfls') returning id")
>
> '#(3);; the id of your inserted row
>
>
> see returning in the postgres-documentation:
> https://www.postgresql.org/docs/9.5/sql-insert.html
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: db module 'query' does not return insert-id

2019-04-24 Thread Simon Schlee


> > (require db)
> > (define db (postgresql-connect  ...args...))
> > (simple-result-info (query db "insert into collaborations (name) values 
> ('foojalskdsfls')"))
> '((insert-id . #f) (affected-rows . 1))
>

With postgresql instead of doing a plain insert you can use returning to 
return your id:
(assuming your collaborations table has a id field that is automatically 
initialized)

> (query-row db "insert into collaborations (name) values ('foojalskdsfls') 
returning id")

'#(3);; the id of your inserted row


see returning in the postgres-documentation: 
https://www.postgresql.org/docs/9.5/sql-insert.html

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Discovery of a secret society

2019-04-24 Thread mailkior
A product has been placed in my body (resembling a gadget well known to the 
general public, but very different) that can be used to locate me, listen 
to me, etc. A Canadian company, for criminal reasons, used this technique 
to try to kill me by piercing my heart.

This company has corrupted several individuals and blackmailed in order to 
recover its right to use this technology.

This company is part of an international community that does not hesitate 
to condone this kind of assassination.

In fact, it's a long story. For reasons that I do not know, this technology 
was put into my body about 40 years ago. At that time, I had just left 
school and was trying to get into the job market. Only questions and 
without the answers, I look like a crazy person.

These are laboratories involved in international security and also dealing 
with the underground economy. It is also an extremely corrupt environment, 
and the word extremely is not exaggerated.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Question regarding the function printBoard board

2019-04-24 Thread orenpa11
Thanks

On Tuesday, April 23, 2019 at 10:12:00 PM UTC+3, Stefan Schmiedl wrote:
>
>
> "orenpa11" >, 23.04.2019, 20:53: 
>
> > Hi 
> > I am using  the functionprintBoard board  (DrRacket  Pretty Big) 
> > 
> > (printBoard  '((0 0 2 0) (0 0 0 0) (0 0 8 0) (0 0 0 0))) 
> > and the result is 
> > 
> > (0 0 2 0) 
> > (0 0 0 0) 
> > (0 0 8 0) 
> > (0 0 0 0) 
> > "" 
>
> No, it is not. The *print output* is 
> (0 0 2 0) 
> (0 0 0 0) 
> (0 0 8 0) 
> (0 0 0 0) 
> while the *return value* is the empty string "" as 
> implemented in your code. 
>
> > How do I delete the "" ? 
>
> How would you change your question given the information above? 
>
> s. 
>
> > I would like the output to be   
> > (0 0 2 0) 
> > (0 0 0 0) 
> > (0 0 8 0) 
> > (0 0 0 0) 
> > 
> > P.S. the code is 
> > 
> > (define (buildBoard n)   ;build the started board   
> >(cond ((= n 0) '()) 
> >  (else (cons '(0 0 0 0) (buildBoard (sub1 n)) 
> > 
> > (define (printBoard board) ;print the board 
> >   (cond ((empty? board) "" ) 
> > (else (writeln(first board)) 
> >  (printBoard (rest board) 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] How would you implement autoquoted atoms?

2019-04-24 Thread rocketnia
Instead of a new `#%q-expression` form, I think there's potential to use 
`#%datum` or `quote` itself for this. Potentially, the only thing that 
makes numbers (for instance) special is that the reader, printer, IDE, and 
bytecode systems already know what module(s) the number structure type(s) 
come from. As long as user-defined structure types are able to provide each 
of those systems with the same knowledge (e.g. through a structure type 
property), then they can have the same benefits.

One complication: User-defined structure types typically aren't 
interoperable across phases and module registries, the way kernel-defined, 
cross-phase persistent structure types like numbers and lists are. Even if 
we know what their module path is, that's not all the information needed, 
some of the information only "exists" once a generative `struct` definition 
has created it.

In particular, I think using `quote` on user-defined types brings up 
cross-phase difficulties: A `quote` expression is typically computed at 
phase (N + 1) for use as a constant at phase N. If we expect to be able to 
compute it at compile time using phase-(N + 1) instances of user-defined 
structure types, and if we expect to be able to process it at run time 
using phase-N instances of those types, then the `quote` operation itself 
needs to perform some kind of marshalling between those.

How to do that marshalling? Well, whatever materials we need, the structure 
type property can provide them. For instance, certain structure types might 
go through no change at all (e.g. simple procedures, perhaps). Certain 
others may do their marshalling using a (module path, identifier, data) 
intermediate stage just like Matthew Flatt and Alexis King are talking 
about. Maybe some values would even use complex higher-order marshalling 
behaviors (similar to contracts or an FFI), letting us take an object that 
uses phase-(N + 1) tools internally and wrap it up in such a way that it 
can process phase-N input and output values. And maybe some steps of the 
marshalling would use side effects, for instance to implement the interning 
zeRusski is talking about.

Whatever the technique we use for marshalling any particular structure 
type, once the marshalling has completed at phase N, we're often going to 
want a value that's compatible with the phase-N instance of the structure 
type. And that means that by the time we ever see that result value, the 
structure type must have been defined at phase N already -- which means the 
module where the `quote` appears should (at least indirectly) have a 
phase-N dependency on the module that contains that definition.

To make this work, this time it can be the structure type itself that 
"carries its own `require` at all times" (via the structure type property), 
and a `quote` implicitly acts as a `require` for all the structure types 
that appear inside it. This has a lot in common with the `#q` approach, but 
it seamlessly blends in user-defined types with core types: We can say that 
when we `quote` numbers and lists, we implicitly `require` their modules 
too, but that since those modules are part of the kernel, the `require` has 
just been imperceptible the whole time.

For types that need to be marshalled to bytecode or saved as plain text 
from a graphical editor, I agree that the (module path, identifier, data) 
format seems like a fine choice.

That said, I do want to point out that in this approach, the *bytecode* and 
*plain text* uses of (module path, identifier, data) triples would be 
subtly different from each other. In bytecode, the module path would be 
required at phase 0 (because, as far as I understand it, phase 0 is all 
that there is in the bytecode) and the construction would be performed near 
the start of the module. In plain text Racket code, that phase 0 behavior 
only happens as the *result* of compiling a `quote` form. Since `quote` 
marshals the value down one phase, it must have started out at phase 1, and 
thus we need the reader to return a phase-1 instantiation of the value.

This suggests that although we would use a reader syntax like 
`#q(module-path identifier data)` in this approach, its behavior would be 
to `require` that module path at phase 1 and perform the construction 
immediately.


On Tuesday, April 23, 2019 at 12:45:04 PM UTC-7, zeRusski wrote:
>
> (begin-for-syntax
>   (list 1 #k(foo) 2))
> ;; => ; tag: undefined;
>
> This can be solved with (require (for-syntax prelude/tags)) but as with 
> other autoquoted types I'd probably want to be able to just write them in 
> any phase. Docs say some stuff about namespaces having a scope that crosses 
> all phases plus separate scopes for each phase. Is there a way for a 
> binding to span all phases without cooperation from the user?
>

I think one thing that might help is to have #k(foo) read as:

(
  (let ()
(local-require (only-in prelude/tags tag))
tag)
  'foo)

This still supposes that `#%app`, `let`, `lo