[racket-users] Re: Help with simple macro transformation

2020-02-17 Thread Ryan Kramer
Gah, of course it's possible with patterns. For some reason I just didn't 
think of matching `(id rest ...)`

(define-syntax (rearrange stx)
  (syntax-case stx ()
[(_ [(id rest ...) body]
more ...)
 #'(cons '[id body]
 (rearrange [(rest ...) body]
more ...))]
[(_ [() body]
more ...)
 #'(rearrange more ...)]
[(_)
 #'(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/0ee5ab41-0ddd-4722-be69-6d5001847dd5%40googlegroups.com.


[racket-users] Help with simple macro transformation

2020-02-17 Thread Ryan Kramer
I'm 95% sure I've done this before, but for some reason I am really stuck 
right now. Given

(rearrange ([(a b c) 1]
[(d e) 2]))

I would like any kind of shape containing [a 1] [b 1] [c 1] [d 2] [e 2]. 
Any kind of nesting should be fine as long as the ids are matched up 1:1 
with the numbers. I've tried variants of the following but always run in to 
"incompatible ellipsis" problems:

(define-syntax-rule (rearrange [(id ...) body] ...)
  '(([id body] ...)
...))

Can this be done with patterns, or do I need to use quasisyntax splicing 
and list manipulation?

Larger context: I am making a table of proc-ids and proc-bodies. Some procs 
share the same bodies, so I want to be able to write [(a b c) shared-body], 
but eventually I need to get to [a shared-body] ...

-- 
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/103ad2ab-432e-4e65-b3c5-1a080c310b01%40googlegroups.com.


Re: [racket-users] Typed code from untyped code

2020-02-17 Thread Alex Knauth
The way I we imagined it, it would be implemented like the workaround of a 
getter function, but with an identifier macro to hide the function from the 
person using the mutable identifier.

Alex Knauth (mobile)

> On Feb 17, 2020, at 7:22 PM, Ben Greenman  wrote:
> 
> On 2/17/20, Bertrand Augereau  wrote:
>> Hello and thank you Ben for the explanation,
>> 
>> I had already implemented the workaround, I'll keep it :)
>> It seems that wrapping every binding access in a function is seen as
>> unnecessary in Scheme and Common Lisp ("Reference needed" :) ) but
>> it's a tool I use a lot in my favorite statically typed languages
>> usually so I'll keep at it because it just eases refactoring... for
>> instance in this case :)
>> Maybe the documentation should warn about this ?
>> Cheers,
>> Bertrand
> 
> Yes, a note in the docs would be good.
> 
> Another idea:* TR could fix the issue by protecting set!'d identifiers
> lazily. Instead of applying a contract in the typed module, export a
> macro that applies the contract at each untyped use-site.
> 
> * Thanks to Alex Knauth
> 
> -- 
> 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/CAFUu9R7f3tRawUp76L9qa%3DEUWL_FNjgysCaJ%3D%3Df%3DS8rAJ41ZXA%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/AE5BC9AE-6FE2-405E-B4D2-6178F0F91532%40knauth.org.


Re: [racket-users] Typed code from untyped code

2020-02-17 Thread Ben Greenman
On 2/17/20, Bertrand Augereau  wrote:
> Hello and thank you Ben for the explanation,
>
> I had already implemented the workaround, I'll keep it :)
> It seems that wrapping every binding access in a function is seen as
> unnecessary in Scheme and Common Lisp ("Reference needed" :) ) but
> it's a tool I use a lot in my favorite statically typed languages
> usually so I'll keep at it because it just eases refactoring... for
> instance in this case :)
> Maybe the documentation should warn about this ?
> Cheers,
> Bertrand

Yes, a note in the docs would be good.

Another idea:* TR could fix the issue by protecting set!'d identifiers
lazily. Instead of applying a contract in the typed module, export a
macro that applies the contract at each untyped use-site.

* Thanks to Alex Knauth

-- 
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/CAFUu9R7f3tRawUp76L9qa%3DEUWL_FNjgysCaJ%3D%3Df%3DS8rAJ41ZXA%40mail.gmail.com.


[racket-users] Racket News - Issue 26

2020-02-17 Thread Paulo Matos
Hi,

Racket News issue 26 is here:
https://racket-news.com/2020/02/racket-news-issue-26.html

Enjoy,

Paulo Matos

