Re: [racket-users] How 'Pythonic' Can Racket Be Made?

2023-10-10 Thread D. Ben Knoble
Nor on Discourse: I use the mailing list mode.

On Tue, Oct 10, 2023 at 12:14 PM Adam Golding  wrote:
>
> ah well the practice of email lists does not depend on google... we should 
> presumbly be using matrix chat instead
>
> On Tue, 10 Oct 2023 at 12:12, Daniel Patterson  wrote:
>>
>> Unlike, e.g., Google?
>>
>> On Oct 10, 2023, at 12:11 PM, Adam Golding  wrote:
>>
>> Yikes, how do we protest introducing a dependency on some corporation?
>>
>> On Tue, 10 Oct 2023 at 12:09, D. Ben Knoble  wrote:
>>>
>>> You'll probably get more replies on Discourse. A short answer is to mention 
>>> Rhombus and to recommend looking at all the #langs on the package server 
>>> and in the docs.
>>>
>>> On Monday, October 9, 2023 at 1:35:11 PM UTC-4 Adam Golding wrote:
>>>>
>>>> I am going to write a language called 'micronatrix' that is pythonic in 
>>>> its use of whitespace and even with python 2 type print statements but 
>>>> very minimal and pared down -- has similar ground been trodden?
>>>> --
>>>> adamgolding.ca
>>>>
>>>> ps I have registered micronatrix.com
>>>
>>>
>>> --
>>> This group is deprecated and retained as an archive.
>>>
>>> Racket discussions have moved to the Racket Discourse at 
>>> https://racket.discourse.group/ .
>>>
>>> ---
>>> 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.
>>> ---
>>> 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/ba2e2e23-c21b-43d0-9649-86a7fefa8d2bn%40googlegroups.com.
>>
>>
>> --
>> This group is deprecated and retained as an archive.
>>
>> Racket discussions have moved to the Racket Discourse at 
>> https://racket.discourse.group/ .
>>
>> ---
>> 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.
>> ---
>> 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/CALiGnDBKj6fz6_Onw1-DVstUHSQPn8T-Qmeir3hnF6k8J_kGmA%40mail.gmail.com.
>>
>>


-- 
D. Ben Knoble

-- 
This group is deprecated and retained as an archive. 

Racket discussions have moved to the Racket Discourse at  
https://racket.discourse.group/ .

---
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.
--- 
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/CALnO6CAEu8xT5rXuR0ZPv0ke66tXeQu3LAV%3D0ADCJrG8QzSVrw%40mail.gmail.com.


[racket-users] Re: How 'Pythonic' Can Racket Be Made?

2023-10-10 Thread D. Ben Knoble
You'll probably get more replies on Discourse. A short answer is to mention 
Rhombus and to recommend looking at all the #langs on the package server 
and in the docs.

On Monday, October 9, 2023 at 1:35:11 PM UTC-4 Adam Golding wrote:

> I am going to write a language called 'micronatrix' that is pythonic in 
> its use of whitespace and even with python 2 type print statements but very 
> minimal and pared down -- has similar ground been trodden?
> --
> adamgolding.ca
>
> ps I have registered micronatrix.com
>

-- 
This group is deprecated and retained as an archive. 

Racket discussions have moved to the Racket Discourse at  
https://racket.discourse.group/ .

---
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.
--- 
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/ba2e2e23-c21b-43d0-9649-86a7fefa8d2bn%40googlegroups.com.


[racket-users] Re: how could I obtain more context to isolate the problem?

2022-08-09 Thread D. Ben Knoble
Are you passing the `?` to `raco setup`? If so, I suspect your shell is 
expanding that to a file or directory named `t` (which matches the glob 
`?`), which is then used as a collection name.

On Monday, August 8, 2022 at 12:43:27 PM UTC-4 infodeve...@gmail.com wrote:

> $ raco setup ?
> collection-path: collection not found
>   collection: "t"
>   in collection directories:
>/home/don/.plt-scheme/4.2.1/collects
>/home/don/.racket/8.1/collects
>/home/don/racket/collects/
>... [175 additional linked and package directories]
>
> Thanks
>
>

-- 
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/9d90c018-ae66-4a9a-bd27-c381227b636cn%40googlegroups.com.


Re: [racket-users] using neg-propositions in partition?

2021-10-05 Thread Ben Greenman
There's an issue open about partition:
 https://github.com/racket/typed-racket/issues/138

Does `my-partition` work like you'd want? Based on Alex's last comment
on the issue, it seems hard to give a predicate that matches the type.


(Whenever I've wanted `partition` in typed code, I was always able to
use 2 filters instead.)

On 10/5/21, 'John Clements' via Racket Users
 wrote:
