[racket-users] Re: Combining generators and typed racket

2020-07-21 Thread Nate Griswold
Actually, is there any way at all to use lazy lists of things (streams or
generators) in typed racket?

Nate


On Tue, Jul 21, 2020 at 8:45 PM Nate Griswold 
wrote:

> Do generators and typed racket work together well? It seems (yield)
> doesn't have a type and i couldn't get my module to work.
>
> Is there a way to make some procedure untyped in the middle of a typed
> file? Is it just best to break these things into separate files?
>
> Thank you
>
> Nate
>

-- 
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/CAM-xLPo_c3LzL81Qv6bA2zzJMhQftQ46JR%3DWyZdSJjPJ9rYM5Q%40mail.gmail.com.


Re: [racket-users] combining require, build-path, and namespaces

2020-07-21 Thread Shriram Krishnamurthi
Ooh, thank you Oak and Jens Axel! I would never have figured that out.

As Matthew's email from Jan 2020 says, having the documentation say
something (and, in particular, suggesting the use of `parameterize` to get
what many users might expect) would be quite lovely.

(Thanks also, Greg.)

Shriram

-- 
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/CAJUf2yQsm_w2JmSVO%3D8x9-JuepRGbpEDqyrsJxi2PVKZDCmVYw%40mail.gmail.com.


[racket-users] Combining generators and typed racket

2020-07-21 Thread Nate Griswold
Do generators and typed racket work together well? It seems (yield) doesn't
have a type and i couldn't get my module to work.

Is there a way to make some procedure untyped in the middle of a typed
file? Is it just best to break these things into separate files?

Thank you

Nate

-- 
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/CAM-xLPoKYybMA755L-qcO5v4-Y4d1kOvJ1yOF28rg_tQm%3Dkhiw%40mail.gmail.com.


[racket-users] Re: combining require, build-path, and namespaces

2020-07-21 Thread Greg Hendershott
Do you definitely want *only* definitions explicitly provide-ed by the 
module, or is it acceptable (or even desirable) to see *all* module 
definitions?  If the latter, you could use module->namespace.

