[racket-users] Recording of conference talk: Make your own language with Racket FOSDEM19

2019-02-25 Thread Stephen De Gabrielle
FYI  Recording of conference talk
Make your own language with Racket
by Jérôme Martin at FOSDEM 19

(I didn’t go)

https://fosdem.org/2019/schedule/event/makeownlangracket/

-- 


-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Representing array of long ints for ncurses ffi

2019-02-25 Thread Sydney Bean
Hello :)
I'm working on a FFI API for ncurses 
https://github.com/dys-bigwig/racket-ncurses and I'm having some trouble 
figuring out how best to represent the titular construct: an array of long 
ints. 

To quote Dan Gookin's excellent ncurses reference:

"chstr is an array of formatted text to be displayed on the screen. The 
> array is composed of chtype characters, which are not char but long int 
> values. (The chtype character consists of a character plus attribute 
> information.)"


this being my first time doing anything of this nature, I'm struggling to 
work out just what features/procedures/representation I should be using to 
best facilitate this.
I have the single chtype defined as follows:

(define _chtype (make-ctype _long #f #f))


and I'm using char->integer to convert racket chars for the addch family of 
functions, combined with a bitwise-ior to apply the attribute mask. I did 
try providing a racket conversion function as part of the definition, but 
that prevented the attribute mask from being applied (trying to apply 
bitwise-ior to #\A for example). Back to the matter at hand, for the 
addchstr function (which utilises the aforementioned chtype-arrays) my plan 
is to use string->list and then map the bitwise-ior over said list. 
However, I first need to decide how to represent the associated c array 
type which will be populated with these attribute masked (long) integers.

I feel I'm really at the point (as if I wasn't before) of needing to ask 
for assistance from someone who has a better idea of how this should be 
handled, so as to minimise the amount of work I may potentially have to 
redo.

Advice would be greatly appreciated. Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cannot use case+else inside match+else

2019-02-25 Thread Ben Greenman
Here's a suggestion for the docs:

https://github.com/racket/racket/pull/2505

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cannot use case+else inside match+else

2019-02-25 Thread Jon Zeppieri
Previously on this program...

https://lists.racket-lang.org/dev/archive/2013-May/thread.html
[racket-dev] else clauses: possible change to match?



On Mon, Feb 25, 2019 at 10:59 PM Greg Hendershott 
wrote:

> Yep, I also spent a non-zero number of years not even realizing "else"
> wasn't a magic literal for match. And then remembering to use _
> instead, as Sorawee suggested.
>
>
> I think this shows why it's usually better for syntax to use
> #:keywords instead of literals? If cond and case used #:else, this
> wouldn't be a problem.
>
> (Racket inherited those from Scheme. But we don't have to follow that
> example in our own, new macros.)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cannot use case+else inside match+else

2019-02-25 Thread Greg Hendershott
Yep, I also spent a non-zero number of years not even realizing "else"
wasn't a magic literal for match. And then remembering to use _
instead, as Sorawee suggested.


I think this shows why it's usually better for syntax to use
#:keywords instead of literals? If cond and case used #:else, this
wouldn't be a problem.

(Racket inherited those from Scheme. But we don't have to follow that
example in our own, new macros.)

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: How do I get (system-tzid) to return the correct value?

2019-02-25 Thread Jon Zeppieri
On Mon, Feb 25, 2019 at 9:42 PM Brian Adkins  wrote:

> On Friday, February 22, 2019 at 4:00:11 PM UTC-5, Jon Zeppieri wrote:
>
> Thanks for the fix Jon. I'm still a relative Racket newbie - I'd like to
> be able to install your package from the new branch, but I'd also like to
> be able to go back to the way things are now. As far as I know, I didn't
> install tzinfo explicitly, so I expect maybe the gregor package has it as a
> dependency. If that's the case, will gregor just happily use the new
> package from your branch?
>

Yep, tzinfo is a dependency of gregor. That won't prevent you from updating
tzinfo in-place, however. You can install the version from the github
branch and test it out. (I already tested it locally, on OS X and on
Windows in a virtual machine, but it would be great to have a Ubuntu test,
as well.) If it works, I'll merge the changes, and then you should be able
to upgrade the package again to the new published version.

If you prefer not to install an unpublished version, that's fine too. I
feel confident enough to merge the PR as-is. (I know, at least, that it
works on OS X and Windows.)

- Jon

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: How do I get (system-tzid) to return the correct value?

2019-02-25 Thread Brian Adkins
On Friday, February 22, 2019 at 4:00:11 PM UTC-5, Jon Zeppieri wrote:
>
>
>
> On Fri, Feb 22, 2019 at 11:36 AM Brian Adkins  > wrote:
>
>>
>> It seems that not short circuiting would be a good idea regardless of 
>> other changes. It's not urgent for me, because the code in question won't 
>> run late in the evening where the problem occurs.
>>
>>
> I have a proposed fix, if you care (or anyone else cares) to take a look 
> and comment: https://github.com/97jaz/tzinfo/pull/7
>
>
Thanks for the fix Jon. I'm still a relative Racket newbie - I'd like to be 
able to install your package from the new branch, but I'd also like to be 
able to go back to the way things are now. As far as I know, I didn't 
install tzinfo explicitly, so I expect maybe the gregor package has it as a 
dependency. If that's the case, will gregor just happily use the new 
package from your branch? 

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cannot use case+else inside match+else

2019-02-25 Thread Robby Findler
I have been bitten by this one too, it is a bit pernicious. Perhaps we
can adjust the documentation to make more clear that `else` isn't
special in `match`?

Robby

On Mon, Feb 25, 2019 at 6:51 PM Sorawee Porncharoenwase
 wrote:
>
> I usually use _ for the otherwise case because I usually match on an 
> identifier, so I have an id to refer to the matched value already if I need 
> to. The only case I don’t use _ is when I compute something inside the match 
> and also need to use its result:
>
> (match (foo bar)
>   [... ...]
>   [result-of-foo-bar ...])
>
>
> On Mon, Feb 25, 2019 at 4:41 PM Shu-Hung You 
>  wrote:
>>
>> Ah!
>>
>> Thank you for pointing this out. I've always thought that `else' is
>> treated as a keyword in `match' just as what `cond' does. That
>> explains everything.
>>
>> On Mon, Feb 25, 2019 at 6:35 PM Sam Tobin-Hochstadt
>>  wrote:
>> >
>> > This is because 'case' expects a particular binding for 'else', but you 
>> > shadowed it with 'match', which does not treat 'else' differently than any 
>> > other identifier.
>> >
>> > Sam
>> >
>> > On Mon, Feb 25, 2019, 7:33 PM Shu-Hung You 
>> >  wrote:
>> >>
>> >> When using a case expression with an else clause in inside a match
>> >> expression, the expander complains about case having a bad syntax.
>> >> However, the use of case expressions outside of match are fine. Is
>> >> there anyway to get around this?
>> >>
>> >> Currently, I just replace it with another match.
>> >>
>> >> #lang racket/base
>> >>
>> >> (require racket/match)
>> >>
>> >> (match 6
>> >>   [else
>> >>(case 5
>> >>  [else 7])])
>> >>
>> >> #|
>> >> unsaved editor:8:6: case: bad syntax (not a datum sequence) at: else
>> >> in: (case 5 (else 7))
>> >>   #(78 4)
>> >> |#
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google Groups 
>> >> "Racket Users" group.
>> >> To unsubscribe from this group and stop receiving emails from it, send an 
>> >> email to racket-users+unsubscr...@googlegroups.com.
>> >> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cannot use case+else inside match+else

2019-02-25 Thread Sorawee Porncharoenwase
I usually use _ for the otherwise case because I usually match on an
identifier, so I have an id to refer to the matched value already if I need
to. The only case I don’t use _ is when I compute something inside the
match and also need to use its result:

(match (foo bar)
  [... ...]
  [result-of-foo-bar ...])


On Mon, Feb 25, 2019 at 4:41 PM Shu-Hung You <
shu-hung@eecs.northwestern.edu> wrote:

> Ah!
>
> Thank you for pointing this out. I've always thought that `else' is
> treated as a keyword in `match' just as what `cond' does. That
> explains everything.
>
> On Mon, Feb 25, 2019 at 6:35 PM Sam Tobin-Hochstadt
>  wrote:
> >
> > This is because 'case' expects a particular binding for 'else', but you
> shadowed it with 'match', which does not treat 'else' differently than any
> other identifier.
> >
> > Sam
> >
> > On Mon, Feb 25, 2019, 7:33 PM Shu-Hung You <
> shu-hung@eecs.northwestern.edu> wrote:
> >>
> >> When using a case expression with an else clause in inside a match
> >> expression, the expander complains about case having a bad syntax.
> >> However, the use of case expressions outside of match are fine. Is
> >> there anyway to get around this?
> >>
> >> Currently, I just replace it with another match.
> >>
> >> #lang racket/base
> >>
> >> (require racket/match)
> >>
> >> (match 6
> >>   [else
> >>(case 5
> >>  [else 7])])
> >>
> >> #|
> >> unsaved editor:8:6: case: bad syntax (not a datum sequence) at: else
> >> in: (case 5 (else 7))
> >>   #(78 4)
> >> |#
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> >> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cannot use case+else inside match+else

2019-02-25 Thread Shu-Hung You
Ah!

Thank you for pointing this out. I've always thought that `else' is
treated as a keyword in `match' just as what `cond' does. That
explains everything.

On Mon, Feb 25, 2019 at 6:35 PM Sam Tobin-Hochstadt
 wrote:
>
> This is because 'case' expects a particular binding for 'else', but you 
> shadowed it with 'match', which does not treat 'else' differently than any 
> other identifier.
>
> Sam
>
> On Mon, Feb 25, 2019, 7:33 PM Shu-Hung You 
>  wrote:
>>
>> When using a case expression with an else clause in inside a match
>> expression, the expander complains about case having a bad syntax.
>> However, the use of case expressions outside of match are fine. Is
>> there anyway to get around this?
>>
>> Currently, I just replace it with another match.
>>
>> #lang racket/base
>>
>> (require racket/match)
>>
>> (match 6
>>   [else
>>(case 5
>>  [else 7])])
>>
>> #|
>> unsaved editor:8:6: case: bad syntax (not a datum sequence) at: else
>> in: (case 5 (else 7))
>>   #(78 4)
>> |#
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cannot use case+else inside match+else

2019-02-25 Thread Sam Tobin-Hochstadt
This is because 'case' expects a particular binding for 'else', but you
shadowed it with 'match', which does not treat 'else' differently than any
other identifier.

Sam

On Mon, Feb 25, 2019, 7:33 PM Shu-Hung You <
shu-hung@eecs.northwestern.edu> wrote:

> When using a case expression with an else clause in inside a match
> expression, the expander complains about case having a bad syntax.
> However, the use of case expressions outside of match are fine. Is
> there anyway to get around this?
>
> Currently, I just replace it with another match.
>
> #lang racket/base
>
> (require racket/match)
>
> (match 6
>   [else
>(case 5
>  [else 7])])
>
> #|
> unsaved editor:8:6: case: bad syntax (not a datum sequence) at: else
> in: (case 5 (else 7))
>   #(78 4)
> |#
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cannot use case+else inside match+else

2019-02-25 Thread 'John Clements' via Racket Users
I may be missing something obvious, here, but why are you using the name “else” 
to bind the result in the match clause? I usually use the name “other”, which 
might solve your problem.

John

> On Feb 25, 2019, at 4:32 PM, Shu-Hung You 
>  wrote:
> 
> When using a case expression with an else clause in inside a match
> expression, the expander complains about case having a bad syntax.
> However, the use of case expressions outside of match are fine. Is
> there anyway to get around this?
> 
> Currently, I just replace it with another match.
> 
> #lang racket/base
> 
> (require racket/match)
> 
> (match 6
>  [else
>   (case 5
> [else 7])])
> 
> #|
> unsaved editor:8:6: case: bad syntax (not a datum sequence) at: else
> in: (case 5 (else 7))
>  #(78 4)
> |#
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Cannot use case+else inside match+else

2019-02-25 Thread Shu-Hung You
When using a case expression with an else clause in inside a match
expression, the expander complains about case having a bad syntax.
However, the use of case expressions outside of match are fine. Is
there anyway to get around this?

Currently, I just replace it with another match.

#lang racket/base

(require racket/match)

(match 6
  [else
   (case 5
 [else 7])])

#|
unsaved editor:8:6: case: bad syntax (not a datum sequence) at: else
in: (case 5 (else 7))
  #(78 4)
|#

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] how to use union types

2019-02-25 Thread Philip McGrath
An alternative to figuring out how to satisfy the type checker is to use
`cast`, e.g.:
#lang typed/racket
(require typed/json)
(string-join
 (cast
  (string->jsexpr
   "[\"The\",\"quick\",\"brown\",\"fox\",\"...\"]")
  (Listof String)))

Obviously this has pros and cons, the main pro being that it runs. The
biggest con, in my view, is that you effectively are dropping into untyped
world. If you figure out how to satisfy the type checker, you get assurance
that your code is well-typed, which is presumably what you want if your
using Typed Racket in the first place. Using `cast` means that you are
responsible for making sure that expression has the type you say it does,
without help from Typed Racket, or you will get a runtime error. For
example, I often forget that `read-json` might return `eof` rather than a
`JSExpr`. Also, `cast` uses the contract machinery, which can carry
performance costs.

But the fact that it runs is not a small benefit, especially if it lets you
fill in other parts of your program and come back to remove the `cast`
later. It also lets you take advantage of Typed Racket to generate any
complicated runtime checks.

-Philip


On Mon, Feb 25, 2019 at 6:49 PM  wrote:

> A JSExpr is one of a couple of things:
>
> - A list
> - A hash with symbol keys
> - A number
> - A string
> - A boolean
> - Null
>
> The (andmap string?) approach implicitly assumes you're giving it a list.
> But it might be something else instead, so you want this: (and (list? js)
> (andmap string? js))
>
> On Monday, February 25, 2019 at 3:44:38 PM UTC-8, Brian Craft wrote:
>>
>> So, that also gives me a type error:
>>
>>  Type Checker: Polymorphic function `andmap' could not be applied to
>> arguments:
>> Domains: (-> a b ... b c) (Listof a) (Listof b) ... b
>>  (-> a c : d) (Listof a)
>> Arguments: (-> Any Boolean : String) (U EOF JSExpr)
>>
>>   in: (andmap string? s)
>>
>>
>> On Monday, February 25, 2019 at 3:22:12 PM UTC-8, Sam Tobin-Hochstadt
>> wrote:
>>>
>>> I think (andmap string? ...) is probably the easiest way to check that.
>>>
>>> Sam
>>>
>>> On Mon, Feb 25, 2019, 6:20 PM Brian Craft  wrote:
>>>
 In typed racket, parsing a string list gives me a JSExpr, which is a
 union. I need to pass it to functions that operate on string lists, but
 can't figure out how to please the type checker. Maybe with occurrence
 typing? But I don't know how to assert "this is a list of strings".

 --
 You received this message because you are subscribed to the Google
 Groups "Racket Users" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to racket-users...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] how to use union types

2019-02-25 Thread jackhfirth
A JSExpr is one of a couple of things:

- A list
- A hash with symbol keys
- A number
- A string
- A boolean
- Null

The (andmap string?) approach implicitly assumes you're giving it a list. 
But it might be something else instead, so you want this: (and (list? js) 
(andmap string? js))

On Monday, February 25, 2019 at 3:44:38 PM UTC-8, Brian Craft wrote:
>
> So, that also gives me a type error:
>
>  Type Checker: Polymorphic function `andmap' could not be applied to 
> arguments:
> Domains: (-> a b ... b c) (Listof a) (Listof b) ... b
>  (-> a c : d) (Listof a)
> Arguments: (-> Any Boolean : String) (U EOF JSExpr)
>
>   in: (andmap string? s)
>
>
> On Monday, February 25, 2019 at 3:22:12 PM UTC-8, Sam Tobin-Hochstadt 
> wrote:
>>
>> I think (andmap string? ...) is probably the easiest way to check that. 
>>
>> Sam
>>
>> On Mon, Feb 25, 2019, 6:20 PM Brian Craft  wrote:
>>
>>> In typed racket, parsing a string list gives me a JSExpr, which is a 
>>> union. I need to pass it to functions that operate on string lists, but 
>>> can't figure out how to please the type checker. Maybe with occurrence 
>>> typing? But I don't know how to assert "this is a list of strings".
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Racket Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to racket-users...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] how to use union types

