[racket-users] Starting a language after Beautiful Racket

2020-04-10 Thread Pratyush Das
I am absolutely new to both Racket and language implementation.

I read through some portions of Beautiful Racket 
 and the racket guide 
 before trying to 
implement a language on my own and this is what I understand - 

I created a main.rkt which would be the boot module in my source directory, 
following the Beautiful Racket master recipe 
.

Every language should define and provide a read-syntax function. 

To make the new language read the source file, read-syntax must be defined 
something like - 
(define (read-syntax path port)
...)

Like in Beautiful Racket's wires language implementation 
, I want to read the source 
file line by line and wrap it in a macro. 
Beautiful Racket does it like this - 

  (define 

 (read-syntax 

 path port)(define 

 wire-datums  (for/list 

 ([wire-str (in-lines 

 port)])(format-datum 

 '(wire ~a) wire-str)))


But this assumes that the br lang is being used(I think because of the 
format-datum syntax). How do I implement this without using the br lang?

Also, am I wrong in any of my assumptions so far?


-- 
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/180aae4b-9e79-43cc-9177-6c917acf0dc8%40googlegroups.com.


[racket-users] [re: opengl] Is this known Racket syntax?

2020-04-10 Thread Hendrik Boom
I'm building the new opengl binding for Racket, and keep running
into surprises.

Most of them are straightforward, but tedious, but I run into
something strange.  It's a piece of syntax in the original
(presumably) corrent, but obsolete, binding -- specifically,
 a strange type.

I thought I should ask before blundering through with it.

Here's the definition for glAreProgramsResidentNV as present in
the existing binding:


(define-gl glAreProgramsResidentNV 2 ((n : _int32) (programs : (_u32vector i)) 
(residences : (_vector o _bool n)) -> (result : _bool) -> (values result 
residences)) (->> exact-integer? u32vector? (values boolean? (vectorof 
boolean?))) check-gl-error)


Now normally the define-gl macro seems to take
a number,
a type of the function (containing names for the parameters
in the style of typed Racket's lambda arguments), and
another type to put in the documentation.

Now the type of the function here is
((n : _int32) (programs : (_u32vector i)) (residences : (_vector o _bool n)) -> 
(result : _bool) -> (values result residences))

An ordinary enough looking type except that -> occurs twice.

**: Is this a known Racket construct?

Or is it something peculiar to define-gl, which I'll just have
to figure out as I build the new opengl binding.  It's presumably
related to the fact that the 'residences' parameter is for output.

-- hendrik


In case anyone is interested, here are the relevant
machine-readable bits from the nes and the old Khronos API specifications


The xml specfile entry for this is:


GLboolean 
glAreProgramsResidentNV
GLsizei n
const GLuint 
*programs
GLboolean 
*residences




And here's the old specfile entry from the old Khronos opengl standard:

AreProgramsResidentNV(n, programs, residences)
return  Boolean
param   n   SizeI in value
param   programsUInt32 in array [n]
param   residences  Boolean out array [n]
categoryNV_vertex_program
dlflags notlistable
version 1.2
extension   soft WINSOFT NV10
glxflagsignore
glxvendorpriv   1293
offset  578


-- 
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/20200410140217.b4e5xizymwunvyu6%40topoi.pooq.com.


Re: [racket-users] [re: opengl] Is this known Racket syntax?

2020-04-10 Thread Jay McCarthy
This comes from _fun, which define-gl expands to,

https://docs.racket-lang.org/foreign/foreign_procedures.html#%28form._%28%28lib._ffi%2Funsafe..rkt%29.__fun%29%29

The first -> is a type spec for the C function's return type and the
second -> is the output expression that is what the Racket wrapper
will return.

Jay

--
Jay McCarthy
Associate Professor @ CS @ UMass Lowell
http://jeapostrophe.github.io
Vincit qui se vincit.

On Fri, Apr 10, 2020 at 10:02 AM Hendrik Boom  wrote:
>
> I'm building the new opengl binding for Racket, and keep running
> into surprises.
>
> Most of them are straightforward, but tedious, but I run into
> something strange.  It's a piece of syntax in the original
> (presumably) corrent, but obsolete, binding -- specifically,
>  a strange type.
>
> I thought I should ask before blundering through with it.
>
> Here's the definition for glAreProgramsResidentNV as present in
> the existing binding:
>
>
> (define-gl glAreProgramsResidentNV 2 ((n : _int32) (programs : (_u32vector 
> i)) (residences : (_vector o _bool n)) -> (result : _bool) -> (values result 
> residences)) (->> exact-integer? u32vector? (values boolean? (vectorof 
> boolean?))) check-gl-error)
>
>
> Now normally the define-gl macro seems to take
> a number,
> a type of the function (containing names for the parameters
> in the style of typed Racket's lambda arguments), and
> another type to put in the documentation.
>
> Now the type of the function here is
> ((n : _int32) (programs : (_u32vector i)) (residences : (_vector o _bool n)) 
> -> (result : _bool) -> (values result residences))
>
> An ordinary enough looking type except that -> occurs twice.
>
> **: Is this a known Racket construct?
>
> Or is it something peculiar to define-gl, which I'll just have
> to figure out as I build the new opengl binding.  It's presumably
> related to the fact that the 'residences' parameter is for output.
>
> -- hendrik
>
>
> In case anyone is interested, here are the relevant
> machine-readable bits from the nes and the old Khronos API specifications
>
>
> The xml specfile entry for this is:
>
> 
> GLboolean 
> glAreProgramsResidentNV
> GLsizei n
> const GLuint 
> *programs
> GLboolean 
> *residences
> 
> 
>
>
> And here's the old specfile entry from the old Khronos opengl standard:
>
> AreProgramsResidentNV(n, programs, residences)
> return  Boolean
> param   n   SizeI in value
> param   programsUInt32 in array [n]
> param   residences  Boolean out array [n]
> categoryNV_vertex_program
> dlflags notlistable
> version 1.2
> extension   soft WINSOFT NV10
> glxflagsignore
> glxvendorpriv   1293
> offset  578
>
>
> --
> 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/20200410140217.b4e5xizymwunvyu6%40topoi.pooq.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/CAJYbDakT1AXhd7zBK%2BHQ%2B5-z6RnkoHj__xxyGAD6vDXt21mWrA%40mail.gmail.com.


Re: [racket-users] [re: opengl] Is this known Racket syntax?

2020-04-10 Thread Hendrik Boom
On Fri, Apr 10, 2020 at 10:05:34AM -0400, Jay McCarthy wrote:
> This comes from _fun, which define-gl expands to,
> 
> https://docs.racket-lang.org/foreign/foreign_procedures.html#%28form._%28%28lib._ffi%2Funsafe..rkt%29.__fun%29%29
> 
> The first -> is a type spec for the C function's return type and the
> second -> is the output expression that is what the Racket wrapper
> will return.

Thank you.  I thought it would be something like that, but it helps a lot
to have a precise specification, which I found now that you indicated
where I should look:
https://docs.racket-lang.org/foreign/foreign_procedures.html

-- hendrik
> 
> Jay
> 
> --
> Jay McCarthy
> Associate Professor @ CS @ UMass Lowell
> http://jeapostrophe.github.io
> Vincit qui se vincit.
> 
> On Fri, Apr 10, 2020 at 10:02 AM Hendrik Boom  wrote:
> >
> > I'm building the new opengl binding for Racket, and keep running
> > into surprises.
> >
> > Most of them are straightforward, but tedious, but I run into
> > something strange.  It's a piece of syntax in the original
> > (presumably) corrent, but obsolete, binding -- specifically,
> >  a strange type.
> >
> > I thought I should ask before blundering through with it.
> >
> > Here's the definition for glAreProgramsResidentNV as present in
> > the existing binding:
> >
> >
> > (define-gl glAreProgramsResidentNV 2 ((n : _int32) (programs : (_u32vector 
> > i)) (residences : (_vector o _bool n)) -> (result : _bool) -> (values 
> > result residences)) (->> exact-integer? u32vector? (values boolean? 
> > (vectorof boolean?))) check-gl-error)
> >
> >
> > Now normally the define-gl macro seems to take
> > a number,
> > a type of the function (containing names for the parameters
> > in the style of typed Racket's lambda arguments), and
> > another type to put in the documentation.
> >
> > Now the type of the function here is
> > ((n : _int32) (programs : (_u32vector i)) (residences : (_vector o _bool 
> > n)) -> (result : _bool) -> (values result residences))
> >
> > An ordinary enough looking type except that -> occurs twice.
> >
> > **: Is this a known Racket construct?
> >
> > Or is it something peculiar to define-gl, which I'll just have
> > to figure out as I build the new opengl binding.  It's presumably
> > related to the fact that the 'residences' parameter is for output.
> >
> > -- hendrik
> >
> >
> > In case anyone is interested, here are the relevant
> > machine-readable bits from the nes and the old Khronos API specifications
> >
> >
> > The xml specfile entry for this is:
> >
> > 
> > GLboolean 
> > glAreProgramsResidentNV
> > GLsizei n
> > const GLuint 
> > *programs
> > GLboolean 
> > *residences
> > 
> > 
> >
> >
> > And here's the old specfile entry from the old Khronos opengl standard:
> >
> > AreProgramsResidentNV(n, programs, residences)
> > return  Boolean
> > param   n   SizeI in value
> > param   programsUInt32 in array [n]
> > param   residences  Boolean out array [n]
> > categoryNV_vertex_program
> > dlflags notlistable
> > version 1.2
> > extension   soft WINSOFT NV10
> > glxflagsignore
> > glxvendorpriv   1293
> > offset  578
> >
> >
> > --
> > 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/20200410140217.b4e5xizymwunvyu6%40topoi.pooq.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/CAJYbDakT1AXhd7zBK%2BHQ%2B5-z6RnkoHj__xxyGAD6vDXt21mWrA%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/20200410141711.ccfbktgqalzidp6j%40topoi.pooq.com.


Re: [racket-users] [re: opengl] Is this known Racket syntax?

2020-04-10 Thread Hendrik Boom
On Fri, Apr 10, 2020 at 10:17:12AM -0400, Hendrik Boom wrote:
> On Fri, Apr 10, 2020 at 10:05:34AM -0400, Jay McCarthy wrote:
> > This comes from _fun, which define-gl expands to,
> > 
> > https://docs.racket-lang.org/foreign/foreign_procedures.html#%28form._%28%28lib._ffi%2Funsafe..rkt%29.__fun%29%29
> > 
> > The first -> is a type spec for the C function's return type and the
> > second -> is the output expression that is what the Racket wrapper
> > will return.
> 
> Thank you.  I thought it would be something like that, but it helps a lot
> to have a precise specification, which I found now that you indicated
> where I should look:
> https://docs.racket-lang.org/foreign/foreign_procedures.html
> 
> -- hendrik

This is getting far more complicated than I suspected a while ago when
I naively asked to have the opengl binding updated!

I'm starting to understand why it hadn't been.

I'm debugging by using diff to compare the old generated binding with my
new one.  The only differences should be things that have changed and
things that have been added.

I'm not yet seeing light at the end of the tunnel, but I hope to soon.

-- hendrik

-- 
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/20200410142645.wevg7oqbmio6nhrk%40topoi.pooq.com.


Re: [racket-users] Starting a language after Beautiful Racket

2020-04-10 Thread Pratyush Das
A followup question -

But this assumes that the br lang is being used(I think because of the
> format-datum syntax). How do I implement this without using the br lang?


...

(define 

src-lines (port->lines

port))
  (define 

src-datums (format-datums

'(handle ~a) src-lines))

...


Is it possible to use modules to just get the format-datums from the br
language?


On Fri, 10 Apr 2020 at 17:50, Pratyush Das  wrote:

> I am absolutely new to both Racket and language implementation.
>
> I read through some portions of Beautiful Racket
>  and the racket guide
>  before trying to
> implement a language on my own and this is what I understand -
>
> I created a main.rkt which would be the boot module in my source
> directory, following the Beautiful Racket master recipe
> .
>
> Every language should define and provide a read-syntax function.
>
> To make the new language read the source file, read-syntax must be defined
> something like -
> (define (read-syntax path port)
> ...)
>
> Like in Beautiful Racket's wires language implementation
> , I want to read the source
> file line by line and wrap it in a macro.
> Beautiful Racket does it like this -
>
>   (define 
> 
>  (read-syntax 
> 
>  path port)(define 
> 
>  wire-datums  (for/list 
> 
>  ([wire-str (in-lines 
> 
>  port)])(format-datum 
> 
>  '(wire ~a) wire-str)))
>
>
> But this assumes that the br lang is being used(I think because of the
> format-datum syntax). How do I implement this without using the br lang?
>
> Also, am I wrong in any of my assumptions so far?
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Racket Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/racket-users/qEXz8YcAisc/unsubscribe.
> To unsubscribe from this group and all its topics, 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/180aae4b-9e79-43cc-9177-6c917acf0dc8%40googlegroups.com
> 
> .
>


-- 
Pratyush Das(Reik)

-- 
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/CAFzLTskQ70okYZj247VA2rGNWyoW62wCyyu3jqXHtzZdw3aJEg%40mail.gmail.com.


[racket-users] ports->ssl-ports issues, plus DTLS question

2020-04-10 Thread David Storrs
We are trying to use TLS (or, more specifically, DTLS) over UDP.  In order
to do this we create an input-port?/output-port? pair via make-pipe and
then run the pair through ports->ssl-ports.  The handshake this causes is
failing and therefore the whole process hangs and the ports don't get
converted.  We have a couple questions:

1) Does the Racket openssl library (i.e. (require openssl)) implement DTLS?

2) What might be causing the failure?  (Hopefully) minimal code is below;
we have been banging our heads on it and could use some advice.


; Pseudo code, simplified from live code and not tested

(define server-ctx (ssl-make-server-context 'tls12))
(ssl-load-certificate-chain!  server-ctx pem)
(ssl-load-private-key!server-ctx pem)
(ssl-server-context-enable-ecdhe! server-ctx 'secp521r1)

(define client-ctx (ssl-make-client-context 'tls12))
(ssl-set-ciphers! client-ctx "ECDHE-RSA-AES128-SHA256")

(define rx-in-ch  (make-async-channel))
(define sock (udp-open-socket))
(udp-bind! sock ...)

(define-values (rx-in1 rx-out1) (make-pipe size))
(define-values (tx-in1 tx-out1) (make-pipe size))

(define-values (rx-in tx-out)
   (ports->ssl-ports rx-in1 tx-out1
#:mode   'accept
#:contextserver-ctx
#:close-original?#t
#:shutdown-on-close? #t))

; the 'connect version is elided for brevity



;;;  Rx
; sync on the UDP socket.  When data is received, async-channel-put it onto
rx-in-ch.
; sync on rx-in-ch.  When data is received, write it onto rx-out port from
make-pipe
; sync on rx-in port from make-pipe.  When data is received it will be
processed by a handler function

;;; Tx
; the handler function writes to tx-out
; sync on tx-in.  When data is received, a handler will udp-send-to onto
the UDP socket

-- 
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/CAE8gKocmTjS6s9WD_LfiOD4cMPNg4MwXybKR%3DhjYETg%3D7z2m1g%40mail.gmail.com.


[racket-users] Re: Are there interfaces for IP ports at least raw sockets?

2020-04-10 Thread Ray Racine


On Thursday, April 9, 2020 at 4:52:31 PM UTC-4, Tony Garnock-Jones wrote:
>
> If you've not already seen and considered it, 
> https://github.com/tonyg/racket-packet-socket might be worth a look.
>
> Regards,
> Tony
>

Appropriate moment to give Syndicate some of the attention level it 
deserves Racket land, if you have ever wondered "gee what would an entire 
network stack look like in Racket" spending some COVID-19 down time 
scanning through Tony's implementation in Syndicate is worthwhile.

https://syndicate-lang.org/

-- 
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/23f0acca-ea87-4f0b-be9a-94b0062ba642%40googlegroups.com.


[racket-users] Re: Organizing tests in project

2020-04-10 Thread Siddhartha Kasivajhula
Hi, I'm still seeing an error
 on the Racket package
server, but the build output is from March 31, 2019
 and
doesn't seem to be showing updated output. I gather that the server builds
packages nightly -- any idea why it hasn't rebuilt yet? Or if it has, is
there a way to get updated error output?



On Mon, Apr 6, 2020 at 3:27 PM Siddhartha Kasivajhula 
wrote:

> FTR I fixed this by using the `compile-omit-paths` flag:
> https://docs.racket-lang.org/raco/setup-info.html
> E.g. in info.rkt:
>
> (define compile-omit-paths '("tests"))
>
>
>
>
> On Tue, Mar 17, 2020 at 12:25 PM Siddhartha Kasivajhula <
> skasi...@gmail.com> wrote:
>
>> Hi,
>> I'm attempting to organize tests in my package into subfolders/modules
>> instead of having them in a giant main.rkt test submodule, but am running
>> into some issues and was hoping for some advice on the best way to do it. I
>> think the primary issue is related to source compilation order in raco, but
>> am also curious how other people organize their tests.
>>
>> I've moved all of the tests into a tests/ subfolder in the main project
>> tree. When I build the project using raco setup, it builds both the
>> project files as well as the tests contained in the tests/ folder. At this
>> point, if I run the tests as is, they result in an error. If instead I
>> first delete the compiled/ subfolder in the tests folder, the tests then
>> work fine.
>>
>> I think the tests may be getting compiled against the version of the
>> compiled collection which is immediately replaced by a fresh compilation
>> during raco setup. This is the error I'm seeing when I run the tests:
>>
>> default-load-handler: expected a `module' declaration, but found
>> something else
>>   file:
>> /Users/siddhartha/work/lisp/racket/relation/tests/compiled/algebraic-test_rkt.dep
>>   context...:
>>default-load-handler
>>standard-module-name-resolver
>>module-path-index-resolve
>>module-declared?
>>
>> I could add a make target to clean the test compiled folder prior to
>> running tests, but it seemed like there must be a better way. So my main
>> questions are:
>>
>> 1. Is there a way to exclude certain folders (such as tests) in the raco
>> setup stage? For reference, the command I'm using is raco setup
>> --no-docs --tidy --pkgs relation.
>> 2. Is this a good way to organize tests? Are there any standard
>> recommended ways?
>>
>> Would appreciate any input,
>> -Sid
>>
>>

-- 
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/CACQBWF%3DJDzWWhQSQPPx8Yu0v9zTYyQ%3DiGwJhH2r3kYqzEZuj9g%40mail.gmail.com.


Re: [racket-users] Starting a language after Beautiful Racket

2020-04-10 Thread Matthew Butterick
Three options:

1) Implement your language in `#lang br` now (and optionally convert to 
`racket/base` later) [1]

2) Import the `br/datum` module into a `#lang racket/base` program to get 
`format-datum` [2]

3) Reimplement `format-datum` your own way. You can see the underlying code by 
right-clicking on `format-datum` in DrRacket and selecting "Open Defining File".

[1] https://beautifulracket.com/appendix/from-br-to-racket-base.html
[2] 
https://docs.racket-lang.org/br/index.html?q=br%2Fdatums#%28mod-path._br%2Fdatum%29

> On Apr 10, 2020, at 9:17 AM, Pratyush Das  wrote:
> 
> A followup question - 
> 
> But this assumes that the br lang is being used(I think because of the 
> format-datum syntax). How do I implement this without using the br lang?
> 
> ...
> (define 
> 
>  src-lines (port->lines 
> 
>  port))
>   (define 
> 
>  src-datums (format-datums 
> 
>  '(handle ~a) src-lines))
> ...
> 
> Is it possible to use modules to just get the format-datums from the br 
> language? 
> 
> 
> On Fri, 10 Apr 2020 at 17:50, Pratyush Das  > wrote:
> I am absolutely new to both Racket and language implementation.
> 
> I read through some portions of Beautiful Racket 
>  and the racket guide 
>  before trying to 
> implement a language on my own and this is what I understand - 
> 
> I created a main.rkt which would be the boot module in my source directory, 
> following the Beautiful Racket master recipe 
> .
> 
> Every language should define and provide a read-syntax function. 
> 
> To make the new language read the source file, read-syntax must be defined 
> something like - 
> (define (read-syntax path port)
> ...)
> 
> Like in Beautiful Racket's wires language implementation 
> , I want to read the source 
> file line by line and wrap it in a macro. 
> Beautiful Racket does it like this - 
>   (define 
> 
>  (read-syntax 
> 
>  path port)
> (define 
> 
>  wire-datums
>   (for/list 
> 
>  ([wire-str (in-lines 
> 
>  port)])
> (format-datum 
> 
>  '(wire ~a) wire-str)))
> 
> But this assumes that the br lang is being used(I think because of the 
> format-datum syntax). How do I implement this without using the br lang?
> 
> Also, am I wrong in any of my assumptions so far?
> 
> 
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Racket Users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/racket-users/qEXz8YcAisc/unsubscribe 
> .
> To unsubscribe from this group and all its topics, 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/180aae4b-9e79-43cc-9177-6c917acf0dc8%40googlegroups.com
>  
> .
> 
> 
> -- 
> Pratyush Das(Reik)
> 
> -- 
> 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/CAFzLTskQ70okYZj247VA2rGNWyoW62wCyyu3jqXHtzZdw3aJEg%40mail.gmail.com
>  
> .

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this g

[racket-users] typing variable length argument lists

2020-04-10 Thread Hendrik Boom
Trying to convert the following to typed Racket:

(define (unique list message . messageargs)
  ; return the only element of the list, or '() if there is none.
  ; Produce message if not just one. 
  (if (equal? 1 (length list)) (car list)
 (begin
   (apply fprintf (cons anomaly (cons message messageargs)))
   (if (null? list) list (car list))
   )
 )
)

It's an error message function tat accepts a list to test.
If the test fails it uses fprintf to print a message with the 
arguments for the ~s items.

I got so far, but I don't know what to do with the . messageargs :

(define (unique [list (Listof Any)] [message : String] . messageargs)
  ; return the only element of the list, or '() if there is none.
  ; Produce message if not just one. 
  (if (equal? 1 (length list)) (car list)
 (begin
   (apply fprintf (cons anomaly (cons message messageargs)))
   (if (null? list) list (car list))
   )
 )
)

-- 
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/20200410234906.5wy5kgzl2qfwd2db%40topoi.pooq.com.


Re: [racket-users] typing variable length argument lists

2020-04-10 Thread Jon Zeppieri
(define (unique [list : (Listof Any)] [message : String] .
[messageargs : Any *])
  ; return the only element of the list, or '() if there is none.
  ; Produce message if not just one.
  (if (equal? 1 (length list)) (car list)
 (begin
   (apply fprintf anomaly message messageargs)
   (if (null? list) list (car list)

On Fri, Apr 10, 2020 at 7:49 PM Hendrik Boom  wrote:
>
> Trying to convert the following to typed Racket:
>
> (define (unique list message . messageargs)
>   ; return the only element of the list, or '() if there is none.
>   ; Produce message if not just one.
>   (if (equal? 1 (length list)) (car list)
>  (begin
>(apply fprintf (cons anomaly (cons message messageargs)))
>(if (null? list) list (car list))
>)
>  )
> )
>
> It's an error message function tat accepts a list to test.
> If the test fails it uses fprintf to print a message with the
> arguments for the ~s items.
>
> I got so far, but I don't know what to do with the . messageargs :
>
> (define (unique [list (Listof Any)] [message : String] . messageargs)
>   ; return the only element of the list, or '() if there is none.
>   ; Produce message if not just one.
>   (if (equal? 1 (length list)) (car list)
>  (begin
>(apply fprintf (cons anomaly (cons message messageargs)))
>(if (null? list) list (car list))
>)
>  )
> )
>
> --
> 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/20200410234906.5wy5kgzl2qfwd2db%40topoi.pooq.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/CAKfDxxwCh5OZSCTujaPCqgKa0uhO_gc7JpaD1jV3jeqC0Wsaxg%40mail.gmail.com.