-- 
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/40615363-3f80-434b-a2c6-198494e13429%40googlegroups.com.


Re: [racket-users] plan to build a continuous integration system in racket

2020-02-17 Thread Sage Gerard
Yes, I understood that. Speaking for myself I'd want to see what other people 
are doing to inform my own designs. My suggestion was in that spirit.

 Original Message 
On Feb 17, 2020, 5:12 PM, Paulo Matos wrote:

> On Thursday, 13 February 2020 14:35:42 UTC+1, Sage Gerard wrote:
>
>> Some core devs are already looking into building a new CI/CD for use in the 
>> project. Maybe it would be worth taking a look at the Racket Slack and ask 
>> if you can participate in the #ci channel.
>
> Sage, correct me if I misunderstood but I think Xu wants to build a CI system 
> in Racket (like buildbot or CircleCI)- not necessarily a CI system for 
> Racket. So his work would be orthogonal to ours.
>
>> Re: web dev, maybe one of my posts can help, but it's more of a supplement 
>> to a guide you already read 
>> https://sagegerard.com/racket-webserver-notes.html
>>
>> I think it's a great idea to learn Racket in any case, but I'm not sure what 
>> your goals are in getting in the web field. The web-server package is a 
>> behemoth of an engineering effort, and it's use of serializable 
>> continuations is an advantage IMO. Is there anything else in particular that 
>> you are hoping to find?
>
>>  Original Message 
>> On Feb 13, 2020, 12:05 AM, Xu Xue < [xuu...@gmail.com](javascript:)> wrote:
>>
>>> Hi, all
>>>
>>> I am a senior student and plan to build a continuous integration system 
>>> using Racket as my graduation project.
>>>
>>> I'm very new to Racket web programming and CI/CD (about CI system I've 
>>> already found some great projects to refer to).
>>>
>>> I've just gone through [Web Applications in Racket] and bought [Server: 
>>> Racket].
>>>
>>> Are there any other starter resources or experiences to share about the 
>>> Racket web programming?
>>>
>>> Or maybe isn't it a good choice to dive into the web field using 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...@googlegroups.com](javascript:).
>>> To view this discussion on the web visit 
>>> [https://groups.google.com/d/msgid/racket-users/3d98a427-f3a7-44d2-ad45-499a1f3cf83c%40googlegroups.com](https://groups.google.com/d/msgid/racket-users/3d98a427-f3a7-44d2-ad45-499a1f3cf83c%40googlegroups.com?utm_medium=email_source=footer).
>
> --
> 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/8a02ee3c-df50-4126-b030-4b3336492c6a%40googlegroups.com](https://groups.google.com/d/msgid/racket-users/8a02ee3c-df50-4126-b030-4b3336492c6a%40googlegroups.com?utm_medium=email_source=footer).

-- 
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/pj0FW0rJ595P1szQPnIHKh6HhTwkGVaS_PIj89r-Qiuo2yzTgadsj0sssX7ZWQpjQLNXKpvTfTRxz1VlJpkzFoxe7OPboZdhGuRG5L3Ktzg%3D%40sagegerard.com.


[racket-users] Re: plan to build a continuous integration system in racket

2020-02-17 Thread Paulo Matos


On Thursday, 13 February 2020 06:05:49 UTC+1, Xu Xue wrote:
>
> Hi, all
>
> I am a senior student and plan to build a continuous integration system 
> using Racket as my graduation project.
>
> I'm very new to Racket web programming and CI/CD (about CI system I've 
> already found some great projects to refer to).
>
>
I always thought Racket to be a great basis for a CI system. Not only 
because ... well, Racket but because each system necessarily needs a way to 
describe pipelines and most use some sort of yaml. With Racket you could 
potentially design something much closer to what a CI description language 
needs (dreaming now about a #lang ci) while remaining tightly integrated 
with the remainder of the system. Also, the fact that racket supports so 
many platforms would provide an advantage over designing it in other 
languages.

I am definitely not an expert in web programming in Racket or in general 
but if I can provide any insights into CI, feel free to reach out. 

Paulo
 

> I've just gone through [Web Applications in Racket] and bought [Server: 
> Racket].
>
> Are there any other starter resources or experiences to share about the 
> Racket web programming?
>
> Or maybe isn't it a good choice to dive into the web field using 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/2893057b-6a94-4830-8eb6-e71bfe2e660d%40googlegroups.com.