2019-02-25 Thread Sam Tobin-Hochstadt
That's because you don't necessarily have a list there, so you need to
combine it with a list? check.

Sam

On Mon, Feb 25, 2019, 6:44 PM Brian Craft  wrote:

> So, that also gives me a type error:
>
>  Type Checker: Polymorphic function `andmap' could not be applied to
> arguments:
> Domains: (-> a b ... b c) (Listof a) (Listof b) ... b
>  (-> a c : d) (Listof a)
> Arguments: (-> Any Boolean : String) (U EOF JSExpr)
>
>   in: (andmap string? s)
>
>
> On Monday, February 25, 2019 at 3:22:12 PM UTC-8, Sam Tobin-Hochstadt
> wrote:
>>
>> I think (andmap string? ...) is probably the easiest way to check that.
>>
>> Sam
>>
>> On Mon, Feb 25, 2019, 6:20 PM Brian Craft  wrote:
>>
>>> In typed racket, parsing a string list gives me a JSExpr, which is a
>>> union. I need to pass it to functions that operate on string lists, but
>>> can't figure out how to please the type checker. Maybe with occurrence
>>> typing? But I don't know how to assert "this is a list of strings".
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Racket Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to racket-users...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] how to use union types

2019-02-25 Thread Brian Craft
So, that also gives me a type error:

 Type Checker: Polymorphic function `andmap' could not be applied to 
