Re: [racket-users] Application Templates!

2020-08-20 Thread James Geddes



> On 20 Aug 2020, at 18:22, Sorawee Porncharoenwase  
> wrote:
> 
> Is this intended to be something like https://docs.racket-lang.org/scaffold/? 

That also looks extremely useful!

James

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/13867585-A96B-49A9-ACEB-C824315AF71C%40gmail.com.


Re: [racket-users] Application Templates!

2020-08-20 Thread James Geddes
Just to note that I would find this sort of thing very useful. 

I have struggled to package my command-line app in a way that makes it easily 
accessible to my colleagues (a mixture of Python developers on Macs using 
homebrew and non-developers on corporate Windows systems using who knows what). 

I’ve also struggled to understand the convention organising directories within 
a package. (I think perhaps this is because the system is actually very 
flexible.) 

For me, commented examples of these would be a very helpful complement to the 
(excellent) guide and reference.

James



> On 20 Aug 2020, at 18:11, Stephen De Gabrielle  
> wrote:
> 
> Alex is right, most developers don't need this. 
> 
> The point of templates is a jumping off point for new developers, or 
> developers trying a domain they are not familiar with. 
> 
> Where possible I will be linking back to any supporting materials 
> (https://alex-hhh.github.io/2020/03/a-game-of-tetris.html thank you Alex)
> 
> As part of the working example distributing or deploying; sometimes we make 
> software for ourselves, (packages, plugins, scripts, keybindings and new raco 
> commands),
> but sometimes we make software for others; in those cases the templates need 
> to include instructions for that process
> - create the distributable executable 
> - deploy a web app (blog post by Alexis - but might make use of the 'Deploy 
> to Heroku' button)
> - Microsoft Store (help please? both x86 and ARM) 
> - App Store for mac (https://defn.io/2020/01/04/remember-internals/ thank you 
> Bogdan) and maybe iOS ( https://defn.io/2020/01/05/racket-on-ios/ )
> - packaged as a PPA for linux.
> - github actions
> - services or components in larger frameworks/applications/or os's (?)
> 
> A recent contribution is a new command extension to raco: 
> https://github.com/nixin72/from-template
> $ raco from-template  
> Philip described it 'like create-react-app, but for all sorts of Racket 
> templates' 
>  (It is currently only linux so it would be nice if a windows user could help)
> 
> A big thank you goes to Philip because it serves two purposes
> 1. It’s a raco tool for installing templates - exactly what is needed 
> 2. It is a template for adding a command to raco!
> 
> PS: I would suggest that Racket is *a lot* like dotnet core in that it is a 
> 'developer platform' (not a framework) 
> that consists of 'a runtime, a series of languages and a bunch of libraries'. 
> Mirroring https://twitter.com/shanselman/status/1288698620804362240?s=20 :
> Racket = .Net (The Ecosystem)
> bc/cs = JVM, CLR
> racket/base, racket/gui, typed/racket, datalog & others = Languages
> https://pkgs.racket-lang.org
>  = npm, maven, etc
> 
> raco
>  = dotnet cli - your entry point, SDK, driver, javac, go, etc 
> 
> raco from-template  = create-react-app, dotnet new - templates
> raco exe
>  = dotnet run - dev time compile and run
> 
> raco distribute = dotnet publish - ready up for deploy
>  
> Kind regards, 
> 
> Stephen
> 
> 
> On Thu, Aug 20, 2020 at 11:17 AM Laurent  wrote:
> Stephen's work may still be quite useful, as it provides a set of really 
> minimal (almost?) working examples that explain the specifics of various 
> tools.
> 
> I say keep it up, Stephen! 
> 
> On Thu, Aug 20, 2020 at 5:33 AM Alex Harsanyi  wrote:
> I am not sure that a template in the style of "dotnet new" is directly 
> applicable for Racket --  the .Net framework is, well a framework. which is a 
> library that expects the users to structure their own programs in certain 
> ways.  The templates fill the need of setting up the boilerplate code for 
> different kind of applications as required by the .Net framework.  Racket 
> applications don't need large amounts of "setup code", most of the code is 
> very specific to the application itself, so not sure what a template would 
> contain apart from very basic things.
> 
> I think Racket would benefit by a suite of applications which are small but 
> not trivial and with a source code which is commented in more detail than a 
> regular application.  I attempted to do this with my blog posts, some of 
> which describe more-or-less complete applications (most of them games). The 
> entire source code is in a single file which can be run directly and is 
> available as a GitHub Gist linked from the blog posts.
> 
> Here are some examples:
> 
> * ishido game (936 lines):  
> https://gist.github.com/alex-hhh/2e204b3a9d9d7094f65a0b585d0b7480 
> * tetris game (893 lines): 
> https://gist.github.com/alex-hhh/2233aee39852f4e0aead4af4cafb40d5
> * chess board (893 lines): 
> https://gist.github.com/alex-hhh/4817c4d0353e40b72108e7e753c3d0da
> * password generator GUI (346 lines): 
> https://gist.github.com/alex-hhh/6acbbb8ebca47c4cfaa2540499494af6
> * password generator, command line (142 lines): 
> https://gist.github.com/alex-hhh/27286f4609ea0c989675e5c946ca39de
> 
> These are of course not templates, but they could serve as the starting 
> points for users who already 

Re: [racket-users] Important message about meet up on 9 April (Racket London)

2020-03-16 Thread James Geddes
Stephen, All,

I think that is likely to be right. For now, I’ve kept my room booking but if 
the Turing or the British Library close, I will let you know.

James

 
> On 13 Mar 2020, at 21:39, Stephen De Gabrielle  
> wrote:
> 
> Hi All, 
> 
> While I haven't yet, I'm expecting it will be appropriate to cancel the meet 
> up on 9 April. 
> 
> Now the good news: I'm planning an 'After Work' Racket London Picnic Tuesday 
> 16 June in Kensington Gardens
> 
> Probably start at 5pm sunset is around 9:20pm 
> 
> Stephen 
> 
> -- 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CAGHj7-%2B63RS4Bb2eFVYYbNWs-DeHzWxf45GQB%2Bh3JTzYa8BoFA%40mail.gmail.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/493D593C-05D1-4305-8056-81C2B55A4439%40gmail.com.


Re: [racket-users] racket meet-up in London ?

2020-02-24 Thread James Geddes
That sounds a great idea, I am interested.

For numbers less than about 10, if it helps, I can get a meeting room in the 
Turing Institute (though I’m also happy to try a coffee shop, not that I have 
any good suggestions).

James

 

> On 24 Feb 2020, at 21:41, Stephen De Gabrielle  
> wrote:
> 
> Proposed date: Thursday 9th April 1-2pm,
> - probably at a cafe near St Pancras station. (suggestions appreciated?)
> 
> Please let me know if you are interested, even if you can’t confirm 
> attendance. I’ll take the afternoon out of my holiday leave so I can get 
> there.
> 
> (If the numbers get too big and I need to book a meeting room I think the 
> best I can get is an hour at kingscross.impacthub.net for £5.70 pp)
> 
> It will be casual introductions and chat, though if someone wants to do a 
> short talk or demo that would be most welcome.
> 
> Kind regards,
> 
> Stephen
> 
> 
> On Sun, 23 Feb 2020 at 20:56, Stephen De Gabrielle  
> wrote:
> Is anyone up for another racket meet-up in London ?
> 
> Need to work out a time and place to meet.
> 
> Kind regards
> 
> Stephen
> 
> 
> -- 
> 
> -- 
> 
> 
> -- 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CAGHj7-Ly6gn-_m5cMHrN%3DeCt_k_m1-f04MBWijrJi7LJsge%2B8A%40mail.gmail.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/6656AD88-B8A7-4E6D-8BDA-9F02E8F84A50%40gmail.com.


Re: [racket-users] Directory-specific installation of packages?

2019-07-29 Thread James Geddes
Alex, many thanks for the suggestions. 

I feel I’m putting too many obstacles in the way. (On the other hand, perhaps 
my situation is not so unusual.) I’m trying to make something work with as few 
barriers as possible, both for experienced (but non-Racket!) developers, and 
for Mac users who are still unsure about the command-line. 

> You can always create an executable (using "raco exe") and a distribution 
> (using "raco dist") which packs all dependencies in a single directory.  

This indeed was my original plan. But I worried about updates: `brew update` 
(or `raco pkg update`) are straightforward enough that people won’t balk. I 
think I can persuade people to do a one-off manual install process, but 
probably not repeated ones. 

In fact, as a first attempt I used homebrew to distribute an executable 
produced by `raco dist`. But to do this one has to go against the spirit of 
homebrew; and it’s therefore a pain to arrange.

> You could also provide a small shell script to update the PATH, which users 
> will have to run once for installation (I believe MacOS stores environment 
> variables in a plist?)

In the end, I went with the “please copy this shell command into a terminal” 
approach to have users set the PATH. Under MacOS, at least one mechanism to set 
the path is to create a file under /etc/paths.d/ whose contents are the 
required paths, so that’s what I did. (Paths set in one's bash config aren’t 
picked up by Mac GUI applications, not that that matters particularly in this 
case.) The only downside here is that the user needs to sudo the command. 

As I say, perhaps I’m just making up ad hoc objections, in which case I 
apologise. I’m reasonably happy with where I’ve ended up, though I remain 
hopeful that a more universal package manager will someday arise, perhaps along 
the lines of Nix (or Guix). 

Many thanks again,

James


-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/171A1141-3D94-43ED-93FC-722E4105CDD6%40gmail.com.


Re: [racket-users] Directory-specific installation of packages?

2019-07-28 Thread James Geddes
Tom, Stephen,

Many thanks for the advice.

In the end, I gave up on a single homebrew-able install. I could not find a way 
to have homebrew manage an app I created in Racket. During the 
homebrew-controlled installation process, Racket’s package manager tries to 
download other Racket packages; and that fails because, as Tom noted, Racket’s 
package manger needs to write to somewhere that homebrew won’t let it.

Stephen, I think bottles are indeed the way to go — but homebrew will only make 
a bottle if you can in principle compile from source. I initially tried a 
version of your other suggestion: I made a distributable executable and then 
lied to homebrew and told it this was “source code”. But I felt bad about it!

My workaround is to tell my colleagues to use homebrew to install Racket; then 
use `raco pkg` to install the app; and to specify `(define 
racket-launcher-names …)` in the info.rkt file to make an executable. 

It’s a workaround because it requires an additional step beyond this: the 
default location for such executables is not typically in one’s PATH, so my 
users have to set the PATH. For most of them that’s fine, but for some it’s not 
great.

In general, I now have the sense that there are OS-specific package managers, 
and there are language-specific package managers, and they do not play nicely 
with each other.

Racket has such a great cross-platform story; it would be nice to have a good 
“distribute your own apps” story. 

(On the question of uptake of different languages, I wonder whether part of 
Excel’s appeal might be that it supports a model in which technically 
sophisticated “spreadsheet developers" can make spreadsheets for “spreadsheet 
users”, and then distribution is straightforward; and this is a space that most 
programming languages have not yet colonised.)

Many thanks again,

James





 



> On 23 Jul 2019, at 08:43, Tom Gillespie  wrote:
> 
> I have periodically investigated installing racket packages via gentoo in a 
> dev-racket/package way that matches how python packages are installed (a far 
> saner experience than any of python's native packaging tools). I always hit 
> roadblocks because raco wants to hit an sqlite database that is outside the 
> build sandbox. I usually attempt to do this via raco, but perhaps there are 
> other ways, which might apply in this case as well. If your colleagues just 
> need the compiled program and do not need the underlying code, why not use 
> raco exe and distribute the standalone binary? Best,
> Tom
> 
> On Tue, Jul 23, 2019 at 12:17 AM Stephen De Gabrielle 
>  wrote:
> Hi James
> 
> Did you have any luck with using homebrew to package and distribute your 
> Racket program?
> 
> I thought Bottles might be the way to go but I’m not sure: 
> https://docs.brew.sh/Bottles
> 
> I have two ideas
> a) add installing racket from homebrew to a bash script that launches your 
> prog
> b) using the create executable function in DrRacket (or raco) to build a 
> stand-alone version that can be modified to distribute via homebrew
> 
> Kind regards
> 
> Stephen
> 
> PS I think this is a great idea that I’m sure others will use.
> 
> On Mon, 22 Jul 2019  at 14:05, James Geddes  wrote:
> Dear All,
> 
> For reasons (explained below, possibly foolish reasons) I am trying to do the 
> following:
> 
> 1. Have `raco pkg install` install a package X to a specific directory, 
> including, in the same directory, all of the dependencies of X, but excluding 
> those dependencies that are already present in the current installation's 
> collections; and
> 
> 2. Have `raco exe myprok.rkt` look in that custom directory for `(require X)`?
> 
> I tried the `--scope-dir` option to `raco pkg install` but that installed 
> what looks like the entire racket standard library (see below).  
> 
> Many thanks,
> 
> James
> 
> 
> 
> PS. What I'm /really/ trying to do is distribute a little command-line 
> programme that I wrote in Racket to my colleagues using the homebrew package 
> manager. My programme depends on the gregor library.
> 
> Most of my colleagues don't have Racket. Homebrew likes to compile from 
> source, so I will need to have homebrew download the dependencies I need for 
> compilation. But now, homebrew really doesn't like you to write outside a 
> very small set of directories during the installation process, and those 
> don't appear to include the standard Racket collections directories.
> 
> (I could well have misunderstood this. I don't understand at all how homebrew 
> interacts with language-specific package managers like raco, pip, cabal, and 
> so on. My sense is that the non-raco ones install dependencies in 
> project-specific directories and I suspect homebrew has specific support for 
> Python libraries.)
>

[racket-users] Directory-specific installation of packages?

2019-07-22 Thread James Geddes
Dear All,

For reasons (explained below, possibly foolish reasons) I am trying to do the 
following:

1. Have `raco pkg install` install a package X to a specific directory, 
including, in the same directory, all of the dependencies of X, but excluding 
those dependencies that are already present in the current installation's 
collections; and

2. Have `raco exe myprok.rkt` look in that custom directory for `(require X)`?

I tried the `--scope-dir` option to `raco pkg install` but that installed what 
looks like the entire racket standard library (see below).  

Many thanks,

James



PS. What I'm /really/ trying to do is distribute a little command-line 
programme that I wrote in Racket to my colleagues using the homebrew package 
manager. My programme depends on the gregor library.

Most of my colleagues don't have Racket. Homebrew likes to compile from source, 
so I will need to have homebrew download the dependencies I need for 
compilation. But now, homebrew really doesn't like you to write outside a very 
small set of directories during the installation process, and those don't 
appear to include the standard Racket collections directories.

(I could well have misunderstood this. I don't understand at all how homebrew 
interacts with language-specific package managers like raco, pip, cabal, and so 
on. My sense is that the non-raco ones install dependencies in project-specific 
directories and I suspect homebrew has specific support for Python libraries.)

Anyway, my program depends on the gregor library, so I tried this:

$ raco pkg install --scope-dir tmp gregor-lib

$ ls tmp

2d-lib pict-doc
at-exp-lib pict-lib
base   pict-snip-lib
cext-lib   pkgs.rktd
class-iop-lib  plai-lib
cldr-bcp47 planet-doc
:
[ ~100 rows omitted]
:
net-docweb-server-doc
net-libweb-server-lib
option-contract-libwxme-lib
parser-tools-doc   xrepl
parser-tools-lib   xrepl-doc
pconvert-lib   xrepl-lib
pict   zo-lib






-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/2C6D9102-2F63-4A0E-A033-C7FECC5F9CF8%40gmail.com.


Re: [racket-users] Impromptu racket meetup in London Friday, 19 July at 12pm-3pm

2019-07-12 Thread James Geddes
Given that I work inside the Library building, I will try to drop by!

(I also have a Racket sticker on my laptop. Will be there around 12:30.)

James


> On 12 Jul 2019, at 16:20, Stephen De Gabrielle  
> wrote:
> 
> Hi,
> 
> Next Friday, 19 July at 12pm-3pm there will be an impromptu Racket meetup at 
> the cafe at the British Library 'The Last Word'. 
> https://goo.gl/maps/M62e4b9JK7c1oaA69 
> 
> No agenda. All welcome. Spread the word!
> 
> I'll be drinking tea, eating cake(I hope), and will be easily identified as a 
> the man with racket logo on his laptop. Updates on this thread.
> 
> Stephen
> 
> 
> -- 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CAGHj7-%2BygW4HZEstkv-xBCsdb0eaxro8DR9QWzpkSciPbNzvhw%40mail.gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/831ED46F-E64A-4C0A-AAB3-C6BDD1B4A741%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Re: [racket-users] Thinking in scheme / racket

2019-07-11 Thread James Geddes
Dear Bob,

My sense is that there are, perhaps, two questions: first, what's the advantage 
of Racket when faced with a "prosaic computational task where ... my brain 
defaults to writing in something like C"?; and second, how to advocate for 
Racket when Python (appears to be) "quite a bit faster".

I’m interested in both of these because I am trying to understand where my 
colleagues are coming from (and possibly changing their minds).

On the first question, this discussion has perhaps produced four different 
versions of the prime-counting program:

1. Python (using a for-loop);
2. Racket (using accumulator-passing style);
3. Racket (using a for-loop);
4. Racket (using map/filter).

(Actually, I can’t find an example of (4) in the email chain, but there’s one 
at the bottom of this email.)

It’s certainly been educational for me to see all four. On reflection, do you 
still have the sense that (1) is the “most natural”? 


On the second question, let me report some rough-and-ready timings on my 
machine for counting the number of primes of the form 2^n + 3 for n < 1000 (the 
code is at the end of the email):

Python: 265 ms
Racket (filter/map version): 760 ms
Racket (for loop version): 670 ms.

My own feeling is that /for this particular application/, there's just not that 
much difference. 

I strongly suspect that all of the difference comes from the implementation of 
the primality testing functions. It turns out that, for sufficiently large 
numbers, both sympy and math/number-theory actually check for pseudoprimality. 
So there may be implementation-dependent details (which I don't understand) 
that are different, such as the probability that a composite number is 
incorrectly identified as a prime.

Indeed, maybe the answer to your second question is that, I rather suspect, 
Racket is quite a bit faster than Python, so one could reasonably turn the 
question around. 

I implemented a cheap-and-cheerful, deterministic primality test (from 
Wikipedia, code again at the end of the email). I’m pretty sure I’ve written 
essentially identical code in Python and Racket: Python using `while` and 
mutation; Racket using `for/and`. Here are the times I get for testing the 
primality of 2^55 + 3 (which is in fact prime):

Python: 7 s
Racket: 0.8 s  

Make of that what you will!

Best regards,

James




=== Python, count special primes ===

import timeit
import sympy

def count_special_primes(N):
count = 0
for n in range(N):
if sympy.isprime(2 ** n + 3):
count = count + 1
return count

print(timeit.timeit('count_special_primes(1000)', globals = globals(), number = 
1))


=== Racket, count special primes ===

#lang racket

(require math/number-theory)

;; "filter/map" variation   
;; Count primes of the form 2^n + 3 for n < N

(define (count-special-primes N)
  (define (f n) (+ (expt 2 n) 3))
  (length
   (filter prime?
   (map f (range N)

(time
 (count-special-primes 1000))

;; “for-loop" variation

(define (count-special-primes/quicker N)
  (define (f n) (+ (expt 2 n) 3))
  (for/sum ([n (in-range N)])
(if (prime? (f n)) 1 0)))

(time
 (count-special-primes/quicker 1000))


=== Python, primality test ===

Import timeit
import math

## Quick and dirty test for primality
## from https://en.wikipedia.org/wiki/Primality_test

def is_prime(n):

if n <= 3:
return (n > 1)
elif (n % 2 == 0) or (n % 3 == 0):
return False
else:
k = 5
k_max = int(math.sqrt(n)) + 1
while k < k_max:
if (n % k == 0) or (n % (k + 2) == 0):
return False
k = k + 6
return True


print(timeit.timeit('is_prime(2 ** 55 + 3)', globals = globals(), number = 1))


=== Racket, primality test ===

;; integer? -> integer? 
;; Quick-and-dirty test for primality
;; from https://en.wikipedia.org/wiki/Primality_test

(define (prime/slow? n)
  (if (<= n 3)
  (> n 1)
  (if (or (= (modulo n 2) 0)
  (= (modulo n 3) 0))
  #f
  (prime-aux n

;; Test for primality assuming n > 3 and divisible by neither
;; 2 nor 3

(define (prime-aux n)
  (let ([k-max (ceiling (sqrt n))])
(for/and ([k (in-range 5 n 6)]
  #:break (> k k-max))
  (not (or (= (modulo n k) 0)
   (= (modulo n (+ k 2)) 0))

(time (prime/slow? (+ 3 (expt 2 55




> On 11 Jul 2019, at 02:36, Bob Heffernan  wrote:
> 
> On 19-07-10 02:46, Maciek Godek wrote:
>> A while ago, I wrote a booklet which used almost the same problem to 
>> introduce to, what you called nicely in the title of this thread, "thinking 
>> in Scheme", so if you're interested, you may want to check out the first 
>> chapter ("Introduction"):
> 
> Maciek,
> 
> Thank you for your reply.
> 
> I skimmed through your booklet some time ago.  (I too dislike the R
> language, although some attempts have been made in recent years to make
> it less awful).  I read through the introduction again this morning and
> 

Re: [racket-users] Re: Thinking in scheme / racket

2019-07-11 Thread James Geddes
I am also interested in this problem, because many of my colleagues use Python 
and "isn't Python faster?" is a common argument. (Albeit one that I think is 
more of a rationalisation than an reason.)

In this case, however, I would not have thought that there's any prima facie 
reason why the Python version should be faster, even compared to the "filter 
and map" Racket version. 

Indeed, I would have thought that the calculation time would be entirely 
dominated by the test for primality, and especially what happens once the 
candidate primes are bigger than 2^64 and can no longer be represented by a 
single word.

(One possible explanation might be that the Racket math library is written in 
Typed Racket; when calling it from untyped Racket, there is some type checking 
using contracts -- it's possible, I suppose, that this is causing a performance 
penalty.) 

I am going to investigate but if anyone knows more than me I'd appreciate 
thoughts.

Regards,

James
  
 


> On 11 Jul 2019, at 02:36, Bob Heffernan  wrote:
> 
> On 19-07-10 02:46, Maciek Godek wrote:
>> A while ago, I wrote a booklet which used almost the same problem to 
>> introduce to, what you called nicely in the title of this thread, "thinking 
>> in Scheme", so if you're interested, you may want to check out the first 
>> chapter ("Introduction"):
> 
> Maciek,
> 
> Thank you for your reply.
> 
> I skimmed through your booklet some time ago.  (I too dislike the R
> language, although some attempts have been made in recent years to make
> it less awful).  I read through the introduction again this morning and
> enjoyed it.
> 
> The reason I like racket (and scheme-like languages in general) is that
> they encourage the style of programming you are advocating (I think)
> where the program is expressive and can be read and appreciated by
> humans.  In theory, my favourite style of programming is one that is
> elegant and readable by humans.
> 
> My original email had to do with the problem of when this comes into
> conflict with a prosaic computational task where my main aim is simply
> to get the job done efficiently and my brain defaults to writing the
> program in something like C.
> 
> For instance, another way of writing something like my original program
> might be something like:
> 
> (define (f n) (- (expt 2 n) 3))
> (define (good? n) (and (positive? n) (prime? n)))
> (length (filter good? (map f (range 1 100
> 
> which is, I think, fairly expressive.  It is still, however, relatively
> inefficient.  A python programmer might write something like
> 
> count = 0
> for n in range(1, 1000):
>if 2 ** n - 3 >= 0 and isprime(2 ** n - 3):
>  count += 1
> 
> print(count)
> 
> and happily report that her program ran quite a bit faster than mine.
> 
> I'm not sure how I'd advocate for Racket (or scheme) in a situation like this.
> 
> Regards,
> Bob
> 
> -- 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/20190711013633.nm2jlznhzwibhsli%40bob-cit.
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/627E56DD-D629-48D8-BF65-714D1F906AFE%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Distributing executables with homebrew

2019-06-10 Thread James Geddes
Many thanks Joel,

I do agree that `raco distribute` seems the way to go. Indeed, the setup 
described in the blog post you shared is just what I’m currently doings (so 
it’s nice to know I’m not doing something too crazy!).

What gave me pause, however, was that homebrew seems to discourage binary-only 
packages. You /can/ distribute a pre-built binary — as a “bottle” — but the 
process to create a bottle requires one to have a distributable source-code 
version first. (There are also “casks” for pre-built binaries but these seem to 
be specifically designed for MacOS GUI binaries, whereas I have a command-line 
utility.) So I feel I ought to follow that practice. 

And I am also unsure about whether Racket modules written for an application 
"should be" distributed as a Racket package. Given how much of the Racket 
tooling is around packages (scribble, dependencies), I would have thought all 
of it. So one approach to building an executable might to be to set the 
collections directory to somewhere local (I’m assuming this is doable), then 
`raco pkg install my-app`, followed by compilation of the main module. But 
then, as far as I can tell, one can’t `raco exe` a library module, only a file. 
So I’m a bit stuck there, too.

These are rather incoherent thoughts to which I don’t except an answer. But I 
will continue to try to figure out a sensible approach and report back if 
anyone else is interested.


James
  



> On 9 Jun 2019, at 21:00, 'Joel Dueck' via Racket Users 
>  wrote:
> 
> I’m no expert, but since no one else has chimed in: if you’re distributing a 
> program (vs a library) and you want it to work regardless of whether Racket 
> is installed, what you probably want is to compile your program using raco 
> distribute (https://docs.racket-lang.org/raco/exe-dist.html). Then distribute 
> the resulting binary. This will be faster for your users.
> 
> I haven’t done much with Homebrew, but maybe this would be a good place to 
> start: http://octavore.com/posts/2016/02/15/distributing-go-apps-os-x 
> 
> On Friday, June 7, 2019 at 3:59:21 AM UTC-5, james.geddes wrote:
> Dear All, 
> 
> Does anyone have experience sharing a Racket program using homebrew, for 
> users who may or may not have the Racket distribution installed? (Homebrew is 
> a popular package management system for the Mac.) 
> 
> In particular, I'd like to ensure that a certain Racket package (gregor) is 
> available but without necessarily changing the user's installation of Racket 
> if they already have one. 
> 
> (It doesn’t help that I have very little experience in distributing any kind 
> of program with homebrew.) 
> 
> If anyone has a homebrew “formula” that you would be willing to share, I’d 
> greatly appreciate taking a look! 
> 
> Many thanks, 
> 
> James 
> 
>   
> 
> 
> -- 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/06889ecc-cf38-4037-9678-413169c8d5e2%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/602099D3-2101-4C4B-9B05-413E291630FA%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Distributing executables with homebrew

2019-06-07 Thread James Geddes
Dear All,

Does anyone have experience sharing a Racket program using homebrew, for users 
who may or may not have the Racket distribution installed? (Homebrew is a 
popular package management system for the Mac.)

In particular, I'd like to ensure that a certain Racket package (gregor) is 
available but without necessarily changing the user's installation of Racket if 
they already have one. 

(It doesn’t help that I have very little experience in distributing any kind of 
program with homebrew.)

If anyone has a homebrew “formula” that you would be willing to share, I’d 
greatly appreciate taking a look!

Many thanks,

James 

  

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/95915948-B101-4697-929E-3F68FBB8BA8F%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Typed Racket segmentation fault

2019-06-05 Thread James Geddes
This is very helpful, thank you.

In fact, my "naive" version (in untyped Racket) was about the same speed as my 
colleague's naive Python version. Switching to fl+, fl-, etc bought me a 10x 
improvement (I presume from the JIT compiler avoiding boxing and unboxing?). 
Annoyingly, my colleague had got the same speedup by using Numpy, but that does 
require a change to the way one arranges the calculation (and the change is 
unnatural, to my eye).

Simply switching to Racket on Chez improved the naive version by a factor of 
5x, which was very nice to see. 

However, I'm now unsure how to continue. How should I think about making speed 
improvements? There are flvectors, for example: under what circumstances would 
these help? Should I expect more gains from TR above this, or do the gains only 
come from TR figuring out that it can use fl+ rather than me doing so?

Many thanks again,

James


  


> On 5 Jun 2019, at 17:08, Philip McGrath  wrote:
> 
> In case it's helpful as a workaround, changing the #lang line to:
> #lang typed/racket #:no-optimize
> will disable the type-based optimizations, so the problematic 
> `unsafe-make-flrectangular` isn't introduced and the segfault is avoided. You 
> presumably loose some performance, though, and "use this flag to work around 
> a compiler bug" may not be the first example you want to show your 
> colleagues—but, even without the type-based optimizations, Racket is probably 
> still faster than Python.
> 
> In case it's helpful for your colleagues, someone recently brought up this 
> direct comparison of speed benchmarks for Racket and Python 3: 
> https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/racket-python3.html
> 
> -Philip
> 
> 
> On Wed, Jun 5, 2019 at 11:46 AM Matthew Flatt  wrote:
> I had just reached the same conclusion. Specifically, it looks like a
> missing runstack sync in the JIT-inlined `unsafe-make-flrectangular`.
> 
> Thanks!
> 
> At Wed, 5 Jun 2019 11:40:41 -0400, Sam Tobin-Hochstadt wrote:
> > I think this is a miscompilation of `unsafe-make-flrectangular` by the
> > underlying Racket compiler.
> > The below program is a plain racket version of the code, with just one
> > use of unsafe, a call to `unsafe-make-flrectangular`. If that's
> > replaced with `make-flrectangular`, then the program works propetly.
> > Furthermore, if we add a print statement that requires the argument to
> > `unsafe-make-flrectangular`, then the program also works correctly.
> > The program also works correctly with the JIT off, and under RacketCS.
> > https://gist.github.com/samth/683042c4754c1c5ce284794b19dd37e3
> > 
> > On Wed, Jun 5, 2019 at 11:02 AM 'Paulo Matos' via Racket Users
> >  wrote:
> > >
> > >
> > > On 05/06/2019 16:47, Philip McGrath wrote:
> > > > What version of Racket are you using? I get a segfault in 7.2, but 7.3
> > > > works for me.
> > >
> > > I see the segfault in 7.1 but not in 7.2 or 7.3. Then I run it under
> > > valgrind and I see it in all the versions. :)
> > > It's there, but sometimes hiding.
> > >
> > > Will take a look.
> > >
> > > > -Philip
> > > >
> > > >
> > > > On Wed, Jun 5, 2019 at 10:42 AM James Geddes  > > > <mailto:james.ged...@gmail.com>> wrote:
> > > >
> > > > Dear All,
> > > >
> > > > The following Typed Racket program is intended to produce an image
> > > > of the Mandelbrot set (but it doesn't bother actually displaying the
> > > > image).
> > > >
> > > > Running the program using command-line Racket causes a crash.
> > > > Specifically, Racket terminates with the error message:
> > > >
> > > > Segmentation fault: 11
> > > >
> > > > However,
> > > >
> > > > 1. The program runs successfully in DrRacket;
> > > >
> > > > 2. Reducing the size of the image to, say, 200 x 200 (by changing
> > > > the last arguments in the calls to `make-ticks`) also results in
> > > > successful termination, without a segmentation fault.
> > > >
> > > > Any advice appreciated!
> > > >
> > > > (PS: I'm not actually that interested in making pictures. I'm trying
> > > > to do some speed benchmarks to show my colleagues, particularly
> > > > those who argue that Python is faster, and this example happened to
> > > > be on hand.)
> > > >
> > > >
> > > > James
>

Re: [racket-users] Typed Racket segmentation fault

2019-06-05 Thread James Geddes
I'm using version 7.3, amusingly.

James


> On 5 Jun 2019, at 15:47, Philip McGrath  wrote:
> 
> What version of Racket are you using? I get a segfault in 7.2, but 7.3 works 
> for me.
> -Philip
> 
> 
> On Wed, Jun 5, 2019 at 10:42 AM James Geddes  wrote:
> Dear All,
> 
> The following Typed Racket program is intended to produce an image of the 
> Mandelbrot set (but it doesn't bother actually displaying the image).
> 
> Running the program using command-line Racket causes a crash. Specifically, 
> Racket terminates with the error message: 
> 
> Segmentation fault: 11 
> 
> However,
> 
> 1. The program runs successfully in DrRacket;
> 
> 2. Reducing the size of the image to, say, 200 x 200 (by changing the last 
> arguments in the calls to `make-ticks`) also results in successful 
> termination, without a segmentation fault.
> 
> Any advice appreciated!
> 
> (PS: I'm not actually that interested in making pictures. I'm trying to do 
> some speed benchmarks to show my colleagues, particularly those who argue 
> that Python is faster, and this example happened to be on hand.) 
> 
> 
> James
> 
> 
> 
> 
> #lang typed/racket
> 
> ;; Generate an image of the Mandelbrot set 
> (https://en.wikipedia.org/wiki/Mandelbrot_set)
> 
> (define *iteration-limit* : Integer 50)
> 
> (: mandel (-> Float-Complex Integer))
> ;; Given c, iterate z <- z^2 + c starting from z = 0 until either |z| > 2 or 
> the number of iterations
> ;; exceeds *iteration-limit*. Returns the number of iterations required.
> (define (mandel c)
>   (let mandel-iter ([z 0.0+0.0i]
> [i 0])
> (if (or (>= i *iteration-limit*) (> (magnitude z) 2.0))
> i
> (mandel-iter (+ c (sqr z)) (+ i 1)
> 
> (: brot ((Listof Float) (Listof Float) -> (Listof Integer)))
> ;; Apply mandel to a rectangular grid of complex numbers
> (define (brot xs ys)
>   (for*/list : [Listof Integer]
>   ([y (in-list ys)]
>[x (in-list xs)])
> (mandel (make-rectangular x y
> 
> (: make-ticks (-> Float Float Integer (Listof Float)))
> (define (make-ticks min max resolution)
>   (range min max (/ (- max min) resolution)))
> 
> (define *xs* (make-ticks -1.5 0.5 300))
> (define *ys* (make-ticks -1.0 1.0 300))
> 
> ;; Compute a Mandelbrot image (but then discard it)
> (void (brot *xs* *ys*))
> 
> 
> 
> 
> -- 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/194F0EE9-0B9E-412B-A2C0-BCE51CD0AA75%40gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/831D8880-1BBD-4EE2-B112-61BD8E6A1020%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Typed Racket segmentation fault

2019-06-05 Thread James Geddes
Dear All,

The following Typed Racket program is intended to produce an image of the 
Mandelbrot set (but it doesn't bother actually displaying the image).

Running the program using command-line Racket causes a crash. Specifically, 
Racket terminates with the error message: 

Segmentation fault: 11 

However,

1. The program runs successfully in DrRacket;

2. Reducing the size of the image to, say, 200 x 200 (by changing the last 
arguments in the calls to `make-ticks`) also results in successful termination, 
without a segmentation fault.

Any advice appreciated!

(PS: I'm not actually that interested in making pictures. I'm trying to do some 
speed benchmarks to show my colleagues, particularly those who argue that 
Python is faster, and this example happened to be on hand.) 


James




#lang typed/racket

;; Generate an image of the Mandelbrot set 
(https://en.wikipedia.org/wiki/Mandelbrot_set)

(define *iteration-limit* : Integer 50)

(: mandel (-> Float-Complex Integer))
;; Given c, iterate z <- z^2 + c starting from z = 0 until either |z| > 2 or 
the number of iterations
;; exceeds *iteration-limit*. Returns the number of iterations required.
(define (mandel c)
  (let mandel-iter ([z 0.0+0.0i]
[i 0])
(if (or (>= i *iteration-limit*) (> (magnitude z) 2.0))
i
(mandel-iter (+ c (sqr z)) (+ i 1)

(: brot ((Listof Float) (Listof Float) -> (Listof Integer)))
;; Apply mandel to a rectangular grid of complex numbers
(define (brot xs ys)
  (for*/list : [Listof Integer]
  ([y (in-list ys)]
   [x (in-list xs)])
(mandel (make-rectangular x y

(: make-ticks (-> Float Float Integer (Listof Float)))
(define (make-ticks min max resolution)
  (range min max (/ (- max min) resolution)))

(define *xs* (make-ticks -1.5 0.5 300))
(define *ys* (make-ticks -1.0 1.0 300))

;; Compute a Mandelbrot image (but then discard it)
(void (brot *xs* *ys*))


 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/194F0EE9-0B9E-412B-A2C0-BCE51CD0AA75%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Unexpected error in output of :print-type

2019-06-05 Thread James Geddes
Dear All,

The following output from Typed Racket is unexpected -- to me! -- can someone 
confirm whether I should have expected it or that it's (perhaps) a bug or known 
limitation?


> % racket -I typed/racket
> 
> Welcome to Racket v7.3.
> 
> > (for/vector ([i (in-range 5)]) i)
> - : (Vectorof Any) [more precisely: (Mutable-Vectorof Any)]
> '#(0 1 2 3 4)
> 
> > (:print-type (for/vector ([i (in-range 5)]) i))
> ; /Applications/Racket
> ;   v7.3/share/pkgs/typed-racket-lib/typed-racket/base-env/prims.rkt:854:36:
> ;   Type Checker: type mismatch;
> ;  mutation only allowed with compatible types
> ;   expected: Zero
> ;   given: Positive-Byte
> ;   in: (set! n new-n)
> ; [,bt for context]
> > 
> 

(For what it's worth, I'm on macOS 10.14.5.)

The reason I did this at all was that I'm getting a segmentation fault in my 
Typed Racket program (but only when run via `racket` or from Emacs racket-mode, 
not when run in DrRacket). However, I'm struggling to get a minimal 
reproducible example that I can share and in trying to do so I ran into this 
one. (I will keep trying, however.)

Many thanks,

James

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/BAAD082B-539C-4BBF-B1C9-956F93A07649%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Guide and reference

2019-02-06 Thread James Geddes
Dear All,

There was a recent discussion on this list about the Racket guides and manuals. 
Without wishing to comment on the suggestions therein, I did want to say what I 
really, really like about the Racket documentation. 

There are two things. The first is that the Reference is — and I know this 
sounds odd — true: when I want to know something, I look it up in the 
Reference, and there I find the truth and the whole truth about the thing. I 
don’t know how this is made to happen, but I find it extraordinarily helpful. 
It’s not an intuitive explanation, or an analogy, or a description in vague 
language: it’s the truth. (And it’s organised very well so I know where to 
look.)

The second thing I like is the concision of the Guide. It is readable, and may 
well contain intuitive explanations and ways to think about things, yet it does 
so with economy.

There are of course things I am still confused about (packages…) but in general 
I’ve not found elsewhere this tasteful combination of clarity and completeness. 
(Well, except RnRS, so maybe my prejudices are showing through.) 

I find other languages point me to books about the language that take too long 
to get a handle on the basics; and exhaustive references that seem to contain 
both more than I want and less than I need.

Thank you to everyone who has worked on the documentation.

James



James Geddes

-- 
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] European Racketeers and conferences

2017-08-24 Thread James Geddes
I'm in London - not active on this list, but trying to work out how to promote 
Racket in my industry. (I'm building a data science team and I just struggle to 
like Python.) 

I'd be delighted if there were a European meeting, obviously the UK better for 
me but I appreciate borders are a pain. 

James

> On 24 Aug 2017, at 08:45, Marc Kaufmann  wrote:
> 
> I'm in Hungary, but regularly (3 times or more per year) travelling to 
> Germany/Benelux. I am more likely to make a meetup if it falls in an academic 
> holiday and is arranged at least 6 months in advance, given that I am 
> unlikely to travel that distance for just one meetup (even if it is, 
> admittedly, for the second best programming language).
> 
>> On Thursday, August 24, 2017 at 9:08:33 AM UTC+2, John Berry wrote:
>> I live in Finland, and will be giving a talk about Heresy, the language I 
>> built in Racket, next weekend at ClojuTRE in Tampere FI.
>> 
>> 
>> It would be interesting to see a Racketeer meetup of some kind. As much as I 
>> love the UK though, I'm not sure I would be keen on a meetup there with the 
>> way things are going. Too many horror stories about tech people and 
>> conference goers getting harassed or deported by UK border security. 
>> Apparently they think we're going to sneak in and steal all the good tech 
>> jobs. ;)
>> 
>> 
>> On Wed, Aug 23, 2017 at 3:45 PM, Matthew Eric Bassett  
>> wrote:
>> So there's at least 7 of us around UK/Germany/France/Netherlands that
>> 
>> are active on the mailing list.  What would we need at a European
>> 
>> Rackeeteers Meeting to ensure that *at least* all 7 of us would travel
>> 
>> to it ?
>> 
>> 
>> 
>> @Matthias - it'd be fantastic if we could arrange something in London or
>> 
>> Oxford.  I'm just getting back from Salone this week and wasn't planning
>> 
>> on making to ICFP, but I'll see if I can help organize something.  Can
>> 
>> you sure your itinerary ?
>> 
>> 
>> 
>> 
>> 
>>> On 08/23/2017 11:13 AM, 'Paulo Matos' via Racket Users wrote:
>>> 
>>> 
>> 
>>> 
>> 
>>> On 22/08/17 16:20, Daniel Brunner wrote:
>> 
 Hey Matthew,
>> 
 
>> 
 I live in Germany and use Racket for teaching students, teaching our
>> 
 apprentices (dual education system in Germany) and use it "in
>> 
 production" for some tasks.
>> 
 
>> 
>>> 
>> 
>>> In Germany as well - Nuernberg to be precise. I learned Racket back in
>> 
>>> version 53 - that was something around 1999. On and off for a few years
>> 
>>> and now I am using in commercially in my own company.
>> 
>>> 
>> 
>>> Happy to join a European Racket gathering.
>> 
>>> 
>> 
>>> Paulo Matos
>> 
>>> 
>> 
 Best wishes,
>> 
 Daniel
>> 
 
>> 
 Am 22.08.2017 um 15:15 schrieb Matthew Eric Bassett:
>> 
> Hi all,
>> 
> 
>> 
> Gutted I can't make it to RacketCon this year.  Really glad to see it
>> 
> growing.
>> 
> 
>> 
> Question for y'all - how many Racketeers are active on this side of the
>> 
> Atlantic?  Enough for a specific get-together over here?  Or are there
>> 
> already appropriate venues for that that I'm unaware of (I am already
>> 
> familiar with the European lisp symposium)
>> 
> 
>> 
> Best,
>> 
> 
>> 
> 
>> 
 
>> 
>>> 
>> 
>> 
>> 
>> 
>> 
>> --
>> 
>> Matthew Eric Bassett | http://mebassett.info
>> 
>> 
>> 
>> 
>> 
>> --
>> 
>> 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.

-- 
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] Help: How to check a typed/racket type in an untyped Racket contract?

2017-07-31 Thread James Geddes

Matthias,

Thank you, that's really helpful, both for letting me know I'm not being an 
idiot (always welcome!) and for the example code, which makes me realise I 
should learn about exceptions next.

Many thanks again,

James


---
James Geddes

-- 
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] Help: How to check a typed/racket type in an untyped Racket contract?

2017-07-28 Thread James Geddes
This is likely a typed-untyped interface newbie question.

Briefly, how can I write a contract that asserts that some value has a type 
that is defined in an imported typed/racket library?

In more detail, I am using the math/distributions library, which is written in 
typed/racket. My module is written in untyped Racket, and I'm figuring out how 
to use contacts:

#lang racket
(require math/distributions) ;; this is a typed/racket library

(define my-dist (discrete-dist '(thing-one thing-two)))

(provide (contract-out [my-dist ???]))


The question is: what should ??? be?. There is a distribution? predicate but 
I'd quite like to be more specific: namely, that my-dist is a discrete 
distribution. In the source of math/distributions, the following type is 
defined:

(define-type (Discrete-Dist A) (discrete-dist-struct A A))

but I don't know how this might translate into my untyped module.


Any help much appreciated!

James




---
James Geddes

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