Re: [racket-users] plan to build a continuous integration system in racket

2020-02-17 Thread Paulo Matos


On Thursday, 13 February 2020 14:35:42 UTC+1, Sage Gerard wrote:
>
> Some core devs are already looking into building a new CI/CD for use in 
> the project. Maybe it would be worth taking a look at the Racket Slack and 
> ask if you can participate in the #ci channel. 
>
>
Sage, correct me if I misunderstood but I think Xu wants to build a CI 
system in Racket (like buildbot or CircleCI)- not necessarily a CI system 
for Racket. So his work would be orthogonal to ours.
 

> Re: web dev, maybe one of my posts can help, but it's more of a supplement 
> to a guide you already read 
> https://sagegerard.com/racket-webserver-notes.html
>
> I think it's a great idea to learn Racket in any case, but I'm not sure 
> what your goals are in getting in the web field. The web-server package is 
> a behemoth of an engineering effort, and it's use of serializable 
> continuations is an advantage IMO. Is there anything else in particular 
> that you are hoping to find? 
>
>
>
>
>
>  Original Message 
> On Feb 13, 2020, 12:05 AM, Xu Xue < xuu...@gmail.com > wrote:
>
>
> Hi, all
>
> I am a senior student and plan to build a continuous integration system 
> using Racket as my graduation project.
>
> I'm very new to Racket web programming and CI/CD (about CI system I've 
> already found some great projects to refer to).
>
> I've just gone through [Web Applications in Racket] and bought [Server: 
> Racket].
>
> Are there any other starter resources or experiences to share about the 
> Racket web programming?
>
> Or maybe isn't it a good choice to dive into the web field using 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...@googlegroups.com .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/3d98a427-f3a7-44d2-ad45-499a1f3cf83c%40googlegroups.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/8a02ee3c-df50-4126-b030-4b3336492c6a%40googlegroups.com.


Re: [racket-users] Lambda calculus done in Racket

2020-02-17 Thread George Neuner


On 2/17/2020 12:12 PM, Lawrence Bottorff wrote:

I found these blowing down the sidewalk today

; TRUE = λx.λy.x
(define mytrue
  (lambda (t) (lambda (f) t)))

and

; FALSE = λx.λy.y
(define myfalse
  (lambda (t) (lambda (f) f)))

Two problems, I don't understand them and AFAICT, they don't work. I 
traced them back to this 
 
post on stackoverflow. Can anyone get me started here?


LB


In addition to Ricardo's good answer:

The definition of TRUE above is one of the combinators of the S-K-I 
combinator calculus, which is a simple to understand subset of the 
untyped lambda calculus.  Programs in S-K-I are expressed as sequences 
of 3 simple combinators, and computation is done by repeated expansion, 
application and reduction until an irreducible form - the result - is 
reached.


https://en.wikipedia.org/wiki/SKI_combinator_calculus

George

--
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/56ba86fe-c379-3127-d8b2-ba70078380e2%40comcast.net.


Re: [racket-users] Lambda calculus done in Racket

2020-02-17 Thread Ricardo Gabriel Herdt

Hi,

The idea is that you can encode an expression

"if B then P else Q"

as a λ-term BPQ. So if B is true, you get P, otherwise Q.

For an overview of λ-calculus I suggest reading this:

https://ecee.colorado.edu/ecen5533/fall11/reading/lambda_types.pdf

The encoding of boolean expressions is described on (book) page 16.

Regards,

Ricardo

Am 17.02.2020 18:12 schrieb Lawrence Bottorff:

I found these blowing down the sidewalk today

; TRUE = λx.λy.x
(define mytrue
  (lambda (t) (lambda (f) t)))

and

; FALSE = λx.λy.y
(define myfalse
  (lambda (t) (lambda (f) f)))

Two problems, I don't understand them and AFAICT, they don't work. I
traced them back to this [1] post on stackoverflow. Can anyone get me
started here?

LB

 --
 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/CAFAhFSXjQq2WWei8zvVY38cQmPd9Yb9sd95zCsszWY_aO3xPkA%40mail.gmail.com
[2].


Links:
--
[1]
https://stackoverflow.com/questions/40288602/the-code-of-the-build-in-scheme-procedure-pair
[2]
https://groups.google.com/d/msgid/racket-users/CAFAhFSXjQq2WWei8zvVY38cQmPd9Yb9sd95zCsszWY_aO3xPkA%40mail.gmail.com?utm_medium=email_source=footer