> I was somewhat surprised to see today that I can’t use a predicate with both
> positive and negative propositions in the way I would expect with
> partition:
>
>> (:print-type partition)
> (All (a b)
>   (case->
>(-> (-> b Any : #:+ a) (Listof b) (values (Listof a) (Listof b)))
>(-> (-> a Any) (Listof a) (values (Listof a) (Listof a)
>
>
> Specifically, I would have expected the type to be something like this:
>
> (All (a b c)
>   (case->
>(-> (-> b Any : #:+ a) (Listof b) (values (Listof a) (Listof b)))
>;; the second list must consist of 'c's:
>(-> (-> b Any : #:+ a #:- c) (Listof b) (values (Listof a) (Listof c)))
>(-> (-> a Any) (Listof a) (values (Listof a) (Listof a)
>
> … so that if, say, I had a list of Elephants and Emus, that I could use
> elephant? to split it into two lists: one of type (Listof Elephant) and one
> of type (Listof Emu).
>
> I tried to roll my own, and got pretty close:
>
> (: my-partition
>(All (a b c)
> (case->
>  ;; the second list must consist of 'c's:
>  (-> (-> b Any : #:+ a #:- c) (Listof b) (values (Listof a) (Listof
> c)))
>  )))
>
> (define (my-partition my-pred elts)
>   (cond [(empty? elts)
>  (values '() '())]
> [else
>  (define-values (stacks non-stacks)
>(my-partition my-pred (rest elts)))
>  (define f (first elts))
>  (cond [(my-pred f)
> (values (cons f stacks)
> non-stacks)]
>[else
> (values stacks (cons f non-stacks))])]))
>
> That is, I can do it for the case-> clause that I care about. Putting the
> other two back in there causes it to fail type-checking. Is that the
> problem, that TR can’t accommodate both flavors in the same type?
>
> John
>
>
> --
> 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/aa1e77a8-9cc4-4f99-b413-1304daeec12b%40mtasv.net.
>

-- 
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/CAFUu9R6ncSV-MY%3DMDJjG%3DbsKVCjA3%3DDdGwJGNQfBVkTK70guqQ%40mail.gmail.com.


Re: [racket-users] Having trouble getting documentation to generate

2021-09-28 Thread Ben Greenman
On 9/28/21, David Storrs  wrote:
> *fists of rage*
>
> I'm glad it worked for you, and that it works for me if I repeat your
> steps.  I have no idea why it wasn't working given that I was using the
> local copy of the git repository that is the source of what's on github.
> Argh.

Weird ... glad it's working.

> Regardless, thank you very much for your help.  I've fixed the (for-label
> try-catch), removed the test-more dependency, pushed it to github, and told
> the package server to rescan.  It says it will do that 1 minute from now,
> so hopefully it'll be good to go at that point.  I think documentation only
> gets generated once per day though, right?
>
>
> Also, any ideas on why the remove fails?
>
> $ raco pkg remove try-catch
> raco pkg remove: invalid `deps' specification
>   specification: '("base" racket/format racket/string)
>
> That is not the deps specification from the info.rkt file so I don't know
> where it's getting that.

Some package somewhere must have that bad info.rkt file.

A plain "raco setup" might be the quickest way to find the bad one.
That should print the name of every package as it goes through them.

Or, a "raco pkg remove -f try-catch" should work despite the invalid deps spec.

-- 
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/CAFUu9R5%3DCL-_wfB52aG82Vg9y%2B9HKpQhxk_dX08ub5Ln948QGQ%40mail.gmail.com.


Re: [racket-users] Having trouble getting documentation to generate

2021-09-28 Thread Ben Greenman
o 'try-catch'...
remote: Enumerating objects: 18, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 18 (delta 4), reused 18 (delta 4), pack-reused 0
Unpacking objects: 100% (18/18), done.
> cd try-catch
> ls
LICENSE info.rktmain.rktscribblings
> raco pkg install
Linking current directory as a package
The following uninstalled packages are listed as dependencies of try-catch:
   test-more
Would you like to install these dependencies? [Y/n/a/c/?] y
Resolving "test-more" via https://pkgs.racket-lang.org
Downloading repository https://github.com/dstorrs/racket-test-more.git
The following uninstalled packages were listed as dependencies
and they were installed:
 dependencies of try-catch:
   test-more
raco setup: version: 7.8.0.6
raco setup: platform: x86_64-macosx [3m]
raco setup: target machine: racket
raco setup: installation name: development
raco setup: variants: 3m
raco setup: main collects: /Users/ben/code/racket/fork/racket/collects
raco setup: collects paths: 
raco setup:   /Users/ben/code/racket/fork/racket/collects
raco setup: main pkgs: /Users/ben/code/racket/fork/racket/share/pkgs
raco setup: pkgs paths: 
raco setup:   /Users/ben/code/racket/fork/racket/share/pkgs
raco setup:   /Users/ben/Library/Racket/development/pkgs
raco setup: links files: 
raco setup:   /Users/ben/code/racket/fork/racket/share/links.rktd
raco setup:   /Users/ben/Library/Racket/development/links.rktd
raco setup: main docs: /Users/ben/code/racket/fork/racket/doc
raco setup: --- updating info-domain tables ---[13:36:02]
raco setup: updating: /Users/ben/code/racket/fork/racket/share/info-cache.rktd
raco setup: --- pre-installing collections --- [13:36:02]
raco setup: --- installing foreign libraries ---   [13:36:02]
raco setup: --- installing shared files ---[13:36:02]
raco setup: --- compiling collections ---  [13:36:02]
raco setup: --- parallel build using 4 jobs ---[13:36:02]
raco setup: 3 making: /racket-index/scribblings/main
raco setup: 2 making: /test-more
raco setup: 1 making: /try-catch
raco setup: 1 making: /try-catch/scribblings
raco setup: 2 making: /test-more/tests
raco setup: 3 making: /racket-index/scribblings/main/private
raco setup: 3 making: /racket-index/scribblings/main/user
raco setup: --- creating launchers --- [13:36:06]
raco setup: --- installing man pages ---   [13:36:06]
raco setup: --- building documentation --- [13:36:06]
raco setup: 2 skipping: /mischief/mischief/scribblings/mischief.scrbl
raco setup: 1 skipping: 
/social-contract/contract/social/scribblings/social-contract.scrbl
raco setup: 2 running: /try-catch/scribblings/try-catch.scrbl
raco setup: 1 skipping: /typed-compose/typed-compose.scrbl
raco setup: 3 rendering: /racket-index/scribblings/main/release.scrbl
raco setup: 2 rendering: /racket-index/scribblings/main/start.scrbl
raco setup: 1 rendering: /try-catch/scribblings/try-catch.scrbl
raco setup: 0 rendering: 
/racket-index/scribblings/main/local-redirect.scrbl
raco setup: 3 rendering: /racket-index/scribblings/main/search.scrbl
raco setup: --- installing collections ---     [13:36:37]
raco setup: --- post-installing collections ---[13:36:37]
> vi info.rkt
> vi scribblings/try-catch.scrbl

zsh: suspended  nvim scribblings/try-catch.scrbl
> raco setup try-catch
raco setup: version: 7.8.0.6
raco setup: platform: x86_64-macosx [3m]
raco setup: target machine: racket
raco setup: installation name: development
raco setup: variants: 3m
raco setup: main collects: /Users/ben/code/racket/fork/racket/collects
raco setup: collects paths: 
raco setup:   /Users/ben/Library/Racket/development/collects
raco setup:   /Users/ben/code/racket/fork/racket/collects
raco setup: main pkgs: /Users/ben/code/racket/fork/racket/share/pkgs
raco setup: pkgs paths: 
raco setup:   /Users/ben/code/racket/fork/racket/share/pkgs
raco setup:   /Users/ben/Library/Racket/development/pkgs
raco setup: links files: 
raco setup:   /Users/ben/code/racket/fork/racket/share/links.rktd
raco setup:   /Users/ben/Library/Racket/development/links.rktd
raco setup: main docs: /Users/ben/code/racket/fork/racket/doc
raco setup: --- updating info-domain tables ---[13:44:41]
raco setup: --- pre-installing collections --- [13:44:41]
raco setup: --- installing foreign libraries ---   [13:44:41]
raco setup: --- installing shared files ---[13:44:41]
raco setup: --- compiling collections ---  [13:44:41]
raco setup: --- parallel build using 4 jobs ---[13:44:41]
raco setup: 3 making: /try-catch
raco setup: 3 making: /try-catch/scribblings
raco setup: --- creating launchers ---

Re: [racket-users] Syntax Parse Bee 2021

2021-09-15 Thread Ben Greenman
The competition is now closed.

Thank you to the participants!!!

We received 22 entries from 15 individuals:

 https://github.com/syntax-objects/Summer2021/issues

The final results of these submissions cover a wide range. Some are macros
that you could use in any Racket project. Others are syntax classes. Still
others are more like starter code for a new DSL.

The code inside these submissions is **very** informative. Whether you're
new to macros or a seasoned syntax parser, there is a lot to learn from.

- Ben + Stephen


On 8/26/21, Ben Greenman  wrote:
> On 8/25/21, Stephen De Gabrielle  wrote:
>> There is only a couple more days! it's not too late!
>>
>
> We have lots of prizes
>

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


[racket-users] Re: Is this "inside out" macro technique common?

2021-08-13 Thread D. Ben Knoble
Ah, I'm now seeing that with-quasi implicitly #`s the body; I believe with 
syntax-parse, #:with, and #' + template vars + #` when needed you might be 
ok.

-- 
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/2ede4034-80ec-49ad-9782-8883f8d47085n%40googlegroups.com.


[racket-users] Re: Is this "inside out" macro technique common?

2021-08-13 Thread D. Ben Knoble
> A shortcut to answering my question would be to tell me that 
`with-quasisyntax` in the following paste already exists: 
http://pasterack.org/pastes/48885

Without taking a detailed look, is there anything about with-quasisyntax 
that with-syntax 

 
(https://docs.racket-lang.org/reference/stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._with-syntax%29%29)
 doesn't 
do?

I would also highly recommend syntax-parse and it's various abstractions.

-- 
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/5c89cbd3-0b4a-4d60-ab23-6456225b4a80n%40googlegroups.com.


Re: [racket-users] Equivalent of exec

2021-08-04 Thread D. Ben Knoble
Hi Norman,

> It's slightly unfortunate that Racket's
> start-up time make it slightly suboptimal as a command-line tool, but
> raco make helps with that.

With 8.0+/CS, even without make I've had a good experience. As you
say, setup or make makes things even faster, though.

If you weren't already aware, using #lang racket/base has a faster
startup-time than #lang racket, though you have to (require) things
not provided by the smaller base language.

-- 
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/CALnO6CA6CzTQs2pCuypG6%2BaH7ciEjKvwbNXavJxpp%3DWL3SFFBA%40mail.gmail.com.


Re: [racket-users] Equivalent of exec

2021-08-04 Thread D. Ben Knoble
> (exit (system*/exit-code "/usr/bin/vi" "filename")) 

On a slightly unrelated note, if this for consumption by anyone other than 
just you, I would use (getenv "EDITOR") (or VISUAL, if you prefer) rather 
than hard-code the path to vi.

Best,
D. Ben Knoble

-- 
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/079555c4-3e03-4f75-92d2-81cf4b4f220fn%40googlegroups.com.


Re: [racket-users] Re: A language for command line interfaces

2021-07-25 Thread D. Ben Knoble
> Right, thank you for bringing that up. I should have mentioned that the #lang 
> provides all of racket/base at the module level, so you can write normal 
> Racket code (including `require`), and any imports at the module level would 
> be available within the `program` body since it compiles down to a normal 
> function.
>
> You can also use `provide`, so once you define your command using `program`, 
> you can provide it the same as any function. The client module requiring your 
> command would need to be a #lang cli module (at least at the moment) so that 
> it can actually run the imported command using `run`.

That would be good to add to the docs in my opinion.

-- 
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/CALnO6CAsxaJ%3DHsPJE1ZnOJXs9yVobiRiSBOj9UV4cxC%2BLRqiiw%40mail.gmail.com.


[racket-users] Re: A language for command line interfaces

2021-07-25 Thread D. Ben Knoble


> The language is composed of 5 forms - help, flag, constraint, program, 
> and run. With these 5 forms, you get all of the functionality of the 
> built-in parse-command-line form, and with syntax that's much simpler. In 
> fact, the nontrivial forms of the language simply use Racket's normal 
> function definition syntax, so there's very little to learn -- you 
> basically write normal functions and they are implicitly wired to accept 
> their inputs via the command line.
>

Could we add require? I can think of two compelling reasons:

1. What else is available in the program form? All of racket, or just 
racket/base? And either way, what if I want to use procedures from other 
packages?
2. What if I want to write a bunch of library code, and expose some of it 
in a CLI script? I do this now in different ways: a module+ main that uses 
code defined in the enclosing module, or a script that requires auxiliary 
modules. Often the "body" of the program form isn't more than a call to a 
"main" procedure: this enables me to provide that procedure as part of the 
library, too.

-- 
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/a0a0ffba-b8a5-4b57-8fc1-b24a821de85cn%40googlegroups.com.


Re: [racket-users] How to set type signature for recursive lazy list

2021-07-14 Thread Ben Greenman
On 7/14/21, Kiong-Gē Liāu  wrote:
> Thanks, following Ben's suggestion that follow code works

Great!

-- 
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/CAFUu9R7qLYO6374-g3%3DZGJgwJMPG0ARsSqbGh0NVtYTYsK12sQ%40mail.gmail.com.


Re: [racket-users] How to set type signature for recursive lazy list

2021-07-13 Thread Ben Greenman
On 7/13/21, Kiong-Gē Liāu  wrote:
> Ben,
>
> Thanks, changing "stream" to "stream apply" does solve the issue.
>
> I tried to push it further little bit with the following code to see if
> typed racket can support generic like Haskell or Scala:
>
> #lang typed/racket
>
> (require pfds/stream)
>
>
> (define-type (OverFoldable A) (-> (Listof A) A))
>
> (define-type (FibStreamCons A) (-> (Listof A) (Stream A)))
>
> (define-type (FibStream A) (-> (OverFoldable A) (Listof A) (Stream A)))
>
> (: sum (OverFoldable Number))
> (define (sum xs) (apply + xs))
>
> (: gfib_2 (All (A) (FibStream A)))
> (define (gfib_2 f xs)
>   (: gfib_t (All (A) (FibStreamCons A)))
>   (define (gfib_t ys)
> (stream-cons (last ys) (gfib_t (append (cdr ys) (list (f ys))
>   (stream-append (apply stream (drop-right xs 1)) (gfib_t xs)))
>
> However, I got the following error message:
>
> ; /home/kiong-ge/Programming/Racket/typed_racket_test.rkt:28:61: Type
> Checker: type mismatch
> ;   expected: (Listof A)
> ;   given: (Listof A)
> ;   in: ys
>
> But, according to this error message, expected and given types are exactly
> the same, not sure how to deal with this issue.

I think the problem is 2 different type variables that both print as
the letter A.

When I remove the "All" from the type for gfib_t (FibStreamCons A), it
typechecks.

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


Re: [racket-users] How to set type signature for recursive lazy list

2021-07-12 Thread Ben Greenman
On 7/11/21, Kiong-Gē Liāu  wrote:
> Hi, in non-typed racket, I can define a generalized Fibonacci sequence
>
> X[n+k] = f(X[n], X[n+1], , X[n+k-1])
>
> using the following code
>
> #lang racket
>
> (require  racket/stream)
>
> (define (gfib f xs)
>   (define (gfib_t xs)
> (stream-cons (last xs) (gfib_t (append (cdr xs) (list (f xs))
>   (stream-append (drop-right xs 1) (gfib_t xs)))
>
> (define (sum xs) (apply + xs))
> ;; Example of a (0, 1) initialized Fibonacci sequence
> (define gfib20 (gfib sum '(0 1 )))
>
> But using typed racket,  the following code
>
> #lang typed/racket
>
> (require pfds/stream)
>
> (define (sum [xs : (Listof Number)] ) (apply + xs))
>
> (define (gfib [f : (-> (Listof Number) Number)]  [xs : (Listof Number)] )
>   (define (gfib_t [ys : (Listof Number)] )
> (stream-cons (last ys) (gfib_t (append (cdr ys) (list (f ys))
>   (stream-append (stream (drop-right xs 1)) (gfib_t xs)))
>
> leads to error message
>
> ; /home/kiong-ge/Programming/Racket/typed_racket_test.rkt:8:11: Type
> Checker: insufficient type information to typecheck. please add more type
> annotations
> ;   in: gfib_t
>
> How should I set the type signature in the typed racket in order to get the
> same result generated non-typed racket code ?
>
> Thanks,
> Kiong-Ge.

First, gfib_t needs a return type annotation. You can either add `:
(Stream Number)` to the end of the line, or write a full signature
above the define

  (: gfib_t (-> (Listof Number) (Stream Number)))
  (define (gfib_t ys)

After this, the typechecker can run. But it finds a problem with
stream-append. The issue here is that the two arguments to
stream-append have different types. One contains lists of numbers and
the other contains numbers.

  typed.rkt:11:2: Type Checker: Polymorphic function `stream-append'
could not be applied to arguments:
  Argument 1:
Expected: (Rec Stream (U (Boxof (U (-> (Pairof A Stream)) (Pairof
A Stream))) Null))
Given:(Rec x₀ (U (Boxof (U (-> (Pairof (Listof Number) x₀))
(Pairof (Listof Number) x₀))) Null))
  Argument 2:
Expected: (Rec Stream (U (Boxof (U (-> (Pairof A Stream)) (Pairof
A Stream))) Null))
Given:(Rec x₀ (U (Boxof (U (-> (Pairof Number x₀)) (Pairof
Number x₀))) Null))

in: (stream-append (stream (drop-right xs 1)) (gfib_t xs))

Change (stream (drop-right xs 1)) to (apply stream (drop-right xs 1))
and you should be OK.

(It might be possible to call stream-append with a list and a stream
--- like the untyped code does --- but I haven't figured out how to do
that. Better stick with the Stream datatype.)

-- 
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/CAFUu9R6gdCbqBJ%3DyeZfvLUGKeQidNwXfy30gf--Fj5y52t3jQA%40mail.gmail.com.


[racket-users] Syntax Parse Bee 2021

2021-06-30 Thread Ben Greenman
Hi folks,

*Write a macro with Racket this summer! Win stickers!*

The purpose of this event is to grow the syntax-parse-example documentation
and repository to grow as a resource for the Racket community. But you do
not need to submit a full example to win stickers --- any syntax-parse
macro counts.

*It's like a Quilting Bee, but for syntax parse macros!*

Ground Rules:

   - you can write any macro as long as it uses syntax-parse somehow
   - enter as many times as you like
   - the first 20 individuals who enter will win exclusive stickers
   - open July 1 to September 1

Submit by opening an issue here:

https://github.com/syntax-objects/Summer2021/issues/new?assignees==entry=enter-the-syntax-parse-bee.md=%5Bentry+-+name%2Fdescription+of+macro%5D

To help you get started, we suggest two categories of before-and-after
macro:

   1. *Code Cleaning* : Introduce a macro where there was none before. Look
   for ways to make your source code more beautiful and/or less repetitive.
   2. *Macro Engineering* : Use the tools in syntax-parse to improve an
   existing  macro (which may or may not currently use syntax-parse). Try to
   make the old macro more maintainable, more robust against errors, and/or
   more flexible.

Updates will be via Racket News, Racket-Users, Slack, Discord & Reddit.

Whatever you decide, we hope that you learn and have fun!

- Ben + Stephen


PS a 'Bee' is a community effort toward a common goal. A quilting bee is for
making a quilt. In this case the quilt is a patchwork of syntax-parse
macros.

- - -

Syntax parse docs:
 https://docs.racket-lang.org/syntax/stxparse.html

Syntax parse examples:
 https://docs.racket-lang.org/syntax-parse-example/

Extra syntax classes:
 https://docs.racket-lang.org/syntax-classes/

Mythical Macros tutorial:
 https://soegaard.github.io/mythical-macros/

Macros and Languages in Racket book draft:
 http://rmculpepper.github.io/malr/

Fine print:

   - this is an UNOFFICIAL event run by Racket users (@spdegabrielle and
   @bennn)
   - entries must be submitted under the MIT license [1] for code and under
   CC [2] for accompanying prose
   - stickers will be mailed via USPS; international entries are allowed
   - please abide by the Racket Friendly Environment Policy [3]


[1] https://github.com/racket/racket/blob/master/racket/src/LICENSE-MIT.txt
[2] http://creativecommons.org/licenses/by/4.0/
[3] https://racket-lang.org/friendly.html

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFUu9R6kCG%2BXFnYwOnD_9XyfNq%2BNbJnPVA_rpD4vGKPkzSXBDA%40mail.gmail.com.


Re: [racket-users] Could Racket be used as a "frontend" for a non-Racket language?

2021-06-22 Thread D. Ben Knoble
No idea if this is what you're looking for, but I have a feeling it 
wouldn't be terribly difficult to design a #lang where modules were 
programs that, when run, output C# code (kind of like how scribble & pollen 
can output HTML). Then you could have a language (w/ or w/o) macros that 
gets run down to C# and let the C# compiler and project toolchain take care 
of the rest? Essentially it's only a syntax—the semantics is "turn it into 
this C# code."

-- 
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/a70bff98-e143-4c85-bcc9-2d919927764dn%40googlegroups.com.


Re: [racket-users] Plot Problem: No Line; Bounds not found

2021-06-15 Thread Ben Greenman
On 6/15/21, Britt Anderson  wrote:
> Thanks for the help to my specific problem. More generally, what should
> have clued me in to a contract or type error when the only message received
> had to do with y plot bounds? Just looking for practical advice to help me
> figure out things on my own going forward.

There's nothing in this program that could have clued you in besides
the empty plot.

Next time, I'd write tests for my function before sending it to plot's
`function` renderer.

-- 
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/CAFUu9R5FF6%3D4c0-KnkycMBeL0AaU9PHnKRELOH33J8b9NSXqzQ%40mail.gmail.com.


Re: [racket-users] Plot Problem: No Line; Bounds not found

2021-06-15 Thread Ben Greenman
On 6/15/21, Britt Anderson  wrote:
>
> I was starting to explore plot and I am getting a behavior I do not
> understand. plot doesn't seem to be able to figure out the bounds for
> something that seems pretty straight-forward. When I give bounds as an
> optional argument I don't see the line I expect to see. Can anyone provide
> me some pointers? I feel like I am just missing something conceptually and
> would appreciate some guidance. Here is some minimal code to demonstrate
> the problem.  I get a plot square, but no line, and I can demonstrate that
> the function generates reasonable numbers for this range of inputs.
>
>
>
> #lang racket
> (require plot)
> (require math/distributions)
>
> (define (norm-prior mu)
>   (lambda (sd)
>   (lambda (ind)
> (* ind (flnormal-pdf mu sd ind #f)
>
> (define d ((norm-prior 0.5) 0.1))
>
> (plot (function d 0 1 #:y-min 0.0 #:y-max 2.0 #:samples 100))
>
> (map d (range 0.0 1.0 0.01))
>

This is tricky.

Plot is calling your function `d` with inputs like 0, 1/99, and 1. All
of those give contract errors --- try (d 0) for yourself.

But when a plot function throws an error, the library ignores the
problem & keeps trying to draw a picture.

To fix, I'd change `norm-prior` to make a flonum:

 (define (norm-prior mu)
   (lambda (sd)
   (lambda (ind)
 (* ind (flnormal-pdf mu sd (exact->inexact ind) #f)

[[ Maybe plot should check if a function renderer produces no output
and throw an error then. ]]

-- 
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/CAFUu9R649zKbfduwRk57gdCnYbAZ29amvSX1%3D%3D__Zx7hbbop9Q%40mail.gmail.com.


[racket-users] Racket Slack archive update: privacy concerns

2021-06-09 Thread D. Ben Knoble
Update on the project to host an archive of the Racket Slack: I have been
directed to some privacy issues with the current proof-of-concept. Until 
these
issues are resolved, I have made the repository private and taken down the 
site.

If you have a copy of the archive files or site, I must ask that you refrain
from using them publicly until those impacted have a chance to decide what 
to
do.

If you wish to participate in the discussion, please join the Racket Slack 
[1,2]
and use the channel #slack-archive. You can also reach out privately to me 
and
Sam Tobin-Hochstadt, as we have become the organizers behind the archive. So
that I remain accountable and transparent, I would prefer any private
communication with me to include Sam.

The crux of the issue is data privacy: What data is in the archive? What 
are we
doing with private data? How are we using data from the archive? How are we
going to explain that to people? What will opt-in/opt-out look like?  
More
details in Slack.

[1] https://racket.slack.com/
[2] https://racket-slack.herokuapp.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/9d5115ae-45fa-451d-a6c1-c6df506dd61en%40googlegroups.com.


Re: [racket-users] Racket Slack archive [help wanted]

2021-06-08 Thread Ben Knoble


D. Ben Knoble

> 1) It wasn’t immediately clear to me that the links were the names of 
> channels. It seems painfully obvious to me now, but perhaps it’s worth 
> starting all the names with hashes?


Great idea, thanks. 

> 2) Clicking on the channel name “general” appears to melt down somehow, 
> presumably because the page is really really really big. Is pagination near 
> the top of most-desired-new-features?

Yeah, this is one of my top priorities. I’m thinking I’ll break it down by 
date. But I may want to rewrite the static generation in Racket first (to get 
it off Ruby + Jekyll, which may be unfamiliar to the community).


> Again, I think it’s great that you’re doing this!

Thanks :)

-- 
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/A2CF171A-71F5-4C75-9705-53A0F1419F00%40gmail.com.


[racket-users] Racket Slack archive [help wanted]

2021-06-08 Thread D. Ben Knoble
In case you missed it/aren't on Slack:

The latest version of the Slack archive is up-and-running at 
https://benknoble.github.io/racket-slack-archive/ (extends through roughly 
2021-06-07).

The site is now built using a mix of 
- Racket (data processing, mostly the json, hash, and unzip modules)
- Jekyll/Ruby (site-generation; a plugin makes pages out of all the channel 
directories, which are then rendered via a set of HTML templates)

I have some todos to make a nicer experience, and help is welcome. Also if 
anyone wants to start working porting the Jekyll + Ruby stuff to Racket, 
feel free.

-- 
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/a8efd2e6-ffb9-48d3-8b98-2d3da9551e70n%40googlegroups.com.


Re: [racket-users] Can a new user defined pkg encompass nothing more than references to previously defined pkgs?

2021-06-06 Thread Ben Greenman
On 6/6/21, Don Green  wrote:
>
> Can a new user defined pkg encompass nothing more than references to
> previously defined pkgs so that every  user created module references a
> single user defined pkg?

Yes. You can make a new package whose main.rkt provides lots of
identifiers from other packages.

`#lang reprovide` is a nice way to get this done:

  https://docs.racket-lang.org/reprovide/index.html

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFUu9R6_--DsiZY49BN5W8Mchs5WEXcfDk8DrsP1DwTXketMNg%40mail.gmail.com.


Re: [racket-users] Is there a good Racket DSL alternative to Image Magick?

2021-05-12 Thread Ben Greenman
On 5/12/21, Robert Haisfield  wrote:
> Daniel, that's awesome. How would I filter down this list according to the
> regex?
>
> (define list-of-files (map path->string (directory-list starting-path)))

You can wrap it in a filter:

  (define list-of-files (filter (lambda (str) (regexp-match? "\\.png$"
str)) (map path->string (directory-list starting-path


You might also like the glob package:

  (require file/glob)
  (define list-of-files (map path->string (glob (build-path
starting-path "*.png"

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


Re: [racket-users] student produces absolutely bonkers environment lookup code

2021-05-07 Thread Ben Greenman
On 5/7/21, Shu-Hung You  wrote:
> Not that I have any idea of what's going on, but interestingly, Typed
> Racket's second ->* example has (1)(3)(4). The use of list* may be
> possible if one follows the type (List* String Natural x) in the
> example.
>
> https://docs.racket-lang.org/ts-reference/type-ref.html?#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%2A%29%29
>
> Shu-Hung

+1, that example in the docs looks _very_ similar to the student code

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


Re: [racket-users] Package install conflicts on the Racket package catalog

2021-05-05 Thread Ben Greenman
On 5/5/21, Siddhartha Kasivajhula  wrote:
> Thank you, that helped me understand the issue. I've made the appropriate
> changes so hopefully that'll do it.
>
> This is reminding me that in python package distribution land, you are able
> to explicitly indicate which files make it into the package in a file
> analogous to info.rkt (setup.py, but also MANIFEST.in which allows you to
> bundle non-source files, I believe). Files besides these simply reside in
> the repository but don't make it into either source distributions or
> binaries. This could be a desirable feature to emulate in raco, since it
> would mean that (1) test modules need not be included as part of a
> collection even if present in the repo, (2) I've noticed that some Racket
> packages use a lib/test/docs breakdown with 3 separate packages; this seems
> non-ideal to me since they need to reside in 3 separate repos even though
> the non-source repos are essentially metadata (despite being written in
> full-fledged languages like scribble). By supporting something like a
> "source-include-paths" info.rkt declaration with a list of paths (similar
> to compile-omit-paths and test-include-paths), the tests and docs could all
> reside in the same source repo, without their (necessarily) becoming part
> of the installed package/collection. Any thoughts on this?

lib + tests + docs can all live in the same repo. For example:

https://github.com/97jaz/gregor

It does take some effort to get the organization right, but I don't
have any better ideas.

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


Re: [racket-users] Typed Racket: type relations

2021-04-19 Thread Ben Greenman
 3. I don't see any boundaries where you describe -- can you say more?
>>>
>>> Run typed-performance.rkt and see:
>>
>> This might be related to
>> https://github.com/racket/typed-racket/issues/289.
>>
>
> So basically my unsafe-reprovide module should probably use some syntax
> trickery to generate new bindings for all typed provides it requires and
> re-provide them unsafely renaming them back to original name? I think I
> can do something like that using relatively simple syntax macro.
>
> Do I understand it correctly?
>
> Of course Ben's hint at unsafe-reprovide is something I'd like to
> investigate.

My hint turned into a PR and merged a few years ago.
https://github.com/racket/typed-racket/pull/657

Here's the output I see from `typed-performance.rkt` . I'm on a commit
from Jan 20. Does this look more like you'd expect?

```
---
typed: cpu time: 2990 real time: 3023 gc time: 65
unsafe: cpu time: 405 real time: 408 gc time: 5
typed, unsafe provided: cpu time: 692 real time: 697 gc time: 10
plain: cpu time: 748 real time: 752 gc time: 3
---
typed: cpu time: 2817 real time: 2825 gc time: 11
unsafe: cpu time: 414 real time: 417 gc time: 3
typed, unsafe provided: cpu time: 671 real time: 675 gc time: 4
plain: cpu time: 750 real time: 754 gc time: 5
===
---
typed: cpu time: 1678 real time: 1684 gc time: 0
unsafe: cpu time: 161 real time: 165 gc time: 0
typed, unsafe provided: cpu time: 175 real time: 178 gc time: 0
plain: cpu time: 180 real time: 184 gc time: 0
---
typed: cpu time: 1744 real time: 1755 gc time: 0
unsafe: cpu time: 165 real time: 168 gc time: 0
typed, unsafe provided: cpu time: 164 real time: 167 gc time: 0
plain: cpu time: 195 real time: 198 gc time: 0
```

-- 
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/CAFUu9R4SX5BePy%2BNwM76iMrF%2BoMdtjxmZGKcS94USJ%2B8aHR5HQ%40mail.gmail.com.


Re: [racket-users] Re: How do I debug this performance problem?

2021-04-05 Thread Ben Greenman
> I've noticed that Typed Racket adds seemingly unnecessary chaperones when
> the Any type is involved, but maybe they are necessary for some reason? The
> following code tries to create a chaperone that I don't think is necessary.
>
> #lang racket
>
> (module m typed/racket
>   (provide f)
>   (: f (-> Any Any))
>   (define (f x) x))
> (require 'm)
>
> (struct s (a b) #:transparent #:authentic)
> (f (s 1 2))
>
> Is there a reason for the chaperone? Should I report this and similar
> situations as Github issues?

Typed Racket uses Any chaperones to protect its values from untyped
code. For example, if typed code sent a vector to untyped, then the
Any chaperone would prevent `vector-set!`s

I agree the chaperone isn't necessary in your example because `f`
never receives a typed value. I also can't think of a way to use an
un-chaperoned version of `f` to break type soundness ... so maybe
there is a general principle here, about how a typed function creates
an Any result, that TR could learn.

If you have ideas and/or more examples, then yes please open an issue.

-- 
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/CAFUu9R772b608dSGMgatukR%2BtaaSZokDaTKxek_n%3D4bhfczrgg%40mail.gmail.com.


Re: [racket-users] Sticky scrollable nav bar in docs

2021-02-18 Thread Ben Greenman
"sticky" looks worse to me on that example page --- I have to scroll
to the bottom of all the set docs before I can read the navbar

On 2/18/21, Yury Bulka  wrote:
> I agree this is a useful improvement. I would consider using "position:
> sticky" instead of "position: fixed" as that is generally less
> "intrusive" to the layout and doesn't create a need for a second scroll
> bar (the element would scroll as needed with the main scrollbar, but
> still be sticky in the sense that it would keep itself within the
> viewport).
>
> --
> Yury Bulka
> https://mamot.fr/@setthemfree
> #NotOnFacebook
>
>
>
> Sam Tobin-Hochstadt  writes:
>
>> This seems like it would be a nice addition. I think starting with a
>> PR is the right place to begin.
>>
>> Sam
>>
>> On Wed, Feb 17, 2021 at 7:01 PM 'William J. Bowman' via Racket Users
>>  wrote:
>>>
>>> One of my students asked about making the Racket docs navbar sticky and
>>> scrollable, to help when navigating very long docs pages. I made a quick
>>> hack and deployed it here:
>>>   https://www.students.cs.ubc.ca/~cs-411/docs/reference/sets.html
>>>
>>> Personally I've found it very useful. Would this change make sense for
>>> the Racket docs generally? (With some polish by someone who is better at
>>> UX than me?)
>>>
>>> To implement it, I just replaced `doc-site.css` with the following
>>>
>>> .navsettop {
>>> position: fixed;
>>> z-index: 1;
>>> background: #a7b0be;
>>> height: auto;
>>> }
>>>
>>>
>>> .tocset {
>>> position: fixed;
>>> overflow-y: scroll;
>>> height: 88%;
>>> }
>>>
>>> --
>>> William J. Bowman
>>>
>>> --
>>> 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/YC2uQ3BJIsMJTsMP%40williamjbowman.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/87zh01ht4j.fsf%40privacyrequired.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/CAFUu9R6DYLfFQdWhUEg-GZQ_GdFu9nvG_%2BuFkxLMv2-ndrhFHA%40mail.gmail.com.


Re: [racket-users] file/gzip trouble reading

2021-02-16 Thread Ben Greenman
On 2/16/21, Dominik Pantůček  wrote:
>
> On 16. 02. 21 22:27, Matthew Flatt wrote:
>> At Tue, 16 Feb 2021 16:03:29 -0500, Ben Greenman wrote:
>>> Sadly, I've already compressed a few files using
>>> `call-with-output-string` ... is there an easy way to decompress those
>>> / undo the UTF-8 encoding?
>>
>> Unfortunately, the underlying `get-output-string` conversion is lossy,
>> because bytes that don't form a UTF-8 encoding are converted to U+FFFD.
>>
>> (I see that the docs say #\? instead of #\uFFFD, and I'll fix the docs.)
>>
>
> #\uFFFD is #\� (bytes EF BF BD in UTF-8)
>
> For those who do not see it (I suspect encoding issues) it is a white
> question mark on black vertically elongated hexagon.
>
> And actually Racket REPL in my terminal displays it like this (7.9 BC,
> 8.0 CS, both on Ubuntu 20.04 in GNOME terminal).

Alas, I see lots of those question mark hexagons in my data. Good to know.

-- 
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/CAFUu9R5b5Y1kFQ0JuTtrTO-L14xFndABn-cSm44VB5s6H9wDRA%40mail.gmail.com.


Re: [racket-users] file/gzip trouble reading

2021-02-16 Thread Ben Greenman
On 2/16/21, Matthew Flatt  wrote:
> At Tue, 16 Feb 2021 15:44:54 -0500, Ben Greenman wrote:
>> But in my compressed string, the second
>> byte is #o357 for some reason. I'm not sure how that could have
>> happened ... some kind of encoding issue with string ports?
>
> Yes.
>
> You want `call-with-output-bytes` on the compress size and
> `call-with-input-bytes` on the decompress side. Otherwise, you'll get a
> UTF-8 decoding of compressed bytes (which is unlikely to be
> meaningful).
>

Thanks, that helps.

Sadly, I've already compressed a few files using
`call-with-output-string` ... is there an easy way to decompress those
/ undo the UTF-8 encoding?

-- 
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/CAFUu9R5%3DsJFybrJPsqyChCEyKmBD4-7xeM8RXFdkFc6xYa-hWw%40mail.gmail.com.


[racket-users] file/gzip trouble reading

2021-02-16 Thread Ben Greenman
I'm trying to use `gzip-through-ports` and I haven't been able to
unzip compressed data.

Here's a tiny example. I think this should print "hello world":

```
#lang racket

(require
  (only-in file/gzip gzip-through-ports)
  (only-in file/gunzip gunzip-through-ports))

(define src "hello world")

(define (compress str)
  (call-with-output-string
(lambda (out-port)
  (call-with-input-string str
(lambda (in-port)
  (gzip-through-ports in-port out-port #f 0))

(define (decompress str)
  (call-with-output-string
(lambda (out-port)
  (call-with-input-string str
(lambda (in-port)
  (gunzip-through-ports in-port out-port))

(define tgt (decompress (compress src)))

(displayln tgt)
```

But instead, it stops with "gnu-unzip: bad header"

The source code says that the header is the first two bytes, and these
should be #o037 and #o213. But in my compressed string, the second
byte is #o357 for some reason. I'm not sure how that could have
happened ... some kind of encoding issue with string ports?

-- 
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/CAFUu9R4%3DEPphxb44odmqYe9naSWuX7pu7KO0vGqRws537jGZBw%40mail.gmail.com.


Re: [racket-users] History changes

2021-01-10 Thread Ben Greenman
> It would be nice if I don’t have to modify scribble-lib, or, failing that,
> avoid touching documenting forms. Isn’t it possible for history to know
> which defform it’s under?

A history might not appear under a defform (for better or worse).

Maybe it's easier to give a list of links to the new history items. A
patch to @history could make an index tag ... something like
"h:7.4.0.3:hashtables" ... and then the search box might be good
enough to build a list of links.

-- 
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/CAFUu9R4v%3Dr30mikcTuD64UhKhuChD9z_9EZRf-7VweFX0_Be4g%40mail.gmail.com.


Re: [racket-users] Tools and Syntax Highlighting

2021-01-06 Thread Ben Ryjikov
Hi Robby and Stephen,

Thanks for your suggestions! It’s working now thanks to a mix of rackunit tools 
and dynamic require.
We’re also thinking about how to make our code less reliant on DrRacket.

Best,
Ben

> On Jan 4, 2021, at 8:11 PM, Robby Findler  wrote:
> 
> I think a good first question here is "what do you want to happen when you 
> are running the program from outside DrRacket?". DrRacket is, in a general 
> sense, designed to reflect extra information about how a program runs when it 
> can glean that information, but it isn't meant to be the only way that Racket 
> programs run, merely one of them. So what you want to think about is: how can 
> a program offer up information about itself (and what APIs/values/data should 
> that be)? and then: how can DrRacket (or other things that run Racket 
> programs, eg Racket Mode, or command-line racket or a standalone executable, 
> etc) get a hold of that information to show it in a meaningful way?
> 
> There are some examples of success following generally this pattern: test 
> coverage is a means whereby a program is expanded, then instrumented by some 
> tool (via rewriting the program) such that the instrumented program produces 
> information about what parts of the program actually ran to its context 
> (which might be DrRacket but might also be the "cover" library). Check Syntax 
> (which runs automatically these days) expands the program and records 
> information about it (notably binding and bound occurrences of variables) and 
> then DrRacket and Emacs Mode let you work with that information. 
> 
> Robby
> 
> 
> 
> On Mon, Jan 4, 2021 at 1:46 PM Ben Ryjikov  <mailto:bryji...@gmail.com>> wrote:
> I’m sorry - I didn’t explain what kind of highlighting we’re looking for.
> 
> We’re building a new #lang, and we want it so that sometimes when you run, 
> DrRacket highlights a part of the program you are running. But we only want 
> that in certain situations, so we want to create a function which we can call 
> that would do the highlighting on demand.
> 
> Are there any functions or libraries which can do that?
> 
> We’ve managed to get highlighting through a tool (which is listed in 
> info.rkt), but we’re struggling to get it on demand because we can’t easily 
> find a way for the tool and the program to share code.
> 
> Is there a way for a tool to access code which outside of the tool at runtime?
> 
> -Ben
> 
>> On Jan 4, 2021, at 9:04 AM, Stephen De Gabrielle > <mailto:spdegabrie...@gmail.com>> wrote:
>> 
>> On Mon, Jan 4, 2021 at 12:32 AM Ben Ryjikov > <mailto:bryji...@gmail.com>> wrote:
>> Hi Racket,
>> 
>> Is it possible for a tool invoked by info.rkt to access code which is 
>> outside of the tool?
>> 
>> We’re building a #lang and would like to have on-demand syntax highlighting.
>> We’ve tried using a tool, and have successfully made a button and a menu 
>> item that do it, but we’d like to activate the highlighting programmatically 
>> at runtime instead of by clicking on something.
>> We also are hoping to have multiple highlights at once if possible.
>> 
>> Is there any way to get on-demand syntax highlighting without using a button 
>> or menu item? Are there any pre-existing Racket tools or functions that 
>> would do this?
>> 
>> I think datalog does this;
>> 
>> 
>> 
>> 
>>  
>> 
>> Thanks for your time and Happy New Year!
>> 
>> Best,
>> Ben
>> 
>> -- 
>> 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 
>> <mailto:racket-users%2bunsubscr...@googlegroups.com>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/BA1B6C4F-8172-462F-9E2D-8F6F2A9C6BB4%40gmail.com
>>  
>> <https://groups.google.com/d/msgid/racket-users/BA1B6C4F-8172-462F-9E2D-8F6F2A9C6BB4%40gmail.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 
> <mailto:racket-users+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/C549A2BB-8999-496B-B119-70239EB13EDB%40gmail.com
>  
> <https://groups.google.com/d/msgid/racket-users/C549A2BB-8999-496B-B119-70239EB13EDB%40gmail.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/420DFA37-A971-403B-AD4B-F4C22B27453E%40gmail.com.


Re: [racket-users] Tools and Syntax Highlighting

2021-01-04 Thread Ben Ryjikov
I’m sorry - I didn’t explain what kind of highlighting we’re looking for.

We’re building a new #lang, and we want it so that sometimes when you run, 
DrRacket highlights a part of the program you are running. But we only want 
that in certain situations, so we want to create a function which we can call 
that would do the highlighting on demand.

Are there any functions or libraries which can do that?

We’ve managed to get highlighting through a tool (which is listed in info.rkt), 
but we’re struggling to get it on demand because we can’t easily find a way for 
the tool and the program to share code.

Is there a way for a tool to access code which outside of the tool at runtime?

-Ben

> On Jan 4, 2021, at 9:04 AM, Stephen De Gabrielle  
> wrote:
> 
> On Mon, Jan 4, 2021 at 12:32 AM Ben Ryjikov  <mailto:bryji...@gmail.com>> wrote:
> Hi Racket,
> 
> Is it possible for a tool invoked by info.rkt to access code which is outside 
> of the tool?
> 
> We’re building a #lang and would like to have on-demand syntax highlighting.
> We’ve tried using a tool, and have successfully made a button and a menu item 
> that do it, but we’d like to activate the highlighting programmatically at 
> runtime instead of by clicking on something.
> We also are hoping to have multiple highlights at once if possible.
> 
> Is there any way to get on-demand syntax highlighting without using a button 
> or menu item? Are there any pre-existing Racket tools or functions that would 
> do this?
> 
> I think datalog does this;
> 
> 
> 
> 
>  
> 
> Thanks for your time and Happy New Year!
> 
> Best,
> Ben
> 
> -- 
> 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 
> <mailto:racket-users%2bunsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/BA1B6C4F-8172-462F-9E2D-8F6F2A9C6BB4%40gmail.com
>  
> <https://groups.google.com/d/msgid/racket-users/BA1B6C4F-8172-462F-9E2D-8F6F2A9C6BB4%40gmail.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/C549A2BB-8999-496B-B119-70239EB13EDB%40gmail.com.


[racket-users] Tools and Syntax Highlighting

2021-01-03 Thread Ben Ryjikov
Hi Racket,

Is it possible for a tool invoked by info.rkt to access code which is outside 
of the tool?

We’re building a #lang and would like to have on-demand syntax highlighting.
We’ve tried using a tool, and have successfully made a button and a menu item 
that do it, but we’d like to activate the highlighting programmatically at 
runtime instead of by clicking on something.
We also are hoping to have multiple highlights at once if possible.

Is there any way to get on-demand syntax highlighting without using a button or 
menu item? Are there any pre-existing Racket tools or functions that would do 
this?

Thanks for your time and Happy New Year!

Best,
Ben

-- 
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/BA1B6C4F-8172-462F-9E2D-8F6F2A9C6BB4%40gmail.com.


Re: [racket-users] Scribble and main.rkt

2020-12-22 Thread Ben Greenman
> Is it correct that calling the main file of the package something else than
> main.rkt is bad style, unsupported by Scribble?

It's okay to call the main file something else, but you'll have to
tell Scribble about it.

Right now, I guess you have a @defmodule[typed-compose]{}
somewhere. That would tell Scribble that the defprocs below come from
typed-compose/main.rkt

If the main module is typed-compose.rkt, then a
@defmodule[typed-compose/typed-compose]{} should fix the broken
links.
(And, it'll tell readers how to require the things below.)

-- 
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/CAFUu9R5xEQcR8qdtHOQnKYLbZa%3D4WE0T9uxdEv0zNiKQFvd8-A%40mail.gmail.com.


Re: [racket-users] compose in Typed Racket

2020-12-10 Thread Ben Greenman
>> A package for compose-n and compose-3 to like 10 or 20?

Yes

I like the idea of _small packages that do one thing_ better than
_one-stop all-utility packages_ ... but do what you think makes sense.

>> Someday later, perhaps poly dots and #:rest-star can combine to
>> improve the built-in type.
>>
>
> From my naive viewpoint, I don't really see other natural ways of improving
> the type of compose other than what I wrote, the problem being that writing
> the type for arbitrary-arity composition would require specifying equality
> between the return type of every function and the argument type of the
> preceding one.  I'm not sure even Coq and Agda have that facility directly,
> certainly not Haskell or Idris to the best of my knowledge.  I don't expect
> them to go beyond binary compose, because it's sufficient to do any
> compositions.  It's that in Racket I find writing chains of nested compose
> calls somewhat clunky.

Typed Racket already has some domain-specific ideas to support the
#:rest-star option. The equality-chaining constraint is definitely
new, but doesn't seem out of the question.

https://github.com/racket/typed-racket/blob/master/typed-racket-lib/typed-racket/rep/type-rep.rkt#L586-L612

I think other languages (Coq Agda Haskell Idris) have a harder time
here because they want to support currying. And even if they added
#:rest-star logic, their users might call it an anti-pattern because
it doesn't fit with partial application.

-- 
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/CAFUu9R5o7WMvewXTLgafdX-Ei%2B6MnsM13xHW-pauSGs3scTJBA%40mail.gmail.com.


Re: [racket-users] compose in Typed Racket

2020-12-09 Thread Ben Greenman
> If the answer is no, is there any interest in including these three
> functions (as well as compose-5, 6, 7, 8) into Typed Racket?

I think these would be excellent in a package.

Someday later, perhaps poly dots and #:rest-star can combine to
improve the built-in type.

-- 
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/CAFUu9R4ty94AWdQxxLGaveNN3aZitU2qf8sbC4_foQ47xk%3DK4g%40mail.gmail.com.


Re: [racket-users] multi line scribble text body in web-server template

2020-11-01 Thread Ben Greenman
Thats the nor

On 11/1/20, krs...@gmail.com  wrote:
>
> Hi!,
>
> I am using web-server/templates
> .
> I am confused why this just displays the last line?:
>
> @when[#t]{
> first
> second
> }

That's normal "when" behavior

```
Welcome to Racket v7.8.0.5 [cs].
> (when #t "first" "second")
"second"
```

One fix is to put a list of text in the `when` body. He's how I'd write it:

```
#lang at-exp racket

@(define (when-logged-in . pc*)
   (when #t
 pc*))

@when-logged-in{
  first
  second
}
```

-- 
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/CAFUu9R5y6%2B6dCeEYEYRTmKVcHr%3DgZQ9UbztXyy82hKD6AxjPNA%40mail.gmail.com.


Re: [racket-users] Contracts for (partially) specifying dictionary key -> value-predicates

2020-10-31 Thread Ben Greenman
On 10/31/20, jackh...@gmail.com  wrote:
> I'm not sure, but I have a feeling Ben's suggestion to make them functions
> instead of macros wasn't about the performance implications of macros.

Right. I was only thinking that macros are hard to build on. But then,
I can use dictof/proc here.

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


[racket-users] large hash/dc errors (was: Contracts for (partially) specifying dictionary key -> value-predicates)

2020-10-30 Thread Ben Greenman
> Ben: if you have an example of the bad hash/dc error message I'd be
> interested to see it.
>
> Robby

Here's the kind of message that turned me off:

```
ctc.rkt:34:0: broke its own contract
  promised: (hash/dc (k (or/c (quote a) (quote b) (quote c))) (v (k)
(config-value/c k)) #:immutable #t #:kind (quote flat))
  produced: '#hash((a . 1) (b . #t) (c . #))
  in: (hash/dc
   (k (or/c 'a 'b 'c))
   (v (k) (config-value/c k))
   #:immutable
   #t
   #:kind
   'flat)
  contract from: +
  blaming: +
   (assuming the contract is correct)
```

It prints the whole hash and contract, leaving me to figure out the
two key parts: (1) what piece of the hash failed, and (2) what the
contract expected for that piece.

Now that I think of it ->* is bad in the same way --- especially for
`plot` functions.


Here's the code that made that error message. The #;(lambda )
comment is the contract that I ended up using instead of hash/dc (it
still doesn't explain bad values well).

```
#lang racket/base

(require racket/contract)

(provide config/c)

(define config-key/c
  (or/c 'a 'b 'c))

(define (config-value/c k)
  (case k
((a)
 string?)
((b)
 boolean?)
((c)
 void?)))

(define config/c
  #;(lambda (h)
(for ((k (in-list (list 'a 'b 'c
  (unless (hash-has-key? h k)
(raise-arguments-error 'config/c "missing key" "key" k "hash" h))
  (define v (hash-ref h k))
  (unless ((config-value/c k) v)
(raise-arguments-error 'config/c "bad value for key" "key" k
"value" v "hash" h))
  (void)))
  (hash/dc
[k config-key/c]
[v (k) (config-value/c k)]
#:immutable #true
#:kind 'flat))

(contract
  config/c
  (hash 'a 1 'b #true 'c (void))
  '+
  '-)
```

-- 
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/CAFUu9R61khGypp61r6A4i%2BrO8C7O%3D4TLy23KdF9aOpeeSy_4UQ%40mail.gmail.com.


Re: [racket-users] Contracts for (partially) specifying dictionary key -> value-predicates

2020-10-30 Thread Ben Greenman
On 10/29/20, William J. Bowman  wrote:
> I'm considering implementing, maybe as a library or a pull-request to
> racket/dict, contracts for (partially) specifying which keys exist in a
> dictionary and a contract for the value on that key.

Great!

Please make the contract error messages point out the bad key and bad
value. The error messages from hash/dc are usually too big for me, and
I end up moving my key-check and value-check contracts into a function
that checks things one-by-one.

(Maybe hash/dc can give better errors ... I never looked into a fix.)

> I've got a quick prototype here:
>
>   https://gist.github.com/wilbowma/7e97c8a38130c720568d008b288466f0
>
>   (dictof (id expr) ...)
>   A contract for a dictionary that contains exactly the keys id ... that map
> to
>   values that satisfy the contracts expr ... (respectively).
>
>   (rho-dictof (id expr) ...)
>   A contract for a dictionary that contains at least the keys id ... that
> map to
>   values that satisfy the contracts expr ... (respectively).
>
> Before I start documenting and making it a thing, I thought I'd solicit
> feedback.

Two comments:

1. make these functions, not macros

2. make "at least" the default behavior for dictof, add an option to
override (#:exact-keys?), and remove rho-dictof

-- 
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/CAFUu9R7SMK%2BfCxGDHGm_eu%2BmTfcZ%2BZdC4R_dMceg%2Bn6VyY8oXQ%40mail.gmail.com.


[racket-users] Re: Typed Racket Survey — RSVP

2020-10-23 Thread Ben Greenman
Reminder: the survey will close at the end of this weekend
(Sunday Oct 25 11:59pm anywhere on earth).

Thank you to everyone that's filled it out so far!

On 10/17/20, Ben Greenman  wrote:
> Hi Racketeers,
>
> Hope you are having a great RacketCon weekend.
>
> Typed Racket was designed by a few people to serve a broad community —
> you included.
>
> Today, we are looking for feedback to guide the design going forward.
>
> Please share your thoughts and experiences (if any) regarding Typed
> Racket. Even if you've never used --- or even heard about --- Typed
> Racket, we want to hear from you!
>
> https://tinyurl.com/typed-racket-survey
>
> Feel free to email Ben if you have more feedback or questions.
>
> The survey will remain open for 1 week. After it's closed, we will
> share the (anonymized) results.
>
> Thank you,
>
> Ben Greenman & Shriram Krishnamurthi
>

-- 
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/CAFUu9R6X4O9XTqaGhEG-CGtAZ%3D1sHKEECUisfCciO_AjXNxbCw%40mail.gmail.com.


Re: [racket-users] [racket users] Macros sharing data?

2020-10-21 Thread Ben Greenman
You can use syntax-local-value to communicate across macros.

Here's an example:
https://docs.racket-lang.org/syntax-parse-example/index.html?q=cross-macro#(mod-path._syntax-parse-example%2Fcross-macro-communication%2Fcross-macro-communication)


On 10/21/20, Kevin Forchione  wrote:
>   Hi guys,
> Suppose I have a macro that computes a value and then calls another macro in
> its template. Is there a way to share that data with the 2nd macro without
> passing it as an argument?
>
> Thanks!
> Kevin
>
> --
> 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/5425EC92-110D-47B4-BCFB-D2B6C09BBF32%40gmail.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/CAFUu9R5i5pNGVj14NuUM7j6dJfHS3TsFTt2D6kAxLRL%2B1rymGg%40mail.gmail.com.


[racket-users] Typed Racket Survey — RSVP

2020-10-17 Thread Ben Greenman
Hi Racketeers,

Hope you are having a great RacketCon weekend.

Typed Racket was designed by a few people to serve a broad community —
you included.

Today, we are looking for feedback to guide the design going forward.

Please share your thoughts and experiences (if any) regarding Typed
Racket. Even if you've never used --- or even heard about --- Typed
Racket, we want to hear from you!

https://tinyurl.com/typed-racket-survey

Feel free to email Ben if you have more feedback or questions.

The survey will remain open for 1 week. After it's closed, we will
share the (anonymized) results.

Thank you,

Ben Greenman & Shriram Krishnamurthi

-- 
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/CAFUu9R5owBOs_j12X%2B-WvGBH4jLkJ%3Dak9Sxdbm8bzJPZYPzYEQ%40mail.gmail.com.


Re: [racket-users] [scribble] Are nested lists possible?

2020-10-13 Thread Ben Greenman
On 10/13/20, David Storrs  wrote:
> @itemlist[
>   @item{The size cage needed depends on the type of dog
>   @itemlist[
> @item{Pug:  Small}
> @item{Collie: Medium}
> @item{Mastiff:  Large}]}]
>
> I would like to produce something that looks like this:
>
>- The size cage needed depends on the type of dog
>   - Pug: Small
>   - Collie: Medium
>   - Mastiff: Large
>
> Is there a correct way to do this?

What you have looks good to me in #lang scribble/manual

-- 
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/CAFUu9R4-4BO3Gi2PDxZ%3D2BbQCrJP4O%2BkAWT1f7DJJtFapFdYTA%40mail.gmail.com.


Re: [racket-users] Scribbling hexadecimal values

2020-09-18 Thread Ben Greenman
+1

For now, I've used hacks like `(string->number "#x...")` for typesetting
https://docs.racket-lang.org/pict-abbrevs/index.html

On 9/18/20, Dominik Pantůček  wrote:
> Hello Racketeers,
>
> I am struggling to make scribble typeset default values in
> proc-doc/names in hexadecimal. An example would be:
>
> (proc-doc/names
>   name
>   (->* () (integer?) void?)
>   (()
>((argument #x1f)))
>   @{ some description }) ; yes, at-exp reader
>
> The same applies to values in nested contracts of ->* - like (integer-in
> 0 #x1f).
>
> Of course #,(~a "~x" #x1f) will produce the string with appropriate
> contents - but enclosed in parentheses which does not help much. Also it
> is not just a matter of typesetting because the provide form really
> contracts the procedure being provided and the actual values should
> actually be present.
>
> I would love to see some documentation-stage parameter where I could
> just (parameterize ((numbers-as-hexadecimal #t)) (integer-in ...) ...)
> and it would keep the values as they are for contract purposes and
> render them hexadecimal. Of course, this is quite specific - more
> generic solution is probably more appropriate, this is just to explain
> the problem I am trying to solve.
>
>
> Cheers,
> Dominik
>
> --
> 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/aca5b2ab-36b6-98c6-0747-9d5447ae9766%40trustica.cz.
>

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


Re: [racket-users] Advice for beginner

2020-09-08 Thread Ben Greenman
The student languages are not subsets of Racket.


On 9/7/20, Denis Maier  wrote:
>
> Hi,
>
> I've started working with the Htdp textbook as I'd like to acquire a solid
> foundation in (functional) programming. The approach to teaching
> programming looks very promising. Having this ressource available online
> for free is absolutely amazing. Thank you.
>
> One slight annoyance I came across: I've found running code snippets with
> the beginning languages rather slow, much slower than with `#lang racket`.
> Why is that? Anything I could do to make that more performant? (Actually,
> running simple racket snippets is much faster in the REPL than with
> DrRacket. Is there a way to use the BSLs on the command line?)
>
> Or: Could I just use work through the textbook with `#lang racket`? How
> different is racket from the student languages? Are they subsets, i.e. will
>
> everything that works in those languages also work with racket proper?
>
>
> All the best,
> Denis Maier
>
> --
> 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/ec53a53a-bc4e-4fb1-a92a-87682cb8f731n%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/CAFUu9R46WFDzGbRm7vOwd1QQqYfCX%2B5PrnTXFsQL8JK-pn2yww%40mail.gmail.com.


Re: [racket-users] Proper place to store log file

2020-08-24 Thread Ben Greenman
On 8/24/20, Thomas Del Vecchio  wrote:
> Hi everyone!
>
> I'm currently working on some usage logging for a language we're
> developing. We need to store a persistent file that is shared across a
> given device (so that the same log file is used regardless of where you are
>
> working). Is there a best place to put this file? I'm looking at
> find-system-path
> ,
>
> but am not sure from the documentation if one of these is best for this
> purpose.
>
> One option I'm considering is in `(collection-file-path (build-path
> "logging" "user-logs.log") "")`, which is just
> "///logging/user-logs.log", but I'm unsure whether
> it's safe to store user data there (especially if we are expecting to have
> package updates).
>
> Thanks so much!
> Thomas

Try the `basedir` package. You can ask for a `(writeable-data-file
"user-logs.log" #:program "")`.

https://docs.racket-lang.org/basedir/index.html

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFUu9R6aX9ijNkUOa-Rq5C4xer4MkiqUycN2veNtx%3DPzduaANQ%40mail.gmail.com.


Re: [racket-users] Replace pre-installed rackunit with git source

2020-07-22 Thread Ben Greenman
On 7/22/20, Sam Tobin-Hochstadt  wrote:
> To figure out where things are, I recommend the `raco fc` command,
> which is in the `raco-find-collection` package.
>
> Almost certainly what went wrong is that you installed the cloned
> `rackunit` directory as a package. Instead, you need to install all
> the individual sub-directories as packages. To fix that, first remove
> the installed `rackunit` package, and then just re-install the regular
> `rackunit`.
>
> To accomplish your original goal, you should use `raco pkg update
> --clone rackunit` in whatever directory you want to clone rackunit
> (such as `extra-pkgs`). If that complains about `rackunit` not having
> a git repository as source, then you should first do `racket pkg
> update --lookup --catalog https://pkgs.racket-lang.org rackunit` to
> switch from the 7.7 catalog to the pkgs.racket-lang.org one.
>
> Sam
>

You might also be able to force-remove again, then install everything
you just killed.

$ raco pkg remove --force rackunit-doc rackunit-test rackunit-typed
rackunit-gui etc
$ raco pkg install ./rackunit-doc ./rackunit-test ./rackunit-typed
./rackunit-gui etc

-- 
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/CAFUu9R4vYGZFqAx6UdeL7%3DggRE-X9VCKMDXDwnu_2Ro-JkLMVA%40mail.gmail.com.


Re: [racket-users] require and syntax-case

2020-07-13 Thread Ben Greenman
On 7/13/20, Roman Klochkov  wrote:
> I tried
> ```
> (define-syntax my-file
>   (make-require-transformer
>(lambda (stx)
>  (syntax-case stx ()
>[(_ path)
> (printf "Importing: ~a~n" #'path)
> (expand-import #'(file path))]
> (require (my-file "test.rkt"))
> ```
> with the same result: no errors in require, but no imports.
>
> So, it seems, that the only solution is datum->syntax. It works fine.

There is another way: syntax-local-introduce will remove the macro scope.

```
(define-syntax (req2 stx)
  (syntax-case stx ()
[(_ (x y)) (syntax-local-introduce #'(require (x y)))]))
```

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


Re: [racket-users] "is not in my domain"

2020-06-01 Thread Ben Greenman
On 5/29/20, Beatriz Moreira  wrote:
>
>
> Hi, im a beginner with racket and im using it to implement a language in
> order to test its operational semantic rules.
>
> This is the function where i keep having the error:
>
> (define-metafunction FS
>
> call : env-ß classes address f ((x v)...) -> e
>
> [(call (env-ß_1 ... ((address_1 C_1 n_1 vars_1 ...) ... (address C n vars
> ...) (address_2 C_2 n_2 vars_2 ...) ...) env-ß_2 ...)
>
> ((contract C_1 {x_11 ...} F_1) ... (contract C {x_1 ...} f (x ...) {return
> e}) (contract C_2 {x_22 ...} F_2) ...) address f ((x v)...))
>
> e])
>
>
> And this is the error message :
>
> ../../../../../../../Applications/Racket
> v7.6/share/pkgs/redex-lib/redex/private/reduction-semantics.rkt:1588:55:
> call: (call (((2 C 4 (x 3) (r 9)) (9 A 24 (a 9) (b 5 ((contract C (x r)
>
> (a (d y) (return (y + d (contract A (a b) (c (a b) (return (3) 2 a
> (d 7) (y 3)) is not in my domain
>
> I have tried changing the parenthesis but i can't seem to get it right.
> Here's the code
>  .Thank
>
> you guys for your help! :)

The "not in my domain error" happens when a metafunction gets either
the wrong number of arguments or the wrong shape for a certain arg.

Once you have the right number of arguments, `redex-match?` can help
check shapes.

```
(require rackunit)
(check-true (redex-match? FS env-ß (term (((2 C 4 (x 3) (r 9)) (9 A 24
(a 9) (b 5)))
```

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


Re: [racket-users] Inference for polymorphic functions not supported?

2020-05-18 Thread Ben Greenman
On 5/18/20, Hendrik Boom  wrote:
> I keep getting the messages like
>
> Type Checker: Inference for polymorphic keyword functions not supported in:
> (sort hash-list string (symbol->string (car p))) #:cache-keys? #t)

The way to avoid guesswork here is `inst`:

 ((inst sort (Pair Symbol Natural) String) )

Next time you see one of these errors, print the type of the function
or check the DrRacket blue box to figure out which/how many arguments
the `inst` needs.

> or
>
> Type Checker: Polymorphic function `cons' could not be applied to
> arguments:
> Types: a (Listof a) -> (Listof a)
>a b -> (Pairof a b)
> Arguments: (U Exact-Nonnegative-Integer Symbol) (Listof (Pairof Symbol
> Nonnegative-Integer))
> Expected result: (Listof (Pairof Symbol Nonnegative-Integer))
>  in: (for*/list : (Listof (Pair Symbol Natural)) ((p : (Pair Symbol Natural)
> (in-list (hash->sorted-list pname-map))) (k : Symbol (in-value (car p))) (v
> : Natural (in-value (cdr p))) #:when (not (= v 1)) (y (list k v))) y)
>
> Is there some systematic way to code this explicitly so it
> doesn't have to try guesswork? (hich it refuses to do)
>
> And is it really unable to figure out that an
> Exact-Nonnegative-Integer is a Nonnegative-Integer?

This looks like a genuine type error, because (U
Exact-Nonnegative-Integer Symbol) is not a Pair.

Should the loop body say `p` instead of `y`?

-- 
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/CAFUu9R7v4wnd9WrOdNEd6f4oTn5oGhPbe%3DtSgympmDuPQt0N3A%40mail.gmail.com.


Re: [racket-users] Mysterious multiple values in a typed-racket program

2020-05-09 Thread Ben Greenman
On 5/9/20, Hendrik Boom  wrote:
> I get the message
>
> readspec.rkt:195:8: Type Checker: Expression should produce 3 values, but
> produces 1 values of types String in: (for/set : (Setof String) (((l :
> String) (cast (in-lines input-port) (Sequenceof String (cast
> (string-trim l) String))
>
> from the following function:
>
> (define (read-manpages [input-port : Input-Port])
>   (cast (for/set : (Setof String) (([l : String] (cast (in-lines input-port)
> (Sequenceof String
>(cast (string-trim l) String))
> (Setof String)))
>
> The expression it is complaining about is the (for/list ..)
> construction.
>
> I'm trying to covert a Racket program to a typed Racket program.
> As far as I can see, this function reads words, one to a line, from
> input-port and makes a set of these words.
>
> It baffles me where the type checker gets the idea that 3 values are wanted
>
> anywhere.
>
> I put in a lot of casts just to make sure I knew what types it had to work
> with.
>
> The original code, without types:
>
> (define (read-manpages input-port)
>   (for/set ((l (in-lines input-port)))
>(string-trim l)))
>
> Any ideas?

Well this is unfortunate.

`(l : String)` should be `l : String` with no parentheses

The code you have looks like this to Typed Racket:

```
(for/set : TYPE
  (((val0 val1 val2) (in-lines input-port)))
  LOOP-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/CAFUu9R7wBS_hbZpXmFR097qxi8F-54rkogEXe6R0Nyqp_iMqDQ%40mail.gmail.com.


Re: [racket-users] Rhombus project plan

2020-04-30 Thread Ben Greenman
On 4/29/20, Sorawee Porncharoenwase  wrote:
> (Not directly related to Rhombus) Speaking of “how to contribute”, I find
> that it is not friendly at all to setup stuff in order to contribute to
> Racket core and main distribution. According to
> https://blog.racket-lang.org/2017/09/tutorial-contributing-to-racket.html,
> if I want to make a change to, say, https://github.com/racket/math, I
> should start with:
>
> $ raco pkg update --no-setup --catalog https://pkgs.racket-lang.org math
> $ raco pkg update --clone math
>
> The estimated time to run the above two commands is ONE HOUR! The second
> command in particular seems to compile every Racket packages (why does it
> need to do that?!?) which takes a lot of time.

That second command recompiles only the packages that depend on math.
Unfortunately there are a lot of them.

-- 
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/CAFUu9R6DkRjxd_YNrLGLa%2BCc2q8zUk5MfuTDzcP%2BpAZ_CM43eQ%40mail.gmail.com.


Re: [racket-users] Location grabbing in typed/rackunit

2020-04-28 Thread Ben Greenman
On 4/28/20, shane c  wrote:
> I think require/typed/provide in typed/rackunit is affecting the location
> grabbing feature. Hoping someone can provide a suggested path forward. When
>
> I run this program,
>
> #lang typed/racket/base
>
> (require typed/rackunit)
> (check-true (string (check-true (string (check-true (string
> The last expression turns out to be (check-true #f) so an error is printed.
>
> However the error location points to rackunit source.
>
> 
> string FAILURE
> name:   check-true
> location:
>   /Applications/Racket
> v7.6/share/pkgs/rackunit-typed/rackunit/main.rkt:33:2
> params: '(#f)
> 
>
> I can switch to (require rackunit) in #lang racket/base and the location
> points to the source file as expected.
>
> P.S. thanks for all your hard work. -shane

Right, require/typed/provide is turning off the location tracking.

Possible fix: add a `check-true` macro to typed/rackunit that calls
the require/typed `check-true` inside of a `(with-check-info )`
The macro should also set the check expression.

Can you open an issue for this in the rackunit repo?

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


Re: [racket-users] Functions not being linked in scribble

2020-04-28 Thread Ben Greenman
On 4/28/20, David Storrs  wrote:
> According to what I see in Scribble, both actual examples and in the
> documentation, I had thought that if I did @defproc[func-name] then
> func-name would become a link target and later uses of @racket[func-name]
> would automatically link to that site.  I'm clearly missing something; my
> functions are being rendered in link style but they have red links under
> them and are not actually links.  Can someone point me in the right
> direction?

Did you (require (for-label  func-name)) ?

-- 
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/CAFUu9R5%3Dk-WHJ87FHFbLFj-XWy9%2BhMrsVGXcGfeA834s25EfVg%40mail.gmail.com.


Re: [racket-users] a question or two regarding Gregor

2020-04-27 Thread Ben Greenman
On 4/27/20, Tim Hanson  wrote:
>
> I thought I'd check here:
> - does this seem like a reasonable idea?
> - is mine an unusual use case and most folks know what format to expect and
> the exception approach is fine?

I've written code like this before and used it in a contract.

```
(define (iso8601-string? x)
  (and (string? x)
   (with-handlers ((exn:gregor:parse? (lambda (e) #false)))
 (date? (iso8601->date x)

(module+ test
  (test-case "iso8601-string?"
(check-pred iso8601-string? "2018-10-02T01:00:00")))
```

I haven't had to worry about its performance; it was fast enough!

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


Re: [racket-users] Gradual Typed Racket?

2020-04-17 Thread Ben Greenman
On 4/17/20, Sorawee Porncharoenwase  wrote:
>>
>> My understanding is that contract-out only provides protection against
>> inappropriate calls from clients *outside* the module, whereas
>> define/contract enforces the contract against everyone, including things
>> inside the module.  Do I have that right?
>>
>
> I think that's correct. Note though that the implication is that
> define/contract could produce a much more expensive code, especially for
> recursive function, since it will need to check against the contract for
> every iteration.
>
>
>> On a related topic, I don't understand the concept of positive and
>> negative blame.  Can someone fill me in?
>>
>
> I always forget which is positive and negative, so I won't use the terms
> here (and too lazy to lookup). But roughly, suppose you attach a function
> contract (-> number? string?) to a function value, then there are mainly
> two ways things could go wrong.
>
> 1. Client uses the function incorrectly by calling it with non-number.
> 2. The function itself returns a non-string.
>
> A blame would indicate whose party is at fault when a contract is
> violated--caller or the function itself.

1 = negative = the client that uses the value
2 = positive = the code that made the value

But unless you're using `contract` directly, you don't need to know
these words to benefit from contracts.

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


Re: [racket-users] Gradual Typed Racket?

2020-04-17 Thread Ben Greenman
Hi Marc,


>> For contracts, though, (provide (contract-out ...)) gives better error
>> messages than define/contract.
>>
>
> In what sense is this the case, and where can I read more about the
> differences, as well as how to improve errors of contracts?

contract-out gives better error messages than define/contract in the
sense that it has better blame

A define/contract needs to immediately decide who could be blamed for
future errors --- because the new definition can be used right away.

A contract-out can wait until another module requires the definition
--- and tailor its blame errors to different clients.

Here's an example to play with. Submod A provides two functions: f0 is
made with define/contract and f1 with contract-out.

```
  #lang racket

  (module A racket
(define/contract (f0 x)
  (-> natural? natural?)
  x)

(define (f1 x)
  x)

(provide f0)
(provide (contract-out [f1 (-> natural? natural?)])))

  (module B racket
(require (submod ".." A))
(f0 'hello)
#;(f1 'hello))

  (require 'B)
```

If B makes a mistake with f0, the error blames submod A.
But if B makes a mistake with f1, the error blames B.


The contract library makes these blame errors internally. I don't
think there's any way to customize short of using `contract` directly.

> Is it related to this part of the documentation of `contract-out`
> (https://docs.racket-lang.org/reference/attaching-contracts-to-values.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._contract-out%29%29)
> - which I admittedly don't understand:
>
> "The implementation of contract-out
> 
> uses syntax-property
> 
> to attach properties to the code it generates that records the syntax of
> the contracts in the fully expanded program. Specifically, the symbol '
> provide/contract-original-contract is bound to vectors of two elements, the
> exported identifier and a syntax object for the expression that produces
> the contract controlling the export."

I was only thinking of the "blaming: " part of error messages.

Both define/contract and contract-out can print the whole contract; I
don't think this syntax-property gives contract-out any advantage

(Sadly, the whole contract is sometimes too big to help me find a problem.)

-- 
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/CAFUu9R5BMG5ZFVrddrJ-6uceV%2B3936ZudE-8ESObycw9B%2BRjcg%40mail.gmail.com.


Re: [racket-users] Unfinished S-Expressions in scribbled code blocks

2020-04-12 Thread Ben Greenman
> What is the proper way of typesetting (in scribble) parts of racket code
> which do not form complete S-expression?

The proper way is to make a #lang (in particular, a `read-syntax`)
that deals with incomplete S-expressions.

I don't know if anyone has done / attempted this.

An improper way is to use `verbatim` for now and do without color:

```
#lang scribble/manual

@(define (mycode #:indent [indent 0] . content*)
   (nested #:style 'code-inset (apply verbatim #:indent indent content*)))

... and here are the requires:

@mycode|{
(require
}|

.. with the first one being this and we need that for 

@mycode[#:indent 2]|{
  (only-in ffi/unsafe ptr-set! _uint32)
}|
```

-- 
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/CAFUu9R4gvGL8hoVQj4Ui_A4FDABbugnvTEJT%2BpACOoh-t4nMBA%40mail.gmail.com.


Re: [racket-users] typed mutable fields in structures.

2020-04-12 Thread Ben Greenman
Yes, that's right.

I think TR could support this choice ... the typechecket
(tc-structs.rkt) seems to know about the per-field mutability that
comes from a struct info.

On 4/11/20, Hendrik Boom  wrote:
> I noticed that in regular Racket, when defining a structure, it is
> possible for each field to be mutable independent of the other fields.
>
> In Typed Racke I find the choice only of making all the fields or none
> of them mutable.
>
> Is this correct, or have I missed something?
>
> -- 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/20200411141747.ijbhuadzsy5r56ge%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/CAFUu9R5ZDO73_Th-VPRPk8%3Da6yWdstmGg6Fh9SKu1eTL%2BZqw4Q%40mail.gmail.com.


Re: [racket-users] Suggestions for "The Racket Guide"

2020-04-08 Thread Ben Greenman
On 4/8/20, Stephen De Gabrielle  wrote:
> That’s a good suggestion! Do you know the relevant JavaScript we can try it
> out with. Might be an easy PR.
>

Beware that snippets are not always self-contained.

A button should grab any requires and earlier code needed to make the
example run. That'd be very very useful --- but maybe not so easy.

-- 
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/CAFUu9R5QLaMvnMh4krLZJTBHz%3Dbo1aLv%3DYkS1amF-2yJU55-aw%40mail.gmail.com.


Re: [racket-users] Scribble for literate dotfiles?

2020-04-07 Thread Ben Greenman
On 4/5/20, Karl Meakin  wrote:
>  I want to write my dotfiles in literate programming style. As far as I can
>
> tell, everyone does this using Emac's org-mode. I'd rather use a
> fully-fledged programming language (and not be tied to a particular
> editor). Is it possible to achieve this using Scribble? In particular, I'd
> like to be able to designate sections of text in the same input file as
> outputting to different output files (for example, output one section to
> .bashrc and another section to .vimrc).
>
> Thanks in advance.

This is definitely possible, but maybe not easy.

I'd first try writing a racket program with Scribble submodules, and
have the outer program invoke a renderer on each submodule

```
#lang racket

(module dotfile-1 scribble/???
  )

(require (rename-in 'dotfile-1 [doc doc:1]))

(???-render doc:1)
```

If that doesn't work, then I'd try making the outer module
scribble/manual and writing a function that renders one codeblock to a
file.

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


Re: [racket-users] Issue with define-type and typed classes

2020-03-31 Thread Ben Greenman
On 3/5/20, hashim muqtadir  wrote:
> So I have this file, found here:
> https://gitlab.com/hashimmm/remap/-/blob/3682db9fff3bc5007833e07bf9a9ed6e8e0170a9/private/tables.rkt
>
> Lines 51 through 55 say:
>
> (define-type (Func<%> A)  (BaseFunc<%> A FuncAnyParam))(define-type
> BoolFunc<%> (Func<%> BooleanColumn))(define-type AnyFunc<%> (Func<%>
> ColIdent))
>
> And this used to work on older versions of racket, say Racket BC 7.4
>
> But on Racket CS 7.6, I get an error on this line:
> (define-type AnyFunc<%> (Func<%> ColIdent))
>
> Even though (a) it doesn't throw an error on the line before it, and
> (b) replacing it with (define-type AnyFunc<%> (BaseFunc<%> ColIdent
> FuncAnyParam))
> works.
>
> I thought the way define-type works is that
> (Func<%> ColIdent)
> would expand into (BaseFunc<%> ColIdent FuncAnyParam)
>
> I've had similar problems with define-type previously where I'd think it
> would just expand
> by substituting the parameter but it doesn't seem to really do that. I don't
> have any
> trivial example to show, though. Fiddling around eventually gets it to
> work.
>
> I'd really appreciate some help as to how to think about what define-type
> does in my head.
>

That code should work. There's a bug somewhere, either TR or deeper.

I am thinking its deeper because the code sometimes compiles.

1. When I first tried `raco pkg install remap` (using a current CS), it worked
2. Then I tried compiling with BC 7.6 and CS 7.6. BC succeeded and CS failed.
3. Later, I saw 2 consecutive runs of CS fail and succeed:

```
(20:02)% rm -r compiled

(20:02)% /Applications/RacketCS-v7.6/bin/raco make -v tables.rkt
"tables.rkt":
  making #
/Users/ben/code/racket/fork/extra-pkgs/remap/private/tables.rkt:59:3:
Type Checker: parse error in type;
 expected a class type for #:implements clause
  given: (Opaque Func<%>)
  in: (Class #:implements BoolFunc<%>)
  compilation context...:
   /Users/ben/code/racket/fork/extra-pkgs/remap/private/tables.rkt
  context...:
   do-raise-syntax-error
   winder-dummy
   .../private/parse-type.rkt:1234:0: merge-with-parent-type
   .../private/parse-type.rkt:1364:14: for-loop
   .../private/parse.rkt:852:26
   .../private/runtime.rkt:80:24: temp5975
   .../env/type-alias-helper.rkt:230:4: for-loop
   .../env/type-alias-helper.rkt:101:0: register-all-type-aliases
   .../typecheck/tc-toplevel.rkt:359:0: type-check
   .../typecheck/tc-toplevel.rkt:602:0: tc-module
   .../typed-racket/tc-setup.rkt:96:12
   winder-dummy
   .../typed-racket/typed-racket.rkt:23:4
   call-in-empty-metacontinuation-frame
   apply-transformer
   dispatch-transformer

(1:20:02)% rm -r compiled
rm: compiled: No such file or directory

(1:20:02)% /Applications/RacketCS-v7.6/bin/raco make -v tables.rkt
"tables.rkt":
  making #
 [output to "compiled/tables_rkt.zo"]
```

-- 
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/CAFUu9R5aKWqDnSsTf-jJf-VnkDfQ0H38otTkcfLvY%2Buu5yuG2A%40mail.gmail.com.


Re: [racket-users] HTDP2e Exercise 342 find-all

2020-03-31 Thread Ben Greenman
On 3/21/20, Aron Zvi  wrote:
> Hi guys,
>
> Can I get a hint for Exercise 342 find-all
>

Don't use `find` as a helper function; instead, design a function that
returns a list of successes

-- 
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/CAFUu9R7SU%2B1QLwZfPSnVXNV%3DG60VuX4oVeNU4tz%2BdE5jEunSmA%40mail.gmail.com.


Re: [racket-users] HTDP2E 22.3 Domain-Specific Languages: Configurations

2020-03-31 Thread Ben Greenman
On 3/30/20, Aron Zvi  wrote:
> Hey guys
>
> In 22.3 Domain-Specific Languages: Configurations, the book introduces the
> following data example and data definitions for FSM configurations
>
>
> (define
> 
>  xm0
>   '(machine ((initial "red"))
>  (action ((state "red") (next "green")))
>  (action ((state "green") (next "yellow")))
>  (action ((state "yellow") (next "red")
>
> ; An XMachine is a nested list of this shape:
> ;   `(machine ((initial ,FSM-State
> )) [
> List-of
> 
>
> X1T ])
> ; An X1T is a nested list of this shape:
> ;   `(action ((state ,FSM-State
> ) (
> next ,FSM-State
> )))
> I do no understand the XMachine data definition properly. In the definition
>
> it appears that it would be a list with 3 elements:
>
> 1*. *'machine
> 2. `((initial ,FSM-State
> ))
> 3. [List-of
> 
>
> X1T ]
>
> However, from the data example (and the fact that it is an Xexpr
> ) I know
> that the intention is different and that it is a list of the form:
>
> 1. 'machine
> 2.  `((initial ,FSM-State
> ))
> 3. X1T -1
> ...
> X1T -n
>
> where is seems that [List-of
> 
>
> X1T ]is
> expanded and included in the list  ([List-of
> 
>  X1T ] is
> consed
> onto)
>
> Can you please explain how the given  `(machine ((initial ,FSM-State
> )) [
> List-of
> 
>
> X1T ])
> translates
> to this?
>

I think you are right. An XMachine should be a list of 3 elements by
that data definition.

The definition should probably have a "." (or use `cons`es):

`(machine ((initial ,FSM-State)) . [List-of X1T])

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


Re: [racket-users] Best way to handle different versions of Racket?

2020-03-30 Thread Ben Greenman
On 3/30/20, Siddhartha Kasivajhula  wrote:
> Hi there,
> Is there a standard/recommended way to handle multiple versions of Racket
> in library code?

If you're planning to ship the library as a package, you can also:

1. make 2 versions of the library (maybe as two branches in the same git repo)
2. add a version exception on pkgs.racket-lang.org

https://docs.racket-lang.org/pkg/getting-started.html#(part._.Version_.Exceptions)

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


Re: [racket-users] Switch off type checking via typed/racket/no-check fails on typed big-bang

2020-03-30 Thread Ben Greenman
On 3/25/20, Marc Kaufmann  wrote:
> Hi,
>
> I am trying to switch off type checking on a file so that I can prototype
> faster without the wait for the type checker. However, my code also uses
> typed/2htdp/universe and typed/2htdp/image, and I get an error on
> `big-bang`:
>
>> Type Checker: Macro big-bang from typed module used in untyped code in:
> (big-bang ...
>
> So, is there a to run the program without running the type checker?

No, you'll need a hack-around to avoid the macro issue.

This macro+use might be safe, but in general TR can't be sure that
expanding a macro won't break the typed module.

> Relatedly, is there a way of reloading a *typed* racket file in the REPL (I
> can't get it to work with ,reload-require which just chokes somehow).

I don't know about this

-- 
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/CAFUu9R5WDyc2RaR0kH4P%3DGUKVdsP-M7%3DF4R%3DfQiZsMRY4Gd1cg%40mail.gmail.com.


Re: [racket-users] Reflecting on context arity

2020-03-27 Thread Ben Greenman
procedure-result-arity is very limited

if you can find a way to call `f` once, though, you could assume that
its result arity never changes

-- 
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/CAFUu9R6YDx9%2BF27dHW3N1P%3DMK_UuzfrWqo01kigM4fBKxxFXUA%40mail.gmail.com.


Re: [racket-users] TR: Occurrence Typing with custom predicate

2020-03-24 Thread Ben Greenman
On 3/24/20, mmcdan  wrote:
> Hello,
>
> I'm trying to use occurrence typing for (Vectorof Symbol) or (Boxof
> Symbol).
>
> Creating a custom predicate for (Listof Symbol) seems to work:
> ---
> #lang typed/racket
>
> (: los? (-> Any Boolean : (Listof Symbol)))
> (define los?
>   (lambda (seq) (and (list? seq) (andmap symbol? seq
> ---
>
> However I haven't been able to create one for vectors or boxes. None of the
> things I've tried will typecheck. Any pointers?

Typed Racket can't be sure that untyped code won't change whats inside
a mutable vector or box

---
#lang racket
(define v (vector 'A))
(define (set-v!) (vector-set! v 0 0))
(provide v set-v!)

#lang typed/racket
(require/typed "path-to-untyped.rkt"
  (v : (Vectorof Any))
  (set-v! : (-> Void)))

;; suppose this worked
(: vos (-> Any Boolean : (Vectorof Symbol)))
(define (vos x) )

(cond
  [(vos? v)
;; v : (Vectorof Symbol)
(set-v!)
;; v now contains an integer!
]))
---

I don't know a work-around.

I was hoping it could work for (Immutable-Vectorof Symbol), but I
don't know what to use in place of `andmap`.

-- 
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/CAFUu9R6nYVHoKCFGbjD8Q%2Bs__z2Cep9rwvqRL6HyZCE5GnzyhA%40mail.gmail.com.


Re: [racket-users] Contracts on parameters

2020-03-23 Thread Ben Greenman
On 3/23/20, David Storrs  wrote:
> (define/contract (foo x)
>   (-> boolean? any)
>   'ok)
>
> (foo #t)
> 'ok
> (foo 7)
> ; foo: contract violation
> ;   expected: boolean?
> ;   given: 7
> ;   in: the 1st argument of
> ;   (-> boolean? any)
> ;   contract from: (function foo)
> ;   blaming: top-level
> ;(assuming the contract is correct)
> ;   at: readline-input:4.18
> ; [,bt for context]
>
> Yup, all good.
>
>
> (define/contract foo (make-parameter #f) boolean?)
> (foo #t)
> (foo)
> #t
> (foo 7)
> #f
>
>
> This isn't what I expected.  What am I missing?

1. the contract comes first, right now foo = boolean?

2. try parameter/c

-- 
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/CAFUu9R6RrEG-oK1i4fOsF9qUJFrbGc5TiMHPG--38cbvfdZsjQ%40mail.gmail.com.


Re: [racket-users] Gradual Typed Racket?

2020-03-23 Thread Ben Greenman
On 3/21/20, unlimitedscolobb  wrote:
> Hello,
>
> I come to Racket from Haskell and so far I am quite happy, as I feel freer
> to do some weird stuff from time to time, and I am absolutely in love with
> the Lisp-parens syntax.
>
> As a former Haskeller, one of the first things I tried was Typed Racket.
> It worked like a charm for small examples, but started getting in my way
> too much as soon as I got to some more advanced stuff (e.g. polymorphic
> functions, generics, eval, even apply).  My immediate reaction was ditching
> types for contracts, which are rather fine and allow me to use a familiar
> language, but I am somewhat worried about the performance penalties
> defining everything via define/contract may incur.  Also, it seems weird to
> set up runtime contract checks where a simple type annotation would do.
> I have no problem with Typed Racket not being able to type every single one
> of my functions (after all, I came to Racket to be able to do weird stuff),
> but so far I couldn't figure out what would be the best way to mix typed
> into two separate files.
>
> What is the standard practice for mixing typed and untyped code within a
> single module?  Submodules?  Typed regions within untyped code?  Maybe
> there is an example somewhere I can have a look at?

Yep, submodules and typed regions are the two ways to do this.

The plot library uses typed submodules in untyped code in a few small places:

https://github.com/racket/plot/blob/master/plot-lib/plot/private/common/contract.rkt
https://github.com/racket/plot/blob/master/plot-lib/plot/private/common/parameter-groups.rkt

I've done a similar thing to make typed parameters in untyped code.

Not sure about best practices, but I definitely prefer keeping typed
and untyped code in separate modules.

For contracts, though, (provide (contract-out ...)) gives better error
messages than define/contract.

-- 
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/CAFUu9R6NyvCz2TWL4%3DBBQ0edff18LGTQcUytkXngESvrDQYx_g%40mail.gmail.com.


Re: [racket-users] trace facility in Racket?

2020-03-21 Thread Ben Greenman
On 3/21/20, dgtlcmo  wrote:
> Does anyone know how to trace functions inside a closure?  I would like to
> trace hanoi-move, however find that with MIT Scheme I need to place (trace)
>
> within the closure (hanoi n), otherwise the trace will not occur.
>
> Can a trace like this be performed in Racket?
>
> Thanks
>
>  (define (hanoi n)
>   (define (pmd from to)
> (display "Move ")
> (display from)
> (display " to ")
> (display to)
> (newline)
> '())
>   (define (hanoi-move n from to spare)
> (cond ((= n 0) '())
>  ((= n 1) (pmd from to))
>  (else
>   (hanoi-move (- n 1) from spare to)
>   (hanoi-move 1 from to spare)
>   (hanoi-move (- n 1) spare to from
>   (hanoi-move n "A" "B" "C"))

Yes, Racket has trace tools:
https://docs.racket-lang.org/reference/debugging.html

Try adding (trace hanoi) before the call to (hanoi-move ) at the bottom

-- 
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/CAFUu9R5RDgp%2BcdQ219FF14X9mp99qd%2BMB8T2tMRvfvKf8KKa2Q%40mail.gmail.com.


Re: [racket-users] Load and execute files

2020-03-20 Thread Ben Greenman
On 3/20/20, Alexandre Rademaker  wrote:
>
> It works! Thank you. The B.rkt (or check.rkt in my last message) can’t have
> the `#lang racket` line. I am still confused about the implications of the
> `#lang racket` line in the file and the module system of Racket.

Great!

In this case, adding #lang puts the body of B.rkt inside a new module,
which would need a require to get the definitions from the toplevel.

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


Re: [racket-users] Re: HTDP2e part 4: 20.3 Refining Functions dir.rkt

2020-03-20 Thread Ben Greenman
On 3/20/20, Aron Zvi  wrote:
> Thanks for your reply Ben.
>
> I understand that I am supposed to be getting a Dir instance.
> My confusion is indeed regarding the value of the name field of Dir for
> which I get a (full) path symbol of the directory and not just the folder
> name as I would expect.
>
> When I run (create-dir "test") and the test folder is in the same folder as
>
> my racket racket file (using just the folder name as you suggested), I get
> the following Dir instance for which the symbol is still the path to the
> folder from the given root
>
> (make-dir
>  'test
>  (list
>   (make-dir
>*'test/a*
>(list (make-dir *'test/a/docs* '() '()))
>(list (make-file ".DS_Store" 6148 (make-date 2020 3 20 13 7 33) "")
> (make-file "me.txt" 0 (make-date 2020 3 20 13 1 42) ""
>  (list (make-file ".DS_Store" 6148 (make-date 2020 3 20 13 7 28) "")))
>
> *I am expecting to get this *
>
> (make-dir
>  'test
>  (list
>   (make-dir
>*'a*
>(list (make-dir *'docs* '() '()))
>(list (make-file ".DS_Store" 6148 (make-date 2020 3 20 13 7 33) "")
> (make-file "me.txt" 0 (make-date 2020 3 20 13 1 42) ""
>  (list (make-file ".DS_Store" 6148 (make-date 2020 3 20 13 7 28) "")))

Ok, I see how that makes Exercise 339 more difficult. Thanks for
pointing this out.

In Racket, I would use `symbol->string` and `file-name-from-path` to
get the name.

In ISL, I'd use `symbol->string` and `string->list` to get started,
then design a function that takes takes all the characters after the
last #\/ character in a list (or all characters if there is no #\/)

-- 
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/CAFUu9R72khWOazwqVnmR2354%3DcbGxRkyn0u-xPTpemYpy1ES7Q%40mail.gmail.com.


Re: [racket-users] Load and execute files

2020-03-20 Thread Ben Greenman
Does check.rkt start with a #lang line?

My B.rkt from the last message didn't have a #lang

On 3/19/20, Alexandre Rademaker  wrote:
>
> Not yet. To be more concrete:
>
> % racket --lib racket -t ex-1.2-3.rkt -t ex-1.7.rkt -t ex-1.8.rkt -r
> check.rkt
> check.rkt:31:7: sum-of-squares-max3: unbound identifier
>   in: sum-of-squares-max3
>   location...:
>check.rkt:31:7
>   context...:
>do-raise-syntax-error
>for-loop
>[repeats 1 more time]
>finish-bodys
>lambda-clause-expander
>for-loop
>loop
>[repeats 6 more times]
>module-begin-k
>expand-module16
>expand-capturing-lifts
>temp118_0
>temp91_0
>compile15
>temp85_0
>loop
>
> The ex* files are the answers of one particular student. The check.rkt
> contains the tests. I am still trying to avoid the necessity of adding the
> (require …) commands in the check.rkt so I can select the student files to
> test in the command line. The -r or -f option cause the same error. The
> (provide …) forms are presented in the ex* files.
>
> Best,
> Alexandre
>
>
>> On 19 Mar 2020, at 20:26, Ben Greenman 
>> wrote:
>>
>>> But I was really expecting that the option -t in the racket command
>>> should
>>> replace the explicit (require…) in B.rkt. Something like
>>>
>>>> racket -t A.rkt -f B.rkt
>>> default-load-handler: expected a `module' declaration, but found
>>> something
>>> else
>>
>> Yes that almost works, but A.rkt needs to provide things for the
>> require to get them.
>>
>> Also, I guess we need --lib racket (maybe my -I racket was a mistake):
>>
>> racket --lib racket -t A.rkt -f B.rkt
>
>

-- 
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/CAFUu9R7ajThHa0W5qHCH42KuGfMowX%2BnZ2K-V6EbUTdFC2zYHQ%40mail.gmail.com.


Re: [racket-users] Load and execute files

2020-03-19 Thread Ben Greenman
> But I was really expecting that the option -t in the racket command should
> replace the explicit (require…) in B.rkt. Something like
>
>> racket -t A.rkt -f B.rkt
> default-load-handler: expected a `module' declaration, but found something
> else

Yes that almost works, but A.rkt needs to provide things for the
require to get them.

Also, I guess we need --lib racket (maybe my -I racket was a mistake):

> racket --lib racket -t A.rkt -f B.rkt

-- 
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/CAFUu9R6XQ_4wF%3DOFvA1SKsSLFf90wcg0rhUTyTuPVZKf-cDShg%40mail.gmail.com.


Re: [racket-users] Load and execute files

2020-03-19 Thread Ben Greenman
On 3/19/20, Alexandre Rademaker  wrote:
>
> Suppose I have some functions defined in a file A.rkt and some tests defined
> in the file B.rkt. How can I execute the tests in the command line?
>
> I was expecting to be able to run
>
>> racket A.rkt B.rkt
>
> But this does not evaluate the expressions on B.rkt as I was expecting!
>
> 1. Do I need to export the functions in A.rkt with (provide …)?
> 2. Do I need to add the (require …) in B.rkt?
>
>
> The idea is to have the students submitting their A.rkt files and I could
> test all of them using a single set of tests in another racket file.
>
> Ideas? What am I missing?

If A.rkt contains a few expressions (and no #lang):

```
  (define a 2)
```

and B.rkt contains a few expressions:

```
(unless (= 6 a)
  (error 'bad))
```

then `racket -I racket --load a.rkt --load b.rkt` evaluates the
expressions in A and then the expressions in B, as if they were all
part of the same #lang racket file

-- 
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/CAFUu9R735FzZxd9p6mXNP-DFU-D5%3DhC-fpzaBuDAVGvGTTVHsA%40mail.gmail.com.


Re: [racket-users] HTDP2e part 4: 20.3 Refining Functions dir.rkt

2020-03-19 Thread Ben Greenman
On 3/19/20, Aron Zvi  wrote:
> Hey guys,
>
> In part 4 section 20.3 Refining Functions I am using (require htdp/dir)
> and (create-dir DIR-PATH). I get back a Dir instance with name value being
> a full path symbol of the folder. ie. (make-dir
> '/Users/SSS/Documents/xyz empty empty).
> This does not seem to be in line with the exercises in the section where it
> seems that I should be getting back just the folder name.
> I am missing something?

Nope, you're supposed to get a dir structure.

When I call create-dir with a full path, I get a struct with a full
path symbol inside. But when I call create-dir with just the folder
name, the struct only contains the folder name. Maybe that explains
the confusion with the exercises?

But! create-dir does not return a Dir.v3 as section 20.3 says. See the
docs for htdp/dir for the correct data definitions:

https://docs.racket-lang.org/teachpack/dir.html

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFUu9R4tSkd4-iuXDZ1sEN2wYcRbXHOGEP44GY8Nw63rXHYwLw%40mail.gmail.com.


Re: [racket-users] Logger shows lots of info messages about collapsible-contract-bailout and collapsible-value-bailout

2020-03-14 Thread Ben Greenman
>> I don't know what triggers it and google does not return any results.
>> Just curious, is it something I should be worried about?
>> I am using Racket v7.5 if it helps.

Searching google for "collapsible contract" should point to these
pages, at least:

https://docs.racket-lang.org/reference/collapsible.html
https://users.cs.northwestern.edu/~dmf082/papers/collapsible.pdf

In short, racket/contract has two flavors for some contracts: "normal"
and "collapsible". Those log messages appear when the library tries to
use "collapsible" but has to fall back.

-- 
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/CAFUu9R4W8Z%3D7ytVL44w7zXxAiteWdxdS-FUhZTJN1LnjELiG8Q%40mail.gmail.com.


Re: [racket-users] HTDP2e Exercise 320 help

2020-03-12 Thread Ben Greenman
Those data definitions seem to match what the exercise is asking for.
But I think the second one is not what the exercise intends because
there are some data examples that match the 2nd definition but not the
1st.

My guess is that "integrate the definition of SL" means something less
drastic than inlining, and that the goal is to use a list function +
lambda to simplify.

-- 
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/CAFUu9R44_R%2BwjQwXcv6xFQA2qNLn%2B_WYKx73NyFP7kKm%2BS1%2BRQ%40mail.gmail.com.


Re: [racket-users] TR dependent types cannot check equality of symbols

2020-02-24 Thread Ben Greenman
On 2/24/20, Marc Kaufmann  wrote:
> Very nice, adding
>
> (: get-user-var (case-> ...))
>
> indeed does the trick. So I can use `case->` to do overloading (if that's
> what it is called), by defining different functions for different type
> signatures, and then put them together into a single function via a cond.
> E.g.:
>
> (: int-add (-> Integer Integer Integer))
> (define (int-add x y)
>   (+ x y))
>
> (: string-add (-> String String String))
> (define (string-add x y)
>   (string-append x y))
>
> (: int-string-add (case->
> (-> Integer Integer Integer)
> (-> String String String)))
> (define (int-string-add x y)
>   (cond [(integer? x) (int-add x y)]
> [(string? x) (string-add x y)]
> [else
>   (error "Not a string or int" x)]))
>
> I am wondering if there is a way to avoid the final definition of
> `int-string-add`, by simply defining the same function twice (or more) with
>
> different type signatures, and then when I call the function, which code
> gets called depends on the type signature? I would be surprised if this
> existed in Typed Racket right now, but it would be neat and good to know if
>
> there is a more idiomatic/built-in way than what I do above, ie just write:
>
> (: special-add (-> Integer Integer Integer))
> (define-special (special-add x y)
>   (+ x y))
>
> (: special-add (-> String String String))
> (define-special (special-add x y)
>   (string-append x y))
>
> I guess it would be pretty hard, since the type signature has to be coupled
> more tightly to a specific function than TR requires right now, i.e. I'd
> have to write (define-special (special-add [x : String] [y : String]) to
> make the link explicit. Anyway, if it's not possible right now, totally
> fine.

Right, I don't think that's possible now.

The extensible-functions package helps with overloadings, but (iiuc)
you need to pick a type at the top:

https://pkgs.racket-lang.org/package/extensible-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/CAFUu9R6niER6eOakB2bOaDmQowRZJ5GK4JAe4ZfizQZ4V9zrCw%40mail.gmail.com.


Re: [racket-users] TR dependent types cannot check equality of symbols

2020-02-23 Thread Ben Greenman
Try this case-> type instead:

  (case->
(-> Integer 'name Symbol)
(-> Integer 'age Integer)
(-> Integer Symbol (U Symbol Integer)))


I don't know what it would take to add refinements for symbols, but
that might be useful. Andrew Kent's dissertation may have some
pointers:

https://pnwamk.github.io/docs/dissertation.pdf

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


Re: [racket-users] How do I just run the type checker?

2020-02-21 Thread Ben Greenman
On 2/21/20, 'David Florness' via Racket Users
 wrote:
> Sam Tobin-Hochstadt  writes:
>
>> If you compile the file with `raco make server.rkt` then it will run
>> the type checker as part of compilation. Furthermore, it will run
>> faster the next time since it won't have to re-compile.
>
> Question about this: if, after runing `raco make server.rkt` I run
> `racket server.rkt`, will the bytecode be used?

yes

-- 
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/CAFUu9R6aD5c2jU5FXrkmJ%2BnbHyeU7MC6hw12zyjXbA0Ug3HUAA%40mail.gmail.com.


Re: [racket-users] Typed Racket: Casting to types containing type variables

2020-02-19 Thread Ben Greenman
On 2/19/20, unlimitedscolobb  wrote:
>
> []
>
> ;Type Checker: Type a could not be converted to a contract because it
> contains free variables.
> ;   in: a
>
> Does this mean that I can never cast to types containing type variables?

Yes

> My original problem comes from playing around with eval, which returns
> AnyValues.  Ideally, I would like to be able to retrieve the first returned
>
> value (done), and then convert it to a type variable bound by one of the
> arguments:
>
> (: my-super-func (All (a) (-> (Type1 a) a)))
> (define (my-super-func arg)
>   ...
>   (get-first-value (eval some-stuff))) ; how to cast to a ?

You can ask the caller to supply a cast function that turns an Any to an A.

But depending on what you want to cast to, occurrence typing may be
more convenient. For example:

#lang typed/racket

(: my-super-func (All (a) (-> (-> Any) (-> Any Boolean : #:+ a) a)))
(define (my-super-func get-v check-v)
  (assert (get-v) check-v))

(ann (my-super-func (lambda () 42) exact-integer?) Integer);
;; 42
(ann (my-super-func (lambda () '(A)) (lambda (x) (and (list? x)
(andmap symbol? x (Listof Symbol))
;; '(A)

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


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.


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.


Re: [racket-users] TR: cast on mutable hash table...

2020-02-14 Thread Ben Greenman
On 2/14/20, 'John Clements' via users-redirect  wrote:
> I think I may understand what’s going on here, but a student and I worked on
> this for quite a while today before I found the problem.
>
> 
>
> In this case, one easy error is to change the ‘cast’ into an ‘ann’, which
> works fine.

You can also declare a type for `top-store`, instead of the hash expression:


#lang typed/racket

(define-type Store (Mutable-HashTable Integer Value))
(define-type Value (U Real Boolean String))

(: top-store Store)
(define top-store
  (make-hash (list (cons -1 14)
   (cons 1 #t)
   (cons 2 #f

(hash-set! top-store 5 1234)

-- 
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/CAFUu9R6rzKL_A8H2YjiDhS_JT7W%3DZ%3DTq8hVmccsQTTu9f%3DDrcQ%40mail.gmail.com.


Re: [racket-users] How to convert String to Integer

2020-02-11 Thread Ben Greenman
You may want `exact-integer?`

-- 
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/CAFUu9R4oRdEEAZJpdLa%2B_%2Brm6i4T_3UC52XKQ6sTXwiX-jiBYQ%40mail.gmail.com.


Re: [racket-users] How to use dates (especially gregor) with Typed Racket?

2019-12-11 Thread Ben Greenman
Thanks for the feedback! I opened a pull request for the docs:

https://github.com/racket/typed-racket/pull/886

Happy to continue the discussion over there.
(The example I added to the guide is maybe too simple.)

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


Re: [racket-users] How to use dates (especially gregor) with Typed Racket?

2019-12-07 Thread Ben Greenman
On 12/7/19, Marc Kaufmann  wrote:
> Thanks Ben and Jon, that did the trick.
>
> I realized when following the code that the structure wasn't exported - but
>
> I didn't know how to work around that. I now also checked the
> documentation, and the only thing I found on opaque types is
> https://docs.racket-lang.org/ts-reference/special-forms.html?q=opaque#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._require%2Ftyped%29%29.
>
> What it says about opaque types is:
>
> "Opaque types must be required lexically before they are used."

The docs says a little more --- there are 4 sentences that come right
before this one.

I think those sentences would be better off with:
1. a link to `make-predicate`
2. and English words at the start & end of each sentence

Let me know if you have other suggestions

> followed by an example that is even now non-trivial for me to parse and
> figure out. (I started going down the rabbit hole when the `->` was not
> used in the first position of the definition, nor written as `. -> .` Turns
> out types can be defined via infix notation, which is nice but unexpected.)

The docs for -> show the infix notation.

Is the example still difficult to figure out? We could replace it, but
I'm not sure what could be better

(if want to stop using infix notation here, then the other uses on the
same page need to change too)

>
> So there are two questions:
>
> 1. What does #:opaque do?
> 2. How could I have found that out by searching - or essentially the way to
>
> do it was "Email the list". If the latter, that's fine, the email list is
> very helpful and it would be good to add some additional explanation of
> opaque types to the documentation of `require-typed`, and possibly even to
> the typed racket reference. Probably the part talking about typed-racket
> untyped racket interaction.
>
> Let me try answering my first question: #:opaque defines a new type via a
> predicate function -- here `time?` -- that is being imported (can I use it
> without require-typed? I guess there would be no point, but I haven't
> thought this through). This is not based on the usual type constructors
> using other types, but based on whether a thing returns `#true` when passed
> to the predicate, in my case `time?`. I assume this means that the type is
> verified via contracts, so if I do this a lot I should expect some run-time
> performance hits (if I call this function a bunch, which isn't an issue in
> my case).

Right, a `Time` is any value that `time?` says yes to.

About performance: in type-checked code, you can expect to pay for
every call to `time?` and nothing else. The run-time hit should be the
same as using cond/if with any simple predicate.

-- 
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/CAFUu9R6Qqa%3DHpkgrU4-_uEsoY3kgSW0dP3OfrAJn1T%2BndVbOpQ%40mail.gmail.com.


Re: [racket-users] How to use dates (especially gregor) with Typed Racket?

2019-12-03 Thread Ben Greenman
The error is because gregor/time doesn't export a struct. But
nevermind that, because you're probably best off with an opaque type:

```
#lang typed/racket

(require/typed gregor/time
  [#:opaque Time time?]
  [time (->* [Integer] [Integer Integer Integer] Time)]
  [time->iso8601 (-> Time String)])

(require/typed gregor
  [current-time (->* [] [#:tz String] Time)])

(time->iso8601 (current-time))
;; "21:04:25.687808105"
```

-- 
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/CAFUu9R6MhQP-Dt9eqnzf1cgZC%2BqmB0xuGq%2BVvAFkvf2YKSTOFg%40mail.gmail.com.


Re: [racket-users] contract for an "overloaded function"

2019-11-29 Thread Ben Greenman
Try ->i. I wouldn't worry about performance until makes itself a problem.

On 11/29/19, Ryan Kramer  wrote:
> Thanks, but I don't think `case->` works for me. It looks like it chooses a
>
> case purely based on the number of arguments. The following example, when
> given two arguments, will always choose the integer? case even if both
> arguments are strings.
>
> (case-> [-> integer? integer? list?]
> [-> string? string? list?])
>
> On Friday, November 29, 2019 at 1:51:52 PM UTC-6, David Storrs wrote:
>>
>> I think you want `case->`:
>> https://docs.racket-lang.org/reference/function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._case-~3e%29%29
>>
>
> --
> 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/73132ad9-7722-432a-8328-0d4c38bbb5a1%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/CAFUu9R6dBHvCF8B1WsS43Xr7vL9CHiHRpMzN8NsRuCo8S6Q3%3DA%40mail.gmail.com.


Re: [racket-users] Typed Racket needs annotation to realize (Mutable-HashTable Symbol Symbol) is of a more general type

2019-11-06 Thread Ben Greenman
On 11/6/19, Marc Kaufmann  wrote:
> I assumed it was something to do with mutability, but I don't understand
> what you mean when you say there is a two-way channel. The reference in
> typed racket (
> https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Hash.Table%29%29)
> says this:
>
> ```
>
> (HashTable
> 
>  k v)
>
> is the type of a mutable or immutable hash table
> 
> with key type k and value type v.
> Example:
>
>> (make-hash
> 
>  '((a . 1) (b . 2)))
>
> - : (HashTable Symbol Integer) [more precisely: (Mutable-HashTable Symbol
> Integer)]
>
> '#hash((a . 1) (b . 2))
>
> ```
>
> That suggests to me that HashTable includes both Mutatable-HashTable and
> Immutable-HashTable. The example given even states that the HashTable
> Symbol Integer is more precisely of Mutable-HashTable Symbol Integer type -
> does that *not* mean that (Mutable-HashTable Symbol Integer) is a subtype
> of (HashTable Symbol Integer) in the reference example?

Right --- (Mutable-HashTable Symbol Integer) is a subtype of
(HashTable Symbol Integer).

> I now tried to redefine DB as Mutable-HashTable to avoid this issue, but
> that doesn't work either. It still doesn't accept `(make-hash (list (cons
> 'study-type study-type)))` as something of type DB. How is
> (Mutable-HashTable Symbol Symbol) not a subtype of DB, which is
> (Mutable-HashTable DBKey (U DB DBValue)), and DBKey is (U Symbol ... ;other
> stuff) and same for DBValue?

See Alexis's reply.

For a small example,  (Mutable-HashTable Symbol Symbol) is NOT a
subtype of (Mutable-HashTable Symbol (U Symbol String))

```
#lang typed/racket/base

(define-type (M-HT A B) (Mutable-HashTable A B))

(define (f (x : (M-HT Symbol (U Symbol String
  (void))

(define h : (M-HT Symbol Symbol)
  (make-hash '((A . X

(f h) ;; type error
```

> You wrote that make-hash is of type `(Listof (Pairof Symbol Symbol))`. Is
> there a way to expand and print the type of something in terms of primitive
> types (well, or maybe step through one layer of abstraction) so that I
> could play around with some toy examples to get a sense of what types are
> returned? I am clearly confused by what type `make-hash` returns and what
> `hash-ref` expects.

The blue boxes in Dr. Racket might help. There are also a few tools
for looking at types in the REPL:

https://docs.racket-lang.org/ts-reference/Exploring_Types.html

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFUu9R7Y1Jew4-pWBF8cxExZUL-iKro_gLLDSpt_OchTbXWD8A%40mail.gmail.com.


Re: [racket-users] Re: [standard-fish] Summer competiton 2019

2019-10-25 Thread Ben Greenman
On 8/17/19, Philip McGrath  wrote:
> This contest is a bright idea, so here's a standard lightbulb:
> [image: default-lightbulb.png]
> The code is at
> https://gist.github.com/LiberalArtist/4d0059f5af23043515a3cc74bd4928c2
>
> -Philip

I used standard-lightbulb in a slideshow [1].

Thank you Phil for making it, and thank you Stephen for the inspiration!!!


[1] http://ccs.neu.edu/home/types/publications/publications.html#gfd-oopsla-2019

-- 
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/CAFUu9R4ikUmNtet%2BjH5wXK-%3D-QC1hb2G%2B7Z_0JfVQ%3D_tLkoVmA%40mail.gmail.com.


Re: [racket-users] Is there a trick to know which types to specify when importing untyped racket into typed racket?

2019-10-06 Thread Ben Greenman
On 10/6/19, Raoul Schorer  wrote:
> Hi,
>
> I would very much like to import the package multimethod
> 
>
> into a typed module. Unfortunately, the symbols exported by this module are
>
> non-trivial macros (at least to me).
> So I would like to know whether there is some kind of technique to know
> which type to specify for imported symbols with require/typed?
> I tried various things to no avail. Will I be forced to check the code
> expansion and try to check types manually if I want to use the package?

I don't know any alternative to typechecking the expanded code to see
if anything's missing

-- 
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/CAFUu9R780%2B4__%2BjsXjf4ZRYTSHw5v%3DOERDu-JssWB371GoK5gA%40mail.gmail.com.


Re: [racket-users] Fwd: Re: Racket code query

2019-10-03 Thread Ben Greenman
I opened a pull request with a suggestion
https://github.com/conniepocky/Waffle-Lang/pull/1

On 10/3/19, Stephen De Gabrielle  wrote:
> Hi
>
> Please see the thread below for a query from Connie who is trying to make
> her own language (11yo?!)
>
> I believe this is her code;
> https://github.com/conniepocky/Waffle-Lang
>
> I think this is the last working version?
> https://github.com/conniepocky/Waffle-Lang/commit/4a30e6ba3687b719298c27ffb844453a52406fae
>
>
> On Wed, 2 Oct 2019 at 21:16, Donna <> wrote:
>
>> Connie said this is the question she has:
>>
>> I’m trying to create a repl to add to my language that I’m making in
>> Racket. I had made a repl before but since I made the compiler its
>> broken!
>> I think maybe racket updated so thats why it doesn’t work anymore. How
>> should I attempt to recreate or fix this?
>>
>> On 1 Oct 2019, at 20:31, Stephen De Gabrielle <> wrote:
>>
>> Please let me know if Connie is uncomfortable with those options?
>>
>> If she prefers Stack Overflow I can copy the question and forward it on
>> to
>> the mailing list.
>>
>> S.
>>
>> On Tue, 1 Oct 2019 at 17:16, Donna <> wrote:
>>
>>> Thank you Stephen, I’ll forward this to Connie!
>>>
>>>
>>> On 1 Oct 2019, at 16:42, Stephen De Gabrielle <> wrote:
>>>
>>> 
>>>
>>> Hi Donna,
>>>
>>> I think the best place to get help is at
>>> https://groups.google.com/forum/m/#!forum/racket-users
>>>
>>> asking there is a good way to get help. I’ll certainly keep an eye out
>>> and answer if I can.
>>>
>>> Another good place to ask for help is the Racket Slack #beginners
>>> channel. Slack is a chat service, and as the Americans are awake in our
>>> evening she is sure to get a quick response.
>>>
>>> 1.  signup/register at https://racket-slack.herokuapp.com
>>> 2. login at https://racket.slack.com/
>>> 3. Go to the #beginners channel
>>>
>>> I got these instructions from https://racket-lang.org
>>>
>>> Both of these are better than Stack overflow in my opinion.
>>>
>>> Kind regards
>>>
>>> Stephen
>>>
>>>
>>> On Tue, 1 Oct 2019 at 16:06, Donna <> wrote:
>>>
 Hi Stephen

 Hope all is well with you!

 Connie has a problem with her code for her language she’s making. She’s
 been working on it and not been able to solve it this past week.


 To save her spending hours more trying to fix it!

 Thanks,


 Donna

>>> --
>>> 
>>>
>>> --
>> 
>>
>> --
> 
>
> --
> 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-%2B_xOkw4XocVyo8Rxs15pauis0AQ%2BLfk_0QHSGz1c7TKQ%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/CAFUu9R7FC1ncDU0BD2XwiJFU4qO9wYyCLG3fZiNo8_EJOrqyUA%40mail.gmail.com.


  1   2   3   >