[racket-users] Re: Boot To Racket

2017-07-08 Thread Eric Eide
William G Hatch  writes:

> I would love to see a Racket unikernel [...]  But I recall some talk about
> MirageOS (I think) where they said something about it taking something like 2
> years to rewrite the IP/TCP stack in OCaml.

I imagine it wouldn't be too hard to get Racket running atop a rump kernel or
OSv --- but I haven't tried.  It could be interesting, though, perhaps as a
step toward something even more interesting.

Surely you are right that writing everything in Racket would be a big job!

Eric.

-- 
---
Eric Eide   . University of Utah School of Computing
http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 FAX

-- 
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: Replacing multiple characters in a string?

2017-07-08 Thread Alasdair McAndrew
Thanks everybody - you've given me a lot of good ideas.  As to the Lindenmayer 
package, I did know of it.  And I am in fact exploring Lindenmayer systems from 
a very fundamental perspective, which is why I don't want to use a pre-made 
library or package, but write bits and pieces as I go.  Thanks again.

-- 
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] Boot To Racket

2017-07-08 Thread Lehi Toskin
Probably just on a Raspberry Pi, yes.

On Saturday, July 8, 2017 at 5:15:12 PM UTC-7, Deren Dohoda wrote:
> I actually use Racket in an embedded linux scenario on a 32-bit ARM. The 
> board has Debian installed but without twiddling boots under busybox. Once 
> upon a time I thought about giving a 5-minute presentation at Racketcon on 
> the experience of using Racket in this way but it never happened. It's very 
> hard to say what my hypothetical minimum requirements would be for such a 
> system without thinking of the hardware that would exist. Filesystem, 
> USB/RS232 serial/ whatever else the chip offers, and network seem like the 
> bare minimum. Are you thinking about some kind of minimal racket running on a 
> Raspberry Pi or something more abstract?
> 
> 
> Deren
> 
> 
> On Fri, Jul 7, 2017 at 8:16 PM, Lehi Toskin  wrote:
> I have this idea, this vision. I wish to create a small system that would 
> more or less only be to turn on the machine (probably an RPi) and then you'd 
> immediately be inside a Racket REPL. Probably wouldn't be very interesting by 
> itself, but that seems to be almost exactly what eLua and MicroPython are.
> 
> 
> 
> Say, for the sake of discussion, such a tiny system were created. What 
> functionality would you expect to be available? Filesystem access? 
> Networking? Or simply just the racket/base REPL and that's it?
> 
> 
> 
> --
> 
> 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...@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] Boot To Racket

2017-07-08 Thread Deren Dohoda
I actually use Racket in an embedded linux scenario on a 32-bit ARM. The
board has Debian installed but without twiddling boots under busybox. Once
upon a time I thought about giving a 5-minute presentation at Racketcon on
the experience of using Racket in this way but it never happened. It's very
hard to say what my hypothetical minimum requirements would be for such a
system without thinking of the hardware that would exist. Filesystem,
USB/RS232 serial/ whatever else the chip offers, and network seem like the
bare minimum. Are you thinking about some kind of minimal racket running on
a Raspberry Pi or something more abstract?

Deren

On Fri, Jul 7, 2017 at 8:16 PM, Lehi Toskin  wrote:

> I have this idea, this vision. I wish to create a small system that would
> more or less only be to turn on the machine (probably an RPi) and then
> you'd immediately be inside a Racket REPL. Probably wouldn't be very
> interesting by itself, but that seems to be almost exactly what eLua and
> MicroPython are.
>
> Say, for the sake of discussion, such a tiny system were created. What
> functionality would you expect to be available? Filesystem access?
> Networking? Or simply just the racket/base REPL and that's it?
>
> --
> 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] Replacing multiple characters in a string?

2017-07-08 Thread William G Hatch

Or, arguably, not Rackety enough, until it's possible to embed one #lang within 
another (submodules at least, but hey why not lambdas?)


I've been exploring this more and more.  It is related to my shell
project (rash, which does allow embedding at the expression level), and
I've been thinking about it a lot in relation to other things I want to
do or have otherwise been considering.  Some time soon I'll have to
write up my thoughts on the subject.

--
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] Boot To Racket

2017-07-08 Thread William G Hatch

I would love to see a Racket unikernel, and be able to essentially run a
modern Lisp machine.  That seems like a really big project, but I guess
I have no real understanding of how big it would be, or what parts you
could use off the shelf (eg. from OS-kit.  I understand this was done
before in Racket some years ago).  But I recall some talk about MirageOS
(I think) where they said something about it taking something like 2
years to rewrite the IP/TCP stack in OCaml.

But whatever the timeline I would *love* to see it.

On Fri, Jul 07, 2017 at 06:19:52PM -0700, Lehi Toskin wrote:

Well there is the racket-rash project[1]. So you're thinking of more a *NIX 
environment inside the REPL?