--
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/0a2b34fad4634396100f9c5ce87dc146%40posteo.de.


[racket-users] Lambda calculus done in Racket

2020-02-17 Thread Lawrence Bottorff
I found these blowing down the sidewalk today

; TRUE = λx.λy.x
(define mytrue
  (lambda (t) (lambda (f) t)))

and

; FALSE = λx.λy.y
(define myfalse
  (lambda (t) (lambda (f) f)))

Two problems, I don't understand them and AFAICT, they don't work. I traced
them back to this

post on stackoverflow. Can anyone get me started here?

LB

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


Re: [racket-users] Typed code from untyped code

2020-02-17 Thread Bertrand Augereau
Hello and thank you Ben for the explanation,

I had already implemented the workaround, I'll keep it :)
It seems that wrapping every binding access in a function is seen as
unnecessary in Scheme and Common Lisp ("Reference needed" :) ) but
it's a tool I use a lot in my favorite statically typed languages
usually so I'll keep at it because it just eases refactoring... for
instance in this case :)
Maybe the documentation should warn about this ?
Cheers,
Bertrand

Le lun. 17 févr. 2020 à 16:46, Ben Greenman
 a écrit :
>
> If you export a "getter" function instead of the list, both modules
> have the same behavior:
>
> ```
> #lang racket/base
>
> (module racket_mod racket
>   (provide (struct-out s))
>   (provide get-s)
>   (provide set-list-of-s!)
>
>   (struct s (a))
>   (define list-of-s '())
>   (define (get-s) list-of-s)
>   (define (set-list-of-s! los)
> (set! list-of-s los)))
>
> (module racket_mod_typed typed/racket
>   (provide (struct-out s2))
>   (provide get-s2)
>   (provide set-list-of-s2!)
>
>   (struct s2 ([a : Natural]))
>   (define list-of-s2 : (Listof s2) '())
>   (define (get-s2) : (Listof s2) list-of-s2)
>   (define (set-list-of-s2! [los : (Listof s2)])
> (set! list-of-s2 los)))
>
> (require 'racket_mod)
> (require 'racket_mod_typed)
>
> (define los (list (s 1) (s 2)))
> (set-list-of-s! los)
> (displayln (get-s))
> ;; (# #)
>
> (define los2 (list (s2 1) (s2 2)))
> (set-list-of-s2! los2)
> (displayln (get-s2))
> ;; (# #)
> ```
>
> - - -
>
> The issue in the original code comes from Typed Racket's internals.
> When you write `(provide x)` in a TR module, the compiler makes 2
> kinds of `x`: a plain `x` for typed clients and a contract-protected
> `x` for untyped clients.
>
> ```
> ;; source code
> (provide x)
> (define x : (Listof s2) '())
> ```
>
> ```
> ;; complied code, approximately
> (provide (rename-out safe-x x))
> (define-typed/untyped-identifier safe-x typed-x untyped-x)
>
> (define typed-x : (Listof s2) '())
> (define untyped-x (contract (listof s2?) typed-x))
> ```
>
> The contracts make sure that untyped code respects TR types, and
> normally nothing else. But your example shows one way that the current
> strategy can end up with different behavior. This is unfortunate, but
> I'm not sure how TR could do better ... every new element that gets
> added to the list needs protection.
>
> - - -
>
> fwiw, you can also see equal behavior from a typed main module:
>
> ```
> #lang typed/racket
> ;; typed_racket_main.rkt
>
> (require/typed "racket_mod.rkt"
>   (#:struct s ((a : Natural)))
>   (set-list-of-s! (-> (Listof s) Void))
>   (list-of-s (Listof s)))
> (require "racket_mod_typed.rkt")
>
> (define los (list (s 1) (s 2)))
> (set-list-of-s! los)
> (displayln list-of-s)
>
> (define los2 (list (s2 1) (s2 2)))
> (set-list-of-s2! los2)
> (displayln list-of-s2)
> ```
>
> If you were planning to add types everywhere, then maybe its best to
> go ahead with that instead of adding getter functions.
>
> --
> 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/CAFUu9R5fDBYWMPH%3DLsRe1VXnVmdncdrRY%3DLODGYtGhuhsmSZ-A%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/CAHV%3D05qXZvFK%3DFGpyugJ_G3eySsEtX-0hGJByG0oUB8WzXK99g%40mail.gmail.com.