arguments:
Domains: (-> a b ... b c) (Listof a) (Listof b) ... b
 (-> a c : d) (Listof a)
Arguments: (-> Any Boolean : String) (U EOF JSExpr)

  in: (andmap string? s)


On Monday, February 25, 2019 at 3:22:12 PM UTC-8, Sam Tobin-Hochstadt wrote:
>
> I think (andmap string? ...) is probably the easiest way to check that. 
>
> Sam
>
> On Mon, Feb 25, 2019, 6:20 PM Brian Craft  > wrote:
>
>> In typed racket, parsing a string list gives me a JSExpr, which is a 
>> union. I need to pass it to functions that operate on string lists, but 
>> can't figure out how to please the type checker. Maybe with occurrence 
>> typing? But I don't know how to assert "this is a list of strings".
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] how to use union types

2019-02-25 Thread Sam Tobin-Hochstadt
I think (andmap string? ...) is probably the easiest way to check that.

Sam

On Mon, Feb 25, 2019, 6:20 PM Brian Craft  wrote:

> In typed racket, parsing a string list gives me a JSExpr, which is a
> union. I need to pass it to functions that operate on string lists, but
> can't figure out how to please the type checker. Maybe with occurrence
> typing? But I don't know how to assert "this is a list of strings".
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] how to use union types