On Tuesday, July 21, 2020 at 11:45:38 AM UTC-4, Shriram Krishnamurthi wrote:
>
> How I can combine these three? I want to do something like this:
>
> (define n (make-base-namespace))
> (define p (build-path f))
> (eval `(require ,p) n)
>
> Racket doesn't like that: bad syntax for require sub-form because p is a 
> path-typed value.
>
> Essentially, I want to inject the module at f into n so that the provided 
> identifiers of f are visible inside n. (I haven't been able to get 
> dynamic-require working either, nor is it an entirely satisfactory 
> solution because I may not always know what names f is providing.)
>
> Thanks,
> Shriram
>

-- 
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/aa4d274a-3617-42f7-8e5a-666b45f8b227o%40googlegroups.com.


Re: [racket-users] combining require, build-path, and namespaces

2020-07-21 Thread Jens Axel Søgaard
Den tir. 21. jul. 2020 kl. 20.25 skrev Sorawee Porncharoenwase <
sorawee.pw...@gmail.com>:

> This is weird. I usually parameterize current-namespace when using
> namespace-* functions, and in this particular case it works fine.
>
> On Tue, Jul 21, 2020 at 11:05 AM Shriram Krishnamurthi 
> wrote:
>
>> Thank you! Would you know why I might get this error:
>>
>> ; require: unknown module
>>
>> ;   module name:
>>
>> ; #>
>>
>> (This is from inside a module.)
>>
>> Trying the same at the REPL, I see the same thing:
>>
>> > (define n (make-base-namespace))
>>
>> > (namespace-require `(file ,(path->string (build-path "wheats"
>> "w1.rkt"
>>
>> [note no optional namespace]
>> works fine; the name is available at the top-level; but using the same
>> pathname but with the namespace parameter:
>>
>> > (namespace-require `(file ,(path->string (build-path "wheats"
>> "w1.rkt"))) n)
>>
>> ; require: unknown module
>>
>> ;   module name:
>>
>> ; #>
>>
>> (The file in question begins with #lang racket.)
>>
>>

#lang racket

(define ns (make-base-namespace))
(define p  (build-path "/Users/soegaard/tmp" "w1.rkt"))

(parameterize ([current-namespace ns])
  (namespace-require p))

I had to dig up

https://www.mail-archive.com/racket-users@googlegroups.com/msg43291.html

to figure it out.

/Jens Axel

-- 
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/CABefVgyYCFn8%3DVF8Ufr4Q_vwt2nKiTnnk-0t24%3DA%3DmxcSYkKNw%40mail.gmail.com.


Re: [racket-users] combining require, build-path, and namespaces

2020-07-21 Thread Sorawee Porncharoenwase
This is weird. I usually parameterize current-namespace when using
namespace-* functions, and in this particular case it works fine.

On Tue, Jul 21, 2020 at 11:05 AM Shriram Krishnamurthi 
wrote:

> Thank you! Would you know why I might get this error:
>
> ; require: unknown module
>
> ;   module name:
>
> ; #>
>
> (This is from inside a module.)
>
> Trying the same at the REPL, I see the same thing:
>
> > (define n (make-base-namespace))
>
> > (namespace-require `(file ,(path->string (build-path "wheats"
> "w1.rkt"
>
> [note no optional namespace]
> works fine; the name is available at the top-level; but using the same
> pathname but with the namespace parameter:
>
> > (namespace-require `(file ,(path->string (build-path "wheats"
> "w1.rkt"))) n)
>
> ; require: unknown module
>
> ;   module name:
>
> ; #>
>
> (The file in question begins with #lang racket.)
>
> Shriram
>
> --
> 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/CAJUf2yQijBugL3PBo%2B5SBj-9zEKnUc2ejH52VB0AkTW%3DniRGQw%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/CADcuegugFPk2KjHF%3D550%3Dv5dzs1XD74z-mfJWBwBMmC1AtxSzg%40mail.gmail.com.


[racket-users] Sending a file descriptor along a socket?

2020-07-21 Thread Christopher Lemmer Webber
It looks like ffi/unsafe/port provides ways to read a file desciptor
from a port that is capable of receiving them, and there are tools
to transform that file descriptor into a port or the reverse, but
is there a way for me to *write* a file descriptor to a port
(ie, the equivalent to the sendmsg posix system call)?
(It might be right in front of my nose and that I'm missing it...)

Thanks!
 - Chris

-- 
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/87k0yw214s.fsf%40dustycloud.org.


Re: [racket-users] combining require, build-path, and namespaces

2020-07-21 Thread Shriram Krishnamurthi
Thank you! Would you know why I might get this error:

; require: unknown module

;   module name:

; #>

(This is from inside a module.)

Trying the same at the REPL, I see the same thing:

> (define n (make-base-namespace))

> (namespace-require `(file ,(path->string (build-path "wheats" "w1.rkt"

[note no optional namespace]
works fine; the name is available at the top-level; but using the same
pathname but with the namespace parameter:

> (namespace-require `(file ,(path->string (build-path "wheats" "w1.rkt")))
n)

; require: unknown module

;   module name:

; #>

(The file in question begins with #lang racket.)

Shriram

-- 
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/CAJUf2yQijBugL3PBo%2B5SBj-9zEKnUc2ejH52VB0AkTW%3DniRGQw%40mail.gmail.com.


Re: [racket-users] Creating links to Racket docs for functions in user-scope packages

2020-07-21 Thread 'Joel Dueck' via Racket Users
It looks like the problem might be in this function 

 
where it always constructs a path that is relative to (find-doc-dir).

Would it make sense instead to have it check the dest against all the paths 
returned by (get-doc-search-dirs) and just use the first one that matches? 
If so maybe I’ll try doing a pull request to that effect.

Sorry I’m tiptoeing here, I haven’t contributed to Scribble before.

On Monday, July 13, 2020 at 11:02:17 AM UTC-5 Joel Dueck wrote:

>
> On Monday, July 13, 2020 at 8:37:52 AM UTC-5, Matthew Flatt wrote:
>>
>> It might end up being about the same implementation effort to improve the
>> error message or to make the function work on user-scope packages
>>
>
> That was my sense as well...I will try taking a look at this, maybe I can 
> contribute.
>
>

-- 
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/f9e4366b-0db3-45b6-9a59-04292d3edcf1n%40googlegroups.com.


Re: [racket-users] combining require, build-path, and namespaces

2020-07-21 Thread Jens Axel Søgaard
Den tir. 21. jul. 2020 kl. 17.45 skrev Shriram Krishnamurthi <
shri...@gmail.com>:

> How I can combine these three? I want to do something like this:
>
> (define n (make-base-namespace))
> (define p (build-path f))
> (eval `(require ,p) n)
>
> Racket doesn't like that: bad syntax for require sub-form because p is a
> path-typed value.
>
> Essentially, I want to inject the module at f into n so that the provided
> identifiers of f are visible inside n. (I haven't been able to get
> dynamic-require working either, nor is it an entirely satisfactory
> solution because I may not always know what names f is providing.)
>

Sounds like a job for `namespace-require` with a require spec of the form
`(file ,(path->string (build-path f)))`.

/Jens Axel

-- 
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/CABefVgzwBhd%3D27JCRr3PDj5NKL8iukiQCsEspww%2BTBcPBUe4dQ%40mail.gmail.com.


[racket-users] combining require, build-path, and namespaces

2020-07-21 Thread Shriram Krishnamurthi
How I can combine these three? I want to do something like this:

(define n (make-base-namespace))
(define p (build-path f))
(eval `(require ,p) n)

Racket doesn't like that: bad syntax for require sub-form because p is a 
path-typed value.

Essentially, I want to inject the module at f into n so that the provided 
identifiers of f are visible inside n. (I haven't been able to get 
dynamic-require working either, nor is it an entirely satisfactory solution 
because I may not always know what names f is providing.)

Thanks,
Shriram

-- 
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/978e4a26-d7fc-4e5d-aabe-6464a3181420n%40googlegroups.com.


Re: [racket-users] Font bearing - lining up texts and outlines

2020-07-21 Thread Matthew Butterick
The `fontland` library does not have an official public API but it will give 
you the answer, which is 1446.

#lang racket
(require fontland fontland/ttf-glyph)
(define f (open-font "/System/Library/Fonts/Supplemental/Arial Unicode.ttf"))
;; `layout` uses OpenType positioning & substitution tables to create a glyph 
run,
;; which is a structure with two vectors: a vector of glyphs and a vector of 
glyph positions
;; once we have the glyph we can `glyph-decode` it and inspect its yMax value.
(match (layout f "♖")
  [(glyphrun (vector glyph _ ...) _) (hash-ref (glyph-decode glyph) 'yMax)])



> On 21 Jul 20, at 4:25 AM, Jens Axel Søgaard  wrote:
> 
> It helps to use the correct font...
> 
> It turns out the chess rook is not in "Courier", it is in  "Arial Unicode MS".
> The raw pango functions aren't clever enough to find an alternative font,
> but I think `text` from `pict` is. I am not sure of the details here though.

-- 
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/43A50577-DCC4-49DE-B33E-8CB16A1B2A10%40mbtype.com.


[racket-users] Re: Removing duplicates from a list while still maintaining order in Dr. Racket.

2020-07-21 Thread Prabhakar Ragde
Could you point us to the original homework question so we can be sure of 
the requirements? Thanks.

On Monday, July 20, 2020 at 12:04:45 PM UTC-4, JJ C wrote:
>
> In Beginning Student with List Abbreviations
>
> I am struggling to come up with functions to remove duplicates from a list 
> while maintaining the order of the list.
>
> one function to remove duplicates from the left,
>
> i.e. 1 2 1 3 2 4 5 -> 1 2 3 4 5
>
> and one from the right.
>
> i.e. 1 2 1 3 2 4 5 -> 1 3 2 4 5
>
> What are the functions for removing duplicates from each left and right 
> side? If you need to, use helper functions and append, cond, cons, equal?, 
> etc but not using reverse or any built-in 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/d99af45d-b59c-4878-83b8-c77d145858bbo%40googlegroups.com.


Re: [racket-users] Font bearing - lining up texts and outlines

2020-07-21 Thread Jens Axel Søgaard
Den man. 20. jul. 2020 kl. 19.14 skrev Jens Axel Søgaard <
jensa...@soegaard.net>:

> Thanks for the response.
>
> I have attempted to go in your foot steps and have made a single file
> example, so it is easy to try out.
> Just to recap, the goal is to get the vertical bearing.
>
> The first step is to get the pict `text` numbers and the pango numbers
> (ascent, descent and height) -
> but I can't get them to match. Any hints or ideas are welcome.
>

It helps to use the correct font...

It turns out the chess rook is not in "Courier", it is in  "Arial Unicode
MS".
The raw pango functions aren't clever enough to find an alternative font,
but I think `text` from `pict` is. I am not sure of the details here though.

/Jens Axel

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


[racket-users] Racket News - Issue 35

2020-07-21 Thread Paulo Matos
Hey all,

Issue 35 is here: https://racket-news.com/2020/07/racket-news-issue-35.html

Apologies for the slight delay but I started feeling quite poorly yesterday 
evening as I was about to finish the editing of the issue.

Have a great day and Enjoy!

Paulo Matos

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