Re: [racket-users] Typed code from untyped code

2020-02-17 Thread Ben Greenman
If you export a "getter" function instead of the list, both modules
have the same behavior:

```
#lang racket/base

(module racket_mod racket
  (provide (struct-out s))
  (provide get-s)
  (provide set-list-of-s!)

  (struct s (a))
  (define list-of-s '())
  (define (get-s) list-of-s)
  (define (set-list-of-s! los)
(set! list-of-s los)))

(module racket_mod_typed typed/racket
  (provide (struct-out s2))
  (provide get-s2)
  (provide set-list-of-s2!)

  (struct s2 ([a : Natural]))
  (define list-of-s2 : (Listof s2) '())
  (define (get-s2) : (Listof s2) list-of-s2)
  (define (set-list-of-s2! [los : (Listof s2)])
(set! list-of-s2 los)))

(require 'racket_mod)
(require 'racket_mod_typed)

(define los (list (s 1) (s 2)))
(set-list-of-s! los)
(displayln (get-s))
;; (# #)

(define los2 (list (s2 1) (s2 2)))
(set-list-of-s2! los2)
(displayln (get-s2))
;; (# #)
```

- - -

The issue in the original code comes from Typed Racket's internals.
When you write `(provide x)` in a TR module, the compiler makes 2
kinds of `x`: a plain `x` for typed clients and a contract-protected
`x` for untyped clients.

```
;; source code
(provide x)
(define x : (Listof s2) '())
```

```
;; complied code, approximately
(provide (rename-out safe-x x))
(define-typed/untyped-identifier safe-x typed-x untyped-x)

(define typed-x : (Listof s2) '())
(define untyped-x (contract (listof s2?) typed-x))
```

The contracts make sure that untyped code respects TR types, and
normally nothing else. But your example shows one way that the current
strategy can end up with different behavior. This is unfortunate, but
I'm not sure how TR could do better ... every new element that gets
added to the list needs protection.

- - -

fwiw, you can also see equal behavior from a typed main module:

```
#lang typed/racket
;; typed_racket_main.rkt

(require/typed "racket_mod.rkt"
  (#:struct s ((a : Natural)))
  (set-list-of-s! (-> (Listof s) Void))
  (list-of-s (Listof s)))
(require "racket_mod_typed.rkt")

(define los (list (s 1) (s 2)))
(set-list-of-s! los)
(displayln list-of-s)

(define los2 (list (s2 1) (s2 2)))
(set-list-of-s2! los2)
(displayln list-of-s2)
```

If you were planning to add types everywhere, then maybe its best to
go ahead with that instead of adding getter functions.

-- 
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/CAFUu9R5fDBYWMPH%3DLsRe1VXnVmdncdrRY%3DLODGYtGhuhsmSZ-A%40mail.gmail.com.


[racket-users] Typed code from untyped code

2020-02-17 Thread Bertrand Augereau
Hello everybody,
I'm trying to gradually type my script to make it a proper app (yes
I'm a static-ish guy) and I have an issue (Racket 7.6 CS).

===
racket_mod.rkt:
#lang racket

(provide (struct-out s))
(provide list-of-s)
(provide set-list-of-s!)

(struct s (a))
(define list-of-s '())
(define (set-list-of-s! los)
  (set! list-of-s los))
===

racket_mod_typed.rkt:
#lang typed/racket

(provide (struct-out s2))
(provide list-of-s2)
(provide set-list-of-s2!)

(struct s2 ([a : Natural]))
(define list-of-s2 '())
(define (set-list-of-s2! [los : (Listof s2)])
  (set! list-of-s2 los))
===
racket_main.rkt:
#lang racket

(require "racket_mod.rkt")
(require "racket_mod_typed.rkt")

(define los (list (s 1) (s 2)))
(set-list-of-s! los)
(displayln list-of-s)

(define los2 (list (s2 1) (s2 2)))
(set-list-of-s2! los2)
(displayln list-of-s2)
===

list-of-s2 is empty and list-of-s is not, the only difference seems to
be the type annotations.
Can someone help me ? :)

Cheers and thanks,
Bertrand

-- 
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/CAHV%3D05oECAzid22ZcRAtTYhjBow%2BZTn3%3D8G2hsZqHokbmxs1oA%40mail.gmail.com.