2019-02-25 Thread Brian Craft
In typed racket, parsing a string list gives me a JSExpr, which is a union. 
I need to pass it to functions that operate on string lists, but can't 
figure out how to please the type checker. Maybe with occurrence typing? 
But I don't know how to assert "this is a list of strings".

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] lightning talk ideas?

2019-02-25 Thread Ryan Kramer
Thinking about evangelism... I go to a functional programming meetup and we 
usually do "lightning talks" which are described as:

"Sticking with our short talk/demo format, we will once again have 3 - 5 
> slots available for you to show what you're working on, share something you 
> learned, or demo some cool code.
>
> The presentation should aim to be 5 - 15 minutes, with a hard time limit 
> of 20 minutes. Please post a comment with a brief description of what you'd 
> like to present. Anything FP-related is fair game!
>
> I'd really like to encourage as many members as possible to participate. 
> Even if you're just learning something, you can still present. It will help 
> you learn it more deeply by sharing and explaining."
>

I've given two, with a 3rd one planned:
1) you can customize #%app and that's pretty cool
2) define/contract made me realize static typing isn't as important as I've 
always thought
3) scribble is awesome (seriously, does any language have a better code 
documentation tool?)

Obviously there are many great things about Racket, but it can be hard to 
think of a talk that
1) targets FPers who may not have scheme experience
2) can be explained quickly
3) leaves the audience thinking "that's cool, maybe I should take a look at 
Racket"