Just FYI, Rash is near the end of a major rewrite, so the documentation
that is up (what there is of it) is all wrong, and the language is very
different now.  But it does aim to do everything that a unix shell (eg.
bash) does, as well as much more, embeddable in any Racket program at
the expression or module level (also you can escape to normal Racket,
embedding any normal Racket code inside Rash).  Also eventually I hope
to have a nicer interactive repl with completion, etc, as half of the
purpose is to have a better interactive shell environment.  But the
language part is close to being more or less done.

If someone did make a Racket unikernel, I suppose the parts for running
Unix (or Windows, if you're into that kind of thing) programs and
pipelining them wouldn't work on it.  But pipelines of Racket functions
would still work normally.

--
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] Boot To Racket

2017-07-08 Thread Lehi Toskin
That's an interesting project. It's a little too inclusive, so to speak, for 
what I was thinking of implementing.

On Friday, July 7, 2017 at 7:33:32 PM UTC-7, Neil Van Dyke wrote:
> I've made a boot-to-Racket-app appliance image for x86 before, based on 
> Debian Live.  The bootable filesystem image was under 400 MB, including 
> Linux, X, Racket, various other native programs and libraries, and the 
> app itself.
> 
> It would boot to a full-screen display that would display a hostname or 
> IP address at which you should point your smartphone/tablet/laptop Web 
> browser, to get a remote control UI "HTML5 mobile app".  But I could 
> also have had it run "racket" REPL or DrRacket rather than the app.
> 
> (This appliance was going to be an example for my abandoned book, but I 
> did release a few independently reusable Racket packages from it, in 
> keeping with the methodology the book was to promote.)
> 
> One clean way to implement boot-to-Racket is with the "build-lildeb" 
> script of an earlier GNU/Linux distro -- one script file shows and 
> implements all the changes made to strip down and customize Debian 
> Live.  There's also an "update-lildeb" flashing script, which goes to a 
> lot of trouble to tweak the partition table of the flashed device.
> http://www.neilvandyke.org/lildeb/
> 
> If you want something smaller than a stripped-down Debian, there's 
> OpenWrt.  There are signs that someone unknown once put considerable 
> work into getting Racket to run on hardware architectures like some 
> small OpenWrt devices have, because Racket REPL came up a little too 
> easily once I got OpenWrt building working.  The OpenWrt package for 
> Racket turned out to be less than 6 MB, though the bigger concern is the 
> runtime RAM footprint.  I didn't test this much.
> http://www.neilvandyke.org/racket-openwrt/
> 
> There's also various other projects for embedded Linux.  Some of them 
> get into messier and more questionable toolchains, and can involve a lot 
> more work and sometimes sketchy provenance. Personally, if your target 
> hardware is even a modest, well-supported x86 or ARM device (not 
> something very small or strange), I'd probably start with Debian Live 
> (probably copying and modifying my "build-lildeb" script), and see how 
> that works.
> 
> Or you could just have instructions (or a script) for how to modify a 
> stock Debian, Raspian, Arch, etc. install to boot-to-Racket, in a manner 
> of speaking.

-- 
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] Replacing multiple characters in a string?

2017-07-08 Thread Robby Findler
Keep reading?

#lang lindenmayer racket

## axiom ##
ABCABC

## rules ##
A -> AC
B -> BA
C -> CCA

## variables ##
n=1


