Re: [racket-users] Polymorphic functions on Typed Racket classes

2017-07-18 Thread Sourav Datta
On Tuesday, July 18, 2017 at 7:41:05 PM UTC+5:30, Matthias Felleisen wrote:
> In essence, TR’s local inference algorithm cannot determine the type of the 
> sequence you created. It is one of those cases where you need to help along 
> the type checker with the equivalent of an explicit type application: 
>  
>  ((inst seq-first Integer) s1)
> 
>  ((inst seq-rest Integer) s1)
> 
> I have also taken the liberty to rewrite your code a bit. 
> 
> 
> 
> 
> 
> #lang typed/racket
> 
> (define-type (Seq a) (Object [first (-> a)] [rest (-> (Seq a))]))
> 
> (: seq-first (All (a) (-> (Seq a) a)))
> (define (seq-first s) (send s first))
> 
> (: seq-rest (All (a) (-> (Seq a) (Seq a
> (define (seq-rest s) (send s rest))
> 
> (: make-seq (-> (Listof Integer) (Seq Integer)))
> (define (make-seq si)
>   (new (class object%
>          (field [data : (Listof Integer) si])
>          
>          (: first (-> Integer))
>          (define/public (first)
>            (if (empty? data)
>                (error "Empty")
>                (car data)))
>          
>          (: rest (-> (Seq Integer)))
>          (define/public (rest)
>            (if (empty? data)
>                (error "Empty")
>                (make-seq (cdr data
>          
>          (super-new))
>        ))
> 
> 
> (define s1 (make-seq '(1 2 3 4)))
> (send s1 first)
> (send s1 rest)
> 
> ((inst seq-first Integer) s1)
> ((inst seq-rest Integer) s1)
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> On Jul 18, 2017, at 2:57 AM, Sourav Datta  wrote:
> 
> Hi!
> 
> I am encountering a type checker error for the following program but not sure 
> exactly what is wrong with it. The program is as follows:
> 
> #lang typed/racket
> 
> (define-type (Seq a) (Object [first (-> a)]
>                                                [rest (-> (Seq a))]))
> 
> 
> (: seq-first (All (a) (-> (Seq a) a)))
> (define (seq-first s) (send s first))
> 
> (: seq-rest (All (a) (-> (Seq a) (Seq a
> (define (seq-rest s) (send s rest))
> 
> 
> (: make-seq (-> (Listof Integer) (Seq Integer)))
> (define (make-seq si) (new (class object%
>                             (init-field [data : (Listof Integer) empty])
>                             (: first (-> Integer))
>                             (define/public (first)
>                               (if (empty? data)
>                                   (error "Empty")
>                                   (car data)))
>                             (: rest (-> (Seq Integer)))
>                             (define/public (rest)
>                               (if (empty? data)
>                                   (error "Empty")
>                                   (make-seq (cdr data
>                             (super-new))
>                           [data si]))
> 
> 
> This compiles fine. But calling seq-first or seq-rest on a specific instance 
> like (Seq Integer) fails to type check. Like below:
> 
> (define s1 (make-seq '(1 2 3 4)))
> (send s1 first)
> - : Integer
> 1
> (send s1 rest)
> - : (Seq Integer)
> (object:unsaved-editor:15:27 ...)
> (seq-first s1)
> . Type Checker: Polymorphic function `seq-first' could not be applied to 
> arguments:
> Argument 1:
>  Expected: (Seq a)
>  Given:    (Seq Integer)
> in: (seq-first s1)
> (seq-rest s1)
> . Type Checker: Polymorphic function `seq-rest' could not be applied to 
> arguments:
> Argument 1:
>  Expected: (Seq a)
>  Given:    (Seq Integer)
> in: (seq-rest s1)
> 
> 
> So, the confusion here is, why a (All (a) (Seq a)) is incompatible with a 
> (Seq Integer)?
> 
> 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...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Thanks for pointing that out. What I was actually trying to accomplish was 
basically to create a generic sequence type that can be extended by users by 
just providing two methods `first` and `rest` and then implement a set of 
algorithms that may work generically on any sequence (Seq a) - sort of like 
std::algorithm and iterator protocols in C++. I also, looked into the 
discussions regarding generic operations in Typed Racket. I guess it's not yet 
available/supported fully in TR, is that correct? Also, is there any way of 
doing the same thing with objects/structs without actually knowing the type (or 
instantiating) of the data that is coming to seq-first/seq-rest?


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


Re: [racket-users] Unable to create account on pkgd.racket-lang.org

2017-07-18 Thread Danny Yoo
Ah, I forgot to mention that I'm trying to add an account as
"d...@hashcollision.org", just to clarify.

-- 
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] Unable to create account on pkgd.racket-lang.org

2017-07-18 Thread Danny Yoo
Hi everyone,

I'm trying to get an account on pkgd.racket-lang.org so I can send a few 
updates, but I'm not getting email confirmations from the server.  I've checked 
my spam folder, and I don't think I'm filtering them out there.

The URL I'm seeing is:

https://pkgd.racket-lang.org/pkgn/create;((%22k%22%20.%20%22(2927%2010%2040586231)%22))


If there's other debugging information I can provide, please let me know.  
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Getting the phases right on recursive macros/using ... at runtime in syntax-case

2017-07-18 Thread Ben Greenman
3 hints:
- `type-check` can call any helper functions defined with
`define-for-syntax`
- Turnstile uses `local-expand` to expand any macros in subterms (in your
case, any macros in `x` and `y`)
- start using `syntax-parse` :)

On Tue, Jul 18, 2017 at 6:11 PM, Matthias Felleisen 
wrote:

>
> Take a look at the Turnstile package, its documentation, and the paper
> that comes with it (http://www.ccs.neu.edu/racket/pubs/#popl17-ckg).
>
>
> > On Jul 18, 2017, at 5:37 PM, Sam Waxman  wrote:
> >
> > Hello,
> >
> > Suppose I'd like a type-checking macro that looks something like this:
> >
> > (define-syntax (type-check stx)
> >  (syntax-case stx ()
> >[(_ (+ x y))  (if (and (number? (type-check #'x))
> >   (number? (type-check #'y)))
> >  #'Number #'(error "bad types!"))]
> >[*cases for other expressions]))
> >
> > The macro will examine the syntax it's given and determine the type that
> will be produced at runtime.
> >
> > The key here is that type-check needs to call itself, but that's not
> possible. Type-check is defined to be used in phase 0, but the recursive
> call to type-check takes place in phase 1. If the recursive call to
> type-check makes a recursive-call, then this second call would be running
> in phase 2 and so on. The compiler won't allow me to use this macro in a
> phase it's not defined for, so this code is no good.
> >
> > So, first question: How can I get a macro to call itself recursively
> such as in this case? I can't wrap the entire if in a syntax object,
> because I want to throw that error in phase 1, so the condition of the if
> statement needs to be evaluated inside this macro.
> >
> > Second, even if I get type-check to work in all phases, if I call
> type-check with (+ 1 2), the recursive call to (type-check #'x) will get
> #'x as its "argument" instead of 1, no?
> >
> > It almost feels like I should be doing this with a regular old function
> that takes in syntax, and produces a type, but to my knowledge, I can't use
> ... in runtime expressions such as the following
> >
> > (define (type-check stx)
> >  (syntax-case stx ()
> >[(body) *dummy-value*]
> >[(body ...) (begin (type-check #'body) ...)]))
> >
> > This will result in a syntax-error telling me that ... can't be used as
> an expression like this, which makes it impossible to deal with ... forms.
> >
> > Any advice?
> >
> > Thanks in advance.
> >
> > --
> > 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] Getting the phases right on recursive macros/using ... at runtime in syntax-case

2017-07-18 Thread Matthias Felleisen

Take a look at the Turnstile package, its documentation, and the paper that 
comes with it (http://www.ccs.neu.edu/racket/pubs/#popl17-ckg). 


> On Jul 18, 2017, at 5:37 PM, Sam Waxman  wrote:
> 
> Hello,
> 
> Suppose I'd like a type-checking macro that looks something like this:
> 
> (define-syntax (type-check stx)
>  (syntax-case stx ()
>[(_ (+ x y))  (if (and (number? (type-check #'x)) 
>   (number? (type-check #'y))) 
>  #'Number #'(error "bad types!"))]
>[*cases for other expressions]))
> 
> The macro will examine the syntax it's given and determine the type that will 
> be produced at runtime.
> 
> The key here is that type-check needs to call itself, but that's not 
> possible. Type-check is defined to be used in phase 0, but the recursive call 
> to type-check takes place in phase 1. If the recursive call to type-check 
> makes a recursive-call, then this second call would be running in phase 2 and 
> so on. The compiler won't allow me to use this macro in a phase it's not 
> defined for, so this code is no good.
> 
> So, first question: How can I get a macro to call itself recursively such as 
> in this case? I can't wrap the entire if in a syntax object, because I want 
> to throw that error in phase 1, so the condition of the if statement needs to 
> be evaluated inside this macro.
> 
> Second, even if I get type-check to work in all phases, if I call type-check 
> with (+ 1 2), the recursive call to (type-check #'x) will get #'x as its 
> "argument" instead of 1, no?
> 
> It almost feels like I should be doing this with a regular old function that 
> takes in syntax, and produces a type, but to my knowledge, I can't use ... in 
> runtime expressions such as the following
> 
> (define (type-check stx)
>  (syntax-case stx ()
>[(body) *dummy-value*]
>[(body ...) (begin (type-check #'body) ...)]))
> 
> This will result in a syntax-error telling me that ... can't be used as an 
> expression like this, which makes it impossible to deal with ... forms.
> 
> Any advice?
> 
> Thanks in advance.
> 
> -- 
> 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] Catching duplicate identifiers.

2017-07-18 Thread Matthias Felleisen

Why don’t you intercept the exception in the error handler and rewrite the 
error message? Racket already disallows duplicate names in the same scope, 
which seems to be what you want, except that you don’t like the way the errors 
are reported. 



> On Jul 18, 2017, at 5:47 PM, Sam Waxman  wrote:
> 
> Thanks both for your replies, but it doesn't look like either of these will 
> do exactly what I want. While the code keeping track of id's that you wrote 
> comes close, it doesn't allow for shadowing. I still want racket to do 
> everything that it used to do, so the program
> 
> 
> (define a 3)
> (let ()
>  (define a 4)
>  a)
> 
> should still be valid. Shadowing is okay, I just can't have two duplicate 
> identifiers in the same scope. I suppose I could use your code and clear the 
> id-set every time I entered a new scope, but at that point, I'm basically 
> keeping track of the entire environment and there's not a huge difference 
> between just implementing my own lexical scope. I'd like to just have racket 
> tell me when there are duplicate identifiers, as it has to know to throw it's 
> own errors.
> 
> On Tuesday, July 18, 2017 at 2:08:17 PM UTC-4, Jens Axel Søgaard wrote:
>> #lang racket
>> 
>> 
>> (require (for-syntax syntax/parse syntax/id-set))
>> 
>> 
>> (begin-for-syntax
>>   (define defined-ids  (mutable-free-id-set))
>>   (define (already-defined? x) (free-id-set-member? defined-ids x))
>>   (define (define-it! x)   (free-id-set-add!defined-ids x)))
>> 
>> 
>> (define-syntax (def stx)
>>   (syntax-parse stx
>> [(_def x:id e:expr)
>>  (when (already-defined? #'x)
>>(raise-syntax-error 'def "identifier defined twice" #'stx #'x))
>>  (define-it! #'x)
>>  (syntax/loc stx
>>(define x e))]))
>> 
>> 
>> (def one 1)
>> (def two (+ one one))
>> (def three (+ one two))
>> (def three (+ two one))
>> 
>> 
>> 
>> 
>> 2017-07-18 19:23 GMT+02:00 Matthias Felleisen :
>> 
>> 
>> 
>> 
>> #lang racket
>> 
>> 
>> 
>> (define my-favorite-numbers '(1 2 3))
>> 
>> 
>> 
>> (define (duplicate-exists? n)
>> 
>>   (member n my-favorite-numbers))
>> 
>> 
>> 
>> (duplicate-exists? 3)
>> 
>> (duplicate-exists? 4)
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> On Jul 17, 2017, at 3:43 AM, Sam Waxman  wrote:
>> 
>>> 
>> 
>>> Hello,
>> 
>>> 
>> 
>>> In the regular #racket, the following program
>> 
>>> 
>> 
>>> (define a 1)
>> 
>>> (define a 2)
>> 
>>> 
>> 
>>> will result in a syntax error letting you know that you have a duplicate 
>>> identifier. I would like to make my own define that throws a custom error 
>>> message in this case. I.e.
>> 
>>> 
>> 
>>> (define-syntax (my-define stx)
>> 
>>>   (syntax-parse stx
>> 
>>> [(_ id:id expr) (begin
>> 
>>> (if (duplicate-exists? id)
>> 
>>> (syntax-error "Oh no!")
>> 
>>> (void))
>> 
>>>#'(define id expr)]))
>> 
>>> 
>> 
>>> I know there's a lot of functions like bound-identifier=? and 
>>> check-duplicate-identifier, but they seem to all be geared towards the user 
>>> putting in all the identifiers in question as function arguments. In this 
>>> case, I need a function like
>> 
>>> 
>> 
>>> (duplicate-exists? id)
>> 
>>> 
>> 
>>> that just takes in the single identifier, and checks to see if, in the 
>>> scope the function is invoked, there's a duplicate identifier already 
>>> there. I just can't seem to figure out how to write that function.
>> 
>>> 
>> 
>>> Thanks in advance!
>> 
>>> 
>> 
>>> --
>> 
>>> 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...@googlegroups.com.
>> 
>> For more options, visit https://groups.google.com/d/optout.
>> 
>> 
>> 
>> 
>> 
>> -- 
>> 
>> -- 
>> Jens Axel Søgaard
> 
> -- 
> 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] Catching duplicate identifiers.

2017-07-18 Thread Sam Waxman
Thanks both for your replies, but it doesn't look like either of these will do 
exactly what I want. While the code keeping track of id's that you wrote comes 
close, it doesn't allow for shadowing. I still want racket to do everything 
that it used to do, so the program


(define a 3)
(let ()
  (define a 4)
  a)

should still be valid. Shadowing is okay, I just can't have two duplicate 
identifiers in the same scope. I suppose I could use your code and clear the 
id-set every time I entered a new scope, but at that point, I'm basically 
keeping track of the entire environment and there's not a huge difference 
between just implementing my own lexical scope. I'd like to just have racket 
tell me when there are duplicate identifiers, as it has to know to throw it's 
own errors.

On Tuesday, July 18, 2017 at 2:08:17 PM UTC-4, Jens Axel Søgaard wrote:
> #lang racket
> 
> 
> (require (for-syntax syntax/parse syntax/id-set))
> 
> 
> (begin-for-syntax
>   (define defined-ids          (mutable-free-id-set))
>   (define (already-defined? x) (free-id-set-member? defined-ids x))
>   (define (define-it! x)       (free-id-set-add!    defined-ids x)))
> 
> 
> (define-syntax (def stx)
>   (syntax-parse stx
>     [(_def x:id e:expr)
>      (when (already-defined? #'x)
>        (raise-syntax-error 'def "identifier defined twice" #'stx #'x))
>      (define-it! #'x)
>      (syntax/loc stx
>        (define x e))]))
> 
> 
> (def one 1)
> (def two (+ one one))
> (def three (+ one two))
> (def three (+ two one))
> 
> 
> 
> 
> 2017-07-18 19:23 GMT+02:00 Matthias Felleisen :
> 
> 
> 
> 
> #lang racket
> 
> 
> 
> (define my-favorite-numbers '(1 2 3))
> 
> 
> 
> (define (duplicate-exists? n)
> 
>   (member n my-favorite-numbers))
> 
> 
> 
> (duplicate-exists? 3)
> 
> (duplicate-exists? 4)
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> > On Jul 17, 2017, at 3:43 AM, Sam Waxman  wrote:
> 
> >
> 
> > Hello,
> 
> >
> 
> > In the regular #racket, the following program
> 
> >
> 
> > (define a 1)
> 
> > (define a 2)
> 
> >
> 
> > will result in a syntax error letting you know that you have a duplicate 
> > identifier. I would like to make my own define that throws a custom error 
> > message in this case. I.e.
> 
> >
> 
> > (define-syntax (my-define stx)
> 
> >  (syntax-parse stx
> 
> >    [(_ id:id expr) (begin
> 
> >                    (if (duplicate-exists? id)
> 
> >                        (syntax-error "Oh no!")
> 
> >                        (void))
> 
> >                   #'(define id expr)]))
> 
> >
> 
> > I know there's a lot of functions like bound-identifier=? and 
> > check-duplicate-identifier, but they seem to all be geared towards the user 
> > putting in all the identifiers in question as function arguments. In this 
> > case, I need a function like
> 
> >
> 
> > (duplicate-exists? id)
> 
> >
> 
> > that just takes in the single identifier, and checks to see if, in the 
> > scope the function is invoked, there's a duplicate identifier already 
> > there. I just can't seem to figure out how to write that function.
> 
> >
> 
> > Thanks in advance!
> 
> >
> 
> > --
> 
> > 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...@googlegroups.com.
> 
> For more options, visit https://groups.google.com/d/optout.
> 
> 
> 
> 
> 
> -- 
> 
> -- 
> Jens Axel Søgaard

-- 
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] Getting the phases right on recursive macros/using ... at runtime in syntax-case

2017-07-18 Thread Sam Waxman
Hello,

Suppose I'd like a type-checking macro that looks something like this:

(define-syntax (type-check stx)
  (syntax-case stx ()
[(_ (+ x y))  (if (and (number? (type-check #'x)) 
   (number? (type-check #'y))) 
  #'Number #'(error "bad types!"))]
[*cases for other expressions]))

The macro will examine the syntax it's given and determine the type that will 
be produced at runtime.

The key here is that type-check needs to call itself, but that's not possible. 
Type-check is defined to be used in phase 0, but the recursive call to 
type-check takes place in phase 1. If the recursive call to type-check makes a 
recursive-call, then this second call would be running in phase 2 and so on. 
The compiler won't allow me to use this macro in a phase it's not defined for, 
so this code is no good.

So, first question: How can I get a macro to call itself recursively such as in 
this case? I can't wrap the entire if in a syntax object, because I want to 
throw that error in phase 1, so the condition of the if statement needs to be 
evaluated inside this macro.

Second, even if I get type-check to work in all phases, if I call type-check 
with (+ 1 2), the recursive call to (type-check #'x) will get #'x as its 
"argument" instead of 1, no?

It almost feels like I should be doing this with a regular old function that 
takes in syntax, and produces a type, but to my knowledge, I can't use ... in 
runtime expressions such as the following

(define (type-check stx)
  (syntax-case stx ()
[(body) *dummy-value*]
[(body ...) (begin (type-check #'body) ...)]))

This will result in a syntax-error telling me that ... can't be used as an 
expression like this, which makes it impossible to deal with ... forms.

Any advice?

Thanks in advance.

-- 
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] Call for Participation: ICFP 2017

2017-07-18 Thread 'Lindsey Kuper' via users-redirect
[ Early registration ends 4 August. ]

=

Call for Participation

ICFP 2017
22nd ACM SIGPLAN International Conference on Functional Programming
and affiliated events

September 3 - September 9, 2017
Oxford, UK
http://icfp17.sigplan.org/

=

ICFP provides a forum for researchers and developers to hear
about the latest work on the design, implementations, principles, and
uses of functional programming. The conference covers the entire
spectrum of work, from practice to theory, including its peripheries.

A full week dedicated to functional programming:
ICFP, 2 co-hosted conferences, 1 co-hosted symposium, workshops,
tutorials, programming contest results, student research competition,
and mentoring workshop

* Overview and affiliated events:
  http://icfp17.sigplan.org/home

* Program:
  http://icfp17.sigplan.org/program/program-icfp-2017

* Accepted papers:
  http://icfp17.sigplan.org/track/icfp-2017-papers

* Registration is available via:
  https://regmaster4.com/2017conf/ICFP17/register.php
  Early registration is due 4 August, 2016.

* Programming contest, 4-7 August, 2016:
  http://2017.icfpcontest.org

* Student Research Competition:
  http://icfp17.sigplan.org/track/icfp-2017-Student-Research-Competition

* Follow @icfp_conference on twitter for the latest news:
  http://twitter.com/icfp_conference

There are several events affiliated with ICFP:

 Sunday, September 3
   Workshop on Higher-order Programming with Effects
   Workshop on Type-Driven Development
   Scheme and Functional Programming Workshop
   Programming Languages Mentoring Workshop
   ICFP Tutorials

 Monday, September 4 – Wednesday, September 6
   ICFP
   FSCD - Days 1-3

 Thursday, September 7
   Haskell Symposium – Day 1
   ML Family Workshop
   Workshop on Functional High-Performance Computing
   Commercial Users of Functional Programming – Day 1
   FSCD - Day 4

 Friday, September 8
   Haskell Symposium – Day 2
   OCaml Workshop
   Erlang Workshop
   Commercial Users of Functional Programming – Day 2

 Saturday, September 9
   Commercial Users of Functional Programming – Day 3
   Haskell Implementors Workshop
   Functional Art, Music, Modeling and Design

Conference Organizers:

General Chair: Jeremy Gibbons (University of Oxford, UK)
Program Chair: Mark Jones (Portland State University, USA)

Artifact Evaluation Co-Chair: Matthew Flatt (University of Utah, USA)
Artifact Evaluation Co-Chair: Ryan R. Newton (Indiana University, USA)
Industrial Relations Chair: Ryan Trinkle (Obsidian Systems LLC, USA)
PLMW Co-Chair: Neelakantan R. Krishnawami (University of Cambridge, UK)
PLMW Co-Chair: Dan Licata (Wesleyan University, USA)
PLMW Co-Chair: Brigitte Pientka (McGill University, Canada)
Programming Contest Organiser: Sam Lindley (University of Edinburgh, UK)
Publicity and Web Chair: Lindsey Kuper (Intel Labs, USA)
Student Research Competition Chair: Ilya Sergey (University College London, UK)
Student Volunteer Co-Captain: Yosuke Fukuda (Kyoto University, Japan)
Student Volunteer Co-Captain: Yuki Nishida (Kyoto University, Japan) 
Student Volunteer Co-Captain: Jakub Zalewski (University of Edinburgh, UK)
Video Chair: Jose Calderon (Galois, Inc., USA)
Workshops Co-Chair: Andres Löh (Well-Typed LLP, UK)
Workshops Co-Chair: David Christiansen (Indiana University, USA)

Sponsors and industrial partners:

 Platinum partners
   Ahrefs
   Jane Street Capital

 Gold partners
   Bloomberg
   X

 Silver partners
   Galois
   Oracle

 Bronze partners
   Obsidian Systems
   Portland State University
   Well-Typed

-- 
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] Catching duplicate identifiers.

2017-07-18 Thread Jens Axel Søgaard
#lang racket

(require (for-syntax syntax/parse syntax/id-set))

(begin-for-syntax
  (define defined-ids  (mutable-free-id-set))
  (define (already-defined? x) (free-id-set-member? defined-ids x))
  (define (define-it! x)   (free-id-set-add!defined-ids x)))

(define-syntax (def stx)
  (syntax-parse stx
[(_def x:id e:expr)
 (when (already-defined? #'x)
   (raise-syntax-error 'def "identifier defined twice" #'stx #'x))
 (define-it! #'x)
 (syntax/loc stx
   (define x e))]))

(def one 1)
(def two (+ one one))
(def three (+ one two))
(def three (+ two one))


2017-07-18 19:23 GMT+02:00 Matthias Felleisen :

>
>
> #lang racket
>
> (define my-favorite-numbers '(1 2 3))
>
> (define (duplicate-exists? n)
>   (member n my-favorite-numbers))
>
> (duplicate-exists? 3)
> (duplicate-exists? 4)
>
>
>
>
> > On Jul 17, 2017, at 3:43 AM, Sam Waxman  wrote:
> >
> > Hello,
> >
> > In the regular #racket, the following program
> >
> > (define a 1)
> > (define a 2)
> >
> > will result in a syntax error letting you know that you have a duplicate
> identifier. I would like to make my own define that throws a custom error
> message in this case. I.e.
> >
> > (define-syntax (my-define stx)
> >  (syntax-parse stx
> >[(_ id:id expr) (begin
> >(if (duplicate-exists? id)
> >(syntax-error "Oh no!")
> >(void))
> >   #'(define id expr)]))
> >
> > I know there's a lot of functions like bound-identifier=? and
> check-duplicate-identifier, but they seem to all be geared towards the user
> putting in all the identifiers in question as function arguments. In this
> case, I need a function like
> >
> > (duplicate-exists? id)
> >
> > that just takes in the single identifier, and checks to see if, in the
> scope the function is invoked, there's a duplicate identifier already
> there. I just can't seem to figure out how to write that function.
> >
> > Thanks in advance!
> >
> > --
> > 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.
>



-- 
-- 
Jens Axel Søgaard

-- 
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] Catching duplicate identifiers.

2017-07-18 Thread Matthias Felleisen


#lang racket

(define my-favorite-numbers '(1 2 3))

(define (duplicate-exists? n)
  (member n my-favorite-numbers))

(duplicate-exists? 3)
(duplicate-exists? 4)




> On Jul 17, 2017, at 3:43 AM, Sam Waxman  wrote:
> 
> Hello,
> 
> In the regular #racket, the following program
> 
> (define a 1)
> (define a 2)
> 
> will result in a syntax error letting you know that you have a duplicate 
> identifier. I would like to make my own define that throws a custom error 
> message in this case. I.e.
> 
> (define-syntax (my-define stx)
>  (syntax-parse stx
>[(_ id:id expr) (begin
>(if (duplicate-exists? id) 
>(syntax-error "Oh no!") 
>(void))
>   #'(define id expr)]))
> 
> I know there's a lot of functions like bound-identifier=? and 
> check-duplicate-identifier, but they seem to all be geared towards the user 
> putting in all the identifiers in question as function arguments. In this 
> case, I need a function like
> 
> (duplicate-exists? id)
> 
> that just takes in the single identifier, and checks to see if, in the scope 
> the function is invoked, there's a duplicate identifier already there. I just 
> can't seem to figure out how to write that function.
> 
> Thanks in advance!
> 
> -- 
> 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] Example of file i/o?

2017-07-18 Thread Leith
Very good, thank you!

On Tuesday, July 18, 2017 at 11:54:14 AM UTC-5, Ben Greenman wrote:
> (with-input-from-file "file.txt"
>   (lambda ()
>     (for ((line (in-lines)))
>       )))
> 
> 
> On Tue, Jul 18, 2017 at 12:46 PM, Leith  wrote:
> Basic question, but I can't seem to find a good answer.  What is an example 
> of "idiomatic" file I/O using racket?  Like, for example, open a file for 
> reading and do something with every line in the file?
> 
> 
> 
> The example here: https://docs.racket-lang.org/guide/io-patterns.html  says 
> "If you want to process individual lines of a file" but then it doesn't open 
> a file at all.  It uses open-input-string.  I'm guessing it would be 
> sufficient to use open-input-file instead?  Also, what is the right way to 
> read a line at a time until EOF?
> 
> 
> 
> 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...@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] Example of file i/o?

2017-07-18 Thread Ben Greenman
(with-input-from-file "file.txt"
  (lambda ()
(for ((line (in-lines)))
  )))

On Tue, Jul 18, 2017 at 12:46 PM, Leith  wrote:

> Basic question, but I can't seem to find a good answer.  What is an
> example of "idiomatic" file I/O using racket?  Like, for example, open a
> file for reading and do something with every line in the file?
>
> The example here: https://docs.racket-lang.org/guide/io-patterns.html
> says "If you want to process individual lines of a file" but then it
> doesn't open a file at all.  It uses open-input-string.  I'm guessing it
> would be sufficient to use open-input-file instead?  Also, what is the
> right way to read a line at a time until EOF?
>
> 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.
> 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] Example of file i/o?

2017-07-18 Thread Leith
Basic question, but I can't seem to find a good answer.  What is an example of 
"idiomatic" file I/O using racket?  Like, for example, open a file for reading 
and do something with every line in the file?

The example here: https://docs.racket-lang.org/guide/io-patterns.html  says "If 
you want to process individual lines of a file" but then it doesn't open a file 
at all.  It uses open-input-string.  I'm guessing it would be sufficient to use 
open-input-file instead?  Also, what is the right way to read a line at a time 
until EOF?

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


[racket-users] Racket v6.9.0.900 is available for testing

2017-07-18 Thread Vincent St-Amour
Version 6.9.0.900 is now available for testing from

  http://pre-release.racket-lang.org/

(Note that this is not available from the usual download site.)

If all goes well, we will turn this version into a v6.10 release
within a couple of weeks.

This release includes a overhaul of Racket's IO facilities. Because
this is a major change to a portion of the codebase that includes a
lot of platform-specific code, we would like to invite people using
Racket on less common platforms (*BSD, OpenIndiana, etc.) or
architectures to help us test this new implementation.

Your help and feedback in testing this new release candidate would be
much appreciated.

-- 
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] Polymorphic functions on Typed Racket classes

2017-07-18 Thread Matthias Felleisen

In essence, TR’s local inference algorithm cannot determine the type of the 
sequence you created. It is one of those cases where you need to help along the 
type checker with the equivalent of an explicit type application: 
 
 ((inst seq-first Integer) s1)

 ((inst seq-rest Integer) s1)

I have also taken the liberty to rewrite your code a bit. 


#lang typed/racket

(define-type (Seq a) (Object [first (-> a)] [rest (-> (Seq a))]))

(: seq-first (All (a) (-> (Seq a) a)))
(define (seq-first s) (send s first))

(: seq-rest (All (a) (-> (Seq a) (Seq a
(define (seq-rest s) (send s rest))

(: make-seq (-> (Listof Integer) (Seq Integer)))
(define (make-seq si)
  (new (class object%
 (field [data : (Listof Integer) si])
 
 (: first (-> Integer))
 (define/public (first)
   (if (empty? data)
   (error "Empty")
   (car data)))
 
 (: rest (-> (Seq Integer)))
 (define/public (rest)
   (if (empty? data)
   (error "Empty")
   (make-seq (cdr data
 
 (super-new))
   ))


(define s1 (make-seq '(1 2 3 4)))
(send s1 first)
(send s1 rest)

((inst seq-first Integer) s1)
((inst seq-rest Integer) s1)









> On Jul 18, 2017, at 2:57 AM, Sourav Datta  wrote:
> 
> Hi!
> 
> I am encountering a type checker error for the following program but not sure 
> exactly what is wrong with it. The program is as follows:
> 
> #lang typed/racket
> 
> (define-type (Seq a) (Object [first (-> a)]
>[rest (-> (Seq a))]))
> 
> 
> (: seq-first (All (a) (-> (Seq a) a)))
> (define (seq-first s) (send s first))
> 
> (: seq-rest (All (a) (-> (Seq a) (Seq a
> (define (seq-rest s) (send s rest))
> 
> 
> (: make-seq (-> (Listof Integer) (Seq Integer)))
> (define (make-seq si) (new (class object%
> (init-field [data : (Listof Integer) empty])
> (: first (-> Integer))
> (define/public (first)
>   (if (empty? data)
>   (error "Empty")
>   (car data)))
> (: rest (-> (Seq Integer)))
> (define/public (rest)
>   (if (empty? data)
>   (error "Empty")
>   (make-seq (cdr data
> (super-new))
>   [data si]))
> 
> 
> This compiles fine. But calling seq-first or seq-rest on a specific instance 
> like (Seq Integer) fails to type check. Like below:
> 
>> (define s1 (make-seq '(1 2 3 4)))
>> (send s1 first)
> - : Integer
> 1
>> (send s1 rest)
> - : (Seq Integer)
> (object:unsaved-editor:15:27 ...)
>> (seq-first s1)
> . Type Checker: Polymorphic function `seq-first' could not be applied to 
> arguments:
> Argument 1:
>  Expected: (Seq a)
>  Given:(Seq Integer)
> in: (seq-first s1)
>> (seq-rest s1)
> . Type Checker: Polymorphic function `seq-rest' could not be applied to 
> arguments:
> Argument 1:
>  Expected: (Seq a)
>  Given:(Seq Integer)
> in: (seq-rest s1)
>> 
> 
> So, the confusion here is, why a (All (a) (Seq a)) is incompatible with a 
> (Seq Integer)?
> 
> 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.
> 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] Polymorphic functions on Typed Racket classes

2017-07-18 Thread Sourav Datta
Hi!

I am encountering a type checker error for the following program but not sure 
exactly what is wrong with it. The program is as follows:

#lang typed/racket

(define-type (Seq a) (Object [first (-> a)]
[rest (-> (Seq a))]))


(: seq-first (All (a) (-> (Seq a) a)))
(define (seq-first s) (send s first))

(: seq-rest (All (a) (-> (Seq a) (Seq a
(define (seq-rest s) (send s rest))


(: make-seq (-> (Listof Integer) (Seq Integer)))
(define (make-seq si) (new (class object%
 (init-field [data : (Listof Integer) empty])
 (: first (-> Integer))
 (define/public (first)
   (if (empty? data)
   (error "Empty")
   (car data)))
 (: rest (-> (Seq Integer)))
 (define/public (rest)
   (if (empty? data)
   (error "Empty")
   (make-seq (cdr data
 (super-new))
   [data si]))


This compiles fine. But calling seq-first or seq-rest on a specific instance 
like (Seq Integer) fails to type check. Like below:

> (define s1 (make-seq '(1 2 3 4)))
> (send s1 first)
- : Integer
1
> (send s1 rest)
- : (Seq Integer)
(object:unsaved-editor:15:27 ...)
> (seq-first s1)
. Type Checker: Polymorphic function `seq-first' could not be applied to 
arguments:
Argument 1:
  Expected: (Seq a)
  Given:(Seq Integer)
 in: (seq-first s1)
> (seq-rest s1)
. Type Checker: Polymorphic function `seq-rest' could not be applied to 
arguments:
Argument 1:
  Expected: (Seq a)
  Given:(Seq Integer)
 in: (seq-rest s1)
> 

So, the confusion here is, why a (All (a) (Seq a)) is incompatible with a (Seq 
Integer)?

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