Any 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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] type annotation example

2019-02-25 Thread Sam Tobin-Hochstadt
Version 6.0 was released 5 years ago, so while I don't recall exactly when
the prefix -> syntax was introduced, it was most likely since then.

Sam

On Mon, Feb 25, 2019, 1:46 PM Brian Craft  wrote:

> yeah, maybe version. Has this changed since 6.0?
>
> On Monday, February 25, 2019 at 10:39:23 AM UTC-8, johnbclements wrote:
>>
>> When I paste that code into a file called `foo`, it runs fine.
>> Transcript:
>>
>> hardy:/tmp clements> cat foo
>> #lang typed/racket
>> (require typed/racket/base)
>>
>> (: fn (-> String Symbol))
>> (define (fn str) 'foo)
>> hardy:/tmp clements> racket foo
>> hardy:/tmp clements>
>>
>> I can’t honestly guess what the problem is. Wrong version of racket?
>>
>> John
>>
>>
>> > On Feb 25, 2019, at 10:11 AM, Brian Craft  wrote:
>> >
>> > Doing a cut & paste from the typed racket docs, I'm getting a compile
>> error. Input file:
>> >
>> > #lang typed/racket
>> > (require typed/racket/base)
>> >
>> > (: fn (-> String Symbol))
>> > (define (fn str) 'foo)
>> >
>> >
>> > 'fn' taken from this page:
>> >
>> >
>> https://docs.racket-lang.org/ts-guide/more.html#%28part._when-annotations~3f%29
>> >
>> >
>> > Running with 'racket foo', gives me
>> > Type Checker: ->: bad syntax
>> >   in: (-> String Symbol)
>> >
>> >
>> > What am I doing wrong?
>> >
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "Racket Users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an email to racket-users...@googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] type annotation example

2019-02-25 Thread Brian Craft
yeah, maybe version. Has this changed since 6.0?

On Monday, February 25, 2019 at 10:39:23 AM UTC-8, johnbclements wrote:
>
> When I paste that code into a file called `foo`, it runs fine. Transcript: 
>
> hardy:/tmp clements> cat foo 
> #lang typed/racket 
> (require typed/racket/base) 
>
> (: fn (-> String Symbol)) 
> (define (fn str) 'foo) 
> hardy:/tmp clements> racket foo 
> hardy:/tmp clements> 
>
> I can’t honestly guess what the problem is. Wrong version of racket? 
>
> John 
>
>
> > On Feb 25, 2019, at 10:11 AM, Brian Craft  > wrote: 
> > 
> > Doing a cut & paste from the typed racket docs, I'm getting a compile 
> error. Input file: 
> > 
> > #lang typed/racket 
> > (require typed/racket/base) 
> > 
> > (: fn (-> String Symbol)) 
> > (define (fn str) 'foo) 
> > 
> > 
> > 'fn' taken from this page: 
> > 
> > 
> https://docs.racket-lang.org/ts-guide/more.html#%28part._when-annotations~3f%29
>  
> > 
> > 
> > Running with 'racket foo', gives me 
> > Type Checker: ->: bad syntax 
> >   in: (-> String Symbol) 
> > 
> > 
> > What am I doing wrong? 
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "Racket Users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to racket-users...@googlegroups.com . 
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] type annotation example

2019-02-25 Thread 'John Clements' via Racket Users
When I paste that code into a file called `foo`, it runs fine. Transcript:

hardy:/tmp clements> cat foo
#lang typed/racket
(require typed/racket/base)

(: fn (-> String Symbol))
(define (fn str) 'foo)
hardy:/tmp clements> racket foo
hardy:/tmp clements> 

I can’t honestly guess what the problem is. Wrong version of racket? 

John


> On Feb 25, 2019, at 10:11 AM, Brian Craft  wrote:
> 
> Doing a cut & paste from the typed racket docs, I'm getting a compile error. 
> Input file:
> 
> #lang typed/racket
> (require typed/racket/base)
> 
> (: fn (-> String Symbol))
> (define (fn str) 'foo)
> 
> 
> 'fn' taken from this page:
> 
> https://docs.racket-lang.org/ts-guide/more.html#%28part._when-annotations~3f%29
> 
> 
> Running with 'racket foo', gives me
> Type Checker: ->: bad syntax
>   in: (-> String Symbol)
> 
> 
> What am I doing wrong?
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] type annotation example

2019-02-25 Thread Brian Craft
Doing a cut & paste from the typed racket docs, I'm getting a compile 
error. Input file:

#lang typed/racket
(require typed/racket/base)

(: fn (-> String Symbol))
(define (fn str) 'foo)


'fn' taken from this page:

https://docs.racket-lang.org/ts-guide/more.html#%28part._when-annotations~3f%29


Running with 'racket foo', gives me
Type Checker: ->: bad syntax
  in: (-> String Symbol)


What am I doing wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Help with generators from python land!

2019-02-25 Thread Konrad Hinsen

On 23/02/2019 14:25, Zelphir Kaltstahl wrote:

The main difference, as has been pointed out before, is that Python
generators are more common as an idiom for solving problems that in
Racket would typically be approached differently.

This piqued my interest. Can you elaborate a bit or give an example? How
would one approach things with Racket differently?


Stream and sequence processing in Racket cover much of what generators 
are used for in Python. The simplest example is stream-map in Racket, 
whose Python 2 equivalent would require a generator. In Python 3, the 
standard map has become lazy.


Konrad.


--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.