(provide A B C start finish)
(define (finish l vars) (writeln l))
(define (A s vars) (cons 'A s))
(define (B s vars) (cons 'B s))
(define (C s vars) (cons 'C s))
(define (start var) '())




On Sat, Jul 8, 2017 at 2:38 PM, Matthew Butterick  wrote:
>
>
>> On Jul 8, 2017, at 7:15 AM, Robby Findler  
>> wrote:
>>
>> Below is another approach that may be too much Rackety for your taste:  :)
>>
>> http://docs.racket-lang.org/lindenmayer/
>
> Or, arguably, not Rackety enough, until it's possible to embed one #lang 
> within another (submodules at least, but hey why not lambdas?)
>
> --
> 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] Replacing multiple characters in a string?

2017-07-08 Thread Matthew Butterick


> On Jul 8, 2017, at 7:15 AM, Robby Findler  wrote:
> 
> Below is another approach that may be too much Rackety for your taste:  :)
> 
> http://docs.racket-lang.org/lindenmayer/
 
Or, arguably, not Rackety enough, until it's possible to embed one #lang within 
another (submodules at least, but hey why not lambdas?)

-- 
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] Replacing multiple characters in a string?

2017-07-08 Thread David Storrs
I'd probably do this:

(apply string-append
  (for/list ((letter (string->list str)))
 (cond [(equal? letter #\A) "AC"]
   [(equal? letter #\B) "BA"]
   [(equal? letter #\C) "CCA"])))

-- 
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] Replacing multiple characters in a string?

2017-07-08 Thread Robby Findler
Below is another approach that may be too much Rackety for your taste:  :)

http://docs.racket-lang.org/lindenmayer/

Robby


#lang lindenmayer

## axiom ##
ABCABC

## rules ##
A -> AC
B -> BA
C -> CCA

## variables ##
n=1

-- 
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] Replacing multiple characters in a string?

2017-07-08 Thread Philip McGrath
This works, for instance (and I would much prefer case to hash-ref):

#lang typed/racket

(regexp-replace* #rx"[ABC]"
 "ABCABC"
 (λ ([c : String] . _)
   (case c
 [("A") "AC"]
 [("B") "BA"]
 [("C") "CCA"]
 [else (error 'bad-match c)])))

-Philip

On Sat, Jul 8, 2017 at 8:14 AM, Alasdair McAndrew  wrote:

> Many thanks - that works fine!  And it makes sense, to use regexp-replace*
> with a hash table.  (All these things I'm still finding out...)  Is it
> possible to do this - or something similar - in Typed Racket?
>
> On Saturday, 8 July 2017 22:45:04 UTC+10, Neil Van Dyke  wrote:
> > This is one OK way that people are likely to do:
> >
> >
> > #lang racket/base
> >
> > (define (foo str)
> >(regexp-replace* #rx"[ABC]"
> > str
> >(lambda (s)
> >  (hash-ref #hash(("A" . "AC")
> >  ("B" . "BA")
> >  ("C" . "CCA"))
> >s
> >
> > (module+ test
> >(require rackunit)
> >(check-equal? (foo "") "")
> >(check-equal? (foo "ABCABC")   "ACBACCAACBACCA")
> >(check-equal? (foo "ABCDABCD") "ACBACCADACBACCAD"))
> >
> >
> > It's not necessarily the most maintainable (note the duplicated info
> > between the regexp and the map) nor most efficient, but it's OK, IMHO.
>
> --
> 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] Replacing multiple characters in a string?

2017-07-08 Thread Alasdair McAndrew
Many thanks - that works fine!  And it makes sense, to use regexp-replace* with 
a hash table.  (All these things I'm still finding out...)  Is it possible to 
do this - or something similar - in Typed Racket?

On Saturday, 8 July 2017 22:45:04 UTC+10, Neil Van Dyke  wrote:
> This is one OK way that people are likely to do:
> 
> 
> #lang racket/base
> 
> (define (foo str)
>(regexp-replace* #rx"[ABC]"
> str
>(lambda (s)
>  (hash-ref #hash(("A" . "AC")
>  ("B" . "BA")
>  ("C" . "CCA"))
>s
> 
> (module+ test
>(require rackunit)
>(check-equal? (foo "") "")
>(check-equal? (foo "ABCABC")   "ACBACCAACBACCA")
>(check-equal? (foo "ABCDABCD") "ACBACCADACBACCAD"))
> 
> 
> It's not necessarily the most maintainable (note the duplicated info 
> between the regexp and the map) nor most efficient, but it's OK, IMHO.

-- 
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] Replacing multiple characters in a string?

2017-07-08 Thread Neil Van Dyke

This is one OK way that people are likely to do:


#lang racket/base

(define (foo str)
  (regexp-replace* #rx"[ABC]"
   str
  (lambda (s)
(hash-ref #hash(("A" . "AC")
("B" . "BA")
("C" . "CCA"))
  s

(module+ test
  (require rackunit)
  (check-equal? (foo "") "")
  (check-equal? (foo "ABCABC")   "ACBACCAACBACCA")
  (check-equal? (foo "ABCDABCD") "ACBACCADACBACCAD"))


It's not necessarily the most maintainable (note the duplicated info 
between the regexp and the map) nor most efficient, but it's OK, IMHO.


--
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] Replacing multiple characters in a string?

2017-07-08 Thread Alasdair McAndrew
Suppose I have a string "ABCABC" and I want to replace all A's with "AC", all 
B's with "BA" and all C's with "CCA", so that the result is

ACBACCAACBACCA

What is the canonical way of doing this in Racket?  

-- 
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] Contracts in interrelated signatures

2017-07-08 Thread Philip McGrath
Working through the chapter on units in the Racket guide, it shows how to
translate the comment-specified contracts on toy-factory^ to enforced
contracts:

(define-signature contracted-toy-factory^
  ((contracted
[build-toys (-> integer? (listof toy?))]
[repaint(-> toy? symbol? toy?)]
[toy?   (-> any/c boolean?)]
[toy-color  (-> toy? symbol?)])))


I am trying to figure out how you would create an analogous
contracted-toy-store^ from the example toy-store^:

(define-signature toy-store^
  (store-color ; (-> symbol?)
   stock!  ; (integer? -> void?)
   get-inventory)) ; (-> (listof toy?))


The complication here is that the contract for get-inventory needs to have
a binding for toy?, which implicitly comes from the toy-factory^ signature.

Ultimately what I'm trying to do is to create mutually dependent units
along the lines of store-specific-factory@ from the linking example, but
where the factory could rely on the results of get-inventory being toys
according to its notion of toy?, as created by build-toys.

I have the sense that open or extends might be part of the answer, but, if
they are what I need to use, I haven't figured out how to use them properly
yet.

Thanks,
Philip

-- 
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.