Re: [racket-users] racket meet-up in London ?

2020-02-24 Thread James Geddes
That sounds a great idea, I am interested.

For numbers less than about 10, if it helps, I can get a meeting room in the 
Turing Institute (though I’m also happy to try a coffee shop, not that I have 
any good suggestions).

James

 

> On 24 Feb 2020, at 21:41, Stephen De Gabrielle  
> wrote:
> 
> Proposed date: Thursday 9th April 1-2pm,
> - probably at a cafe near St Pancras station. (suggestions appreciated?)
> 
> Please let me know if you are interested, even if you can’t confirm 
> attendance. I’ll take the afternoon out of my holiday leave so I can get 
> there.
> 
> (If the numbers get too big and I need to book a meeting room I think the 
> best I can get is an hour at kingscross.impacthub.net for £5.70 pp)
> 
> It will be casual introductions and chat, though if someone wants to do a 
> short talk or demo that would be most welcome.
> 
> Kind regards,
> 
> Stephen
> 
> 
> On Sun, 23 Feb 2020 at 20:56, Stephen De Gabrielle  
> wrote:
> Is anyone up for another racket meet-up in London ?
> 
> Need to work out a time and place to meet.
> 
> Kind regards
> 
> Stephen
> 
> 
> -- 
> 
> -- 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CAGHj7-Ly6gn-_m5cMHrN%3DeCt_k_m1-f04MBWijrJi7LJsge%2B8A%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/6656AD88-B8A7-4E6D-8BDA-9F02E8F84A50%40gmail.com.


Re: [racket-users] Racket Generic Graph Library: non-numerical edge weight/labels + Graphviz?

2020-02-24 Thread unlimitedscolobb
Thank you very much for your answer Stephen!

I'll be busy the whole day tomorrow, but I'll come back in the evening most 
probably and will continue the discussion on the GitHub issue.

Indeed, I haven't seen the constructors actually check the edges to be 
numerical, but I had the impression that edge-weight had number? as the 
output contract:

  
https://docs.racket-lang.org/graph/index.html#%28def._%28%28lib._graph%2Fmain..rkt%29._edge-weight%29%29

You are right: allowing non-numerical edges should be a matter of replacing 
a couple ='s with equal? and maybe generalising a contract or two.

I'll also give you an example in the discussion on the GitHub issue, in 
about 24 hours.

-
Sergiu


On Monday, February 24, 2020 at 4:54:55 PM UTC+1, Stephen Chang wrote:
>
> > I am somewhat surprised that the graph library enforces numerical edge 
> weights at all. 
>
> The docs do informally say number weights but I don't think the 
> constructors do any checking? Any enforcement should be deferred to 
> individual algorithms. 
>
> Re: graphviz, I took a quick look and I think we could get the 
> behavior you want with a 1-line modification here, changing = to 
> equal? 
>
> https://github.com/stchang/graph/blob/master/graph-lib/graph/graph-fns-graphviz.rkt#L59-L60
>  
>
> Do you have an example I can work with? 
>
> I opened an issue so feel free to reply there instead: 
> https://github.com/stchang/graph/issues/53 
>
> On Sun, Feb 23, 2020 at 8:45 AM unlimitedscolobb 
> > wrote: 
> > 
> > Hello, 
> > 
> > I'm using the wonderful graph library which can do tons of various 
> graph-related tasks.  However, I haven't found a way to attach 
> non-numerical weights/labels to edges _and_ have them appear in the 
> Graphviz rendering of the graph. 
> > 
> > Is it at all possible? 
> > 
> > I did see define-edge-property, but properties defined in this way do 
> not appear in the Graphviz output.  I was looking for ways of passing edge 
> properties to the graphviz function of the library, but there don't seem to 
> be any. 
> > 
> > I am planning to do a pull request enhancing the graphviz function with 
> the possibility to include edge properties, but I wanted to ask around for 
> some solutions which may already exist. 
> > 
> > 
> > - 
> > Sergiu 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "Racket Users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to racket...@googlegroups.com . 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/e4cb44fd-0a21-4e91-a75c-f1442127bfa9%40googlegroups.com.
>  
>
>

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


[racket-users] Re: racket meet-up in London ?

2020-02-24 Thread Stephen De Gabrielle
Proposed date: Thursday 9th April 1-2pm,
- probably at a cafe near St Pancras station. (suggestions appreciated?)

Please let me know if you are interested, even if you can’t confirm
attendance. I’ll take the afternoon out of my holiday leave so I can get
there.

(If the numbers get too big and I need to book a meeting room I think the
best I can get is an hour at kingscross.impacthub.net for £5.70 pp)

It will be casual introductions and chat, though if someone wants to do a
short talk or demo that would be most welcome.

Kind regards,

Stephen


On Sun, 23 Feb 2020 at 20:56, Stephen De Gabrielle 
wrote:

> Is anyone up for another racket meet-up in London ?
>
> Need to work out a time and place to meet.
>
> Kind regards
>
> Stephen
>
>
> --
> 
>
-- 


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


Re: [racket-users] Types for formlets

2020-02-24 Thread Philip McGrath
Hi Marc,

You're right that there will be some challenges in using formlets in Typed
Racket. The easiest approach will probably be to keep defining formlets in
untyped modules and importing them with `require/typed`, perhaps with
helper functions or macros to eliminate some of the boilerplate.
Pragmatically, you aren't even loosing much type safety here: formlets are
processing raw bytes from the outside world, and there is an inherent
possibility for dynamic failure. Using `require/typed` will enforce with
contracts that the values dynamically coming in have the right types and
raise an exception otherwise.

But you asked about how to type formlets. I don't have a worked-out answer,
but I'll try to point you to some of the implementation details that would
be relevant.

To start, in your example:
(define s-formlet
  (formlet (div (label "Enter a string:")
,{=> input-string a-string})
   [a-string : String]))
the `formlet` form is indeed a macro defined here

(and also here
,
sadly basically by copy and paste, because that seemed easier than properly
abstracting over the shared parts when I added the unsafe version).

The `s-formlet` itself, though, is a normal runtime value, as is
`formlet-process`: my guess is that what you were seeing from the macro
stepper was some of the implementation of enforcing the contract on
`formlet-process`.

The `formlet` syntax is built on a functional layer. This is discussed in
the docs , and in
more detail in the paper
 and a technical report
. (You
may be interested to note that the papers present formlets in a version of
OCaml, a statically typed language: the challenge for Typed Racket, as
usual, isn't the types but the typed–untyped interaction.) Formally, a
formlet value is an "applicative functor" or "idiom."

Concretely, a formlet is represented as a function. In Typed Racket syntax,
we might try to write:
(define-type (Formlet A)
  (-> Natural (Values (Listof Xexpr) (-> (Listof Binding) A) Natural)))
(: s-formlet (Formlet String))
That type looks pretty strange! Here's what's going on. The formlet is
called with a numeric counter, which is used to generate field ids. Its
three results are some HTML to display, a function
to process the bindings from the request, and the new value for the
counter. (There is an unchecked invariant that the new counter value should
not be less than the old value.) The `formlet` syntax expands to uses of
the combinators `pure`, `cross`, and `cross*` to assemble compound formlets
from smaller pieces. This functional interface can also be used directly.

That may be enough to illustrate some of the problems. Typed Racket can
have trouble generating contract for polymorphic functions like `(:
formlet-process (∀ (A) (-> (Formlet A) Request A)))`. Furthermore, the
`Formlet` type I wrote is a simplification: formlets are actually allowed
to produce multiple values from the processing function, which again is a
problem for typing. (I think it would be reasonable to eliminate that
feature from a Typed Racket interface: I don't think it is used often,
especially since `formlet/c` was broken for a while
 for the
multiple-return-values case.) Because of the way `cross` is implemented,
there is a great deal of function composition, which could mean many, many
crossings of the typed–untyped boundary with contract enforcement costs.

An approach I might consider would be re-implementing the core
combinators—essentially this module
—in
Typed Racket and writing a typed version of the `formlet` macro that
expands to them. You could still use the library formlets by importing them
with `require/typed` at some concrete type.

I'm happy to talk more if you're interested.

-Philip

On Mon, Feb 24, 2020 at 10:28 AM Marc Kaufmann 
wrote:

> Hi all,
>
> I wonder what the best way is to integrate formlets into typed programs. I
> simply `require/typed` formlet-display  as type (-> Any Any), which is not
> illuminating, but the display part is rarely the problem.
>
> formlet-process is tricky. The earliest point at which I 'know' the type
> of processing a given formlet is directly when formlet-process is called,
> so that's the best time to start typing to get most of the types checked.
> Ideally I would do something like:
>
> (define s-formlet
>   (formlet (div (label "Enter a string:")
> ,{=> input-string a-string})
>[a-string : String]))
>
> and be done with it. Of course I cannot type it this 

Re: [racket-users] Racket Generic Graph Library: non-numerical edge weight/labels + Graphviz?

2020-02-24 Thread Stephen Chang
> I am somewhat surprised that the graph library enforces numerical edge 
> weights at all.

The docs do informally say number weights but I don't think the
constructors do any checking? Any enforcement should be deferred to
individual algorithms.

Re: graphviz, I took a quick look and I think we could get the
behavior you want with a 1-line modification here, changing = to
equal?
https://github.com/stchang/graph/blob/master/graph-lib/graph/graph-fns-graphviz.rkt#L59-L60

Do you have an example I can work with?

I opened an issue so feel free to reply there instead:
https://github.com/stchang/graph/issues/53

On Sun, Feb 23, 2020 at 8:45 AM unlimitedscolobb
 wrote:
>
> Hello,
>
> I'm using the wonderful graph library which can do tons of various 
> graph-related tasks.  However, I haven't found a way to attach non-numerical 
> weights/labels to edges _and_ have them appear in the Graphviz rendering of 
> the graph.
>
> Is it at all possible?
>
> I did see define-edge-property, but properties defined in this way do not 
> appear in the Graphviz output.  I was looking for ways of passing edge 
> properties to the graphviz function of the library, but there don't seem to 
> be any.
>
> I am planning to do a pull request enhancing the graphviz function with the 
> possibility to include edge properties, but I wanted to ask around for some 
> solutions which may already exist.
>
>
> -
> Sergiu
>
> --
> 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/e4cb44fd-0a21-4e91-a75c-f1442127bfa9%40googlegroups.com.

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


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

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

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

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

https://pkgs.racket-lang.org/package/extensible-functions

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


[racket-users] Types for formlets

2020-02-24 Thread Marc Kaufmann
Hi all,

I wonder what the best way is to integrate formlets into typed programs. I 
simply `require/typed` formlet-display  as type (-> Any Any), which is not 
illuminating, but the display part is rarely the problem.

formlet-process is tricky. The earliest point at which I 'know' the type of 
processing a given formlet is directly when formlet-process is called, so 
that's the best time to start typing to get most of the types checked. 
Ideally I would do something like:

(define s-formlet 
  (formlet (div (label "Enter a string:")
,{=> input-string a-string})
   [a-string : String]))

and be done with it. Of course I cannot type it this way. One solution is 
to define

(define (s-formlet-process a-formlet a-request)
  (formlet-process a-formlet a-request))

provide it, and then require it with the correct type in the next file. 
That's sort of what I am doing right now, but it requires quite a bit of 
boiler-plate everywhere. The problem is that I don't see how I would even 
start typing s-formlet itself, since (I think) it is a macro that changes 
how formlet-process deals with it, so I don't even know where to start 
typing any of it. When I expand formlet-process in the macro stepper, it 
turns into the application of some idY11 with something lifted (none of 
which I understand), and I don't see how I would make the type of 
(formlet-process a-formlet ...) dependent on which formlet it is that I am 
processing. 

One idea I had is to define my-formlet-process which takes the name as a 
symbol, rather than as an id, and uses different type signatures depending 
on the symbol, using case->:

#lang racket

;; UNTYPED
(define (my-formlet-process name req)
  (cond [(eq? name 'integer-formlet) (formlet-process integer-formlet req)]
[(eq? name 'string-formlet) (formlet-process string-formlet 
req)]
...

and then require/typed this via (case-> (-> 'integer-formlet Integer) (-> 
'string-formlet String)). This cuts down on having to define all the 
intermediaries, and puts all the types for formlets in one place. It still 
feels more tedious than it has to be, but it is probably not trivial to 
make this much easier.

Any thoughts on if the above is an OK if not best practice, or ideas for 
improvements? I guess using types with some rather sophisticated macros may 
in general be a little tricky - any pointers to other places on how to do 
this and how to figure out how to type it are appreciated.

Cheers,
Marc

-- 
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/6241af3c-4b2d-43a5-a76a-2a14b02bc153%40googlegroups.com.


[racket-users] Re: quick racket editor survey

2020-02-24 Thread Stephen De Gabrielle
at 18 responses
[image: Three-set Venn diagram (at 18 responses).png]
I think this is fascinating.

(I'm filled with fear and admiration for the lone racketeer in the middle)

S.




On Mon, Feb 24, 2020 at 1:31 PM Stephen De Gabrielle <
spdegabrie...@gmail.com> wrote:

> If anyone is interested you can view the responses here:
> https://www.surveymonkey.com/results/SM-GBD6J7ST7/
>
> s.
>

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


[racket-users] Re: quick racket editor survey

2020-02-24 Thread Stephen De Gabrielle
If anyone is interested you can view the responses here:
https://www.surveymonkey.com/results/SM-GBD6J7ST7/

s.

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


[racket-users] quick racket editor survey

2020-02-24 Thread Stephen De Gabrielle
Hi,

quick racket editor survey: https://www.surveymonkey.co.uk/r/H23ZTDW


I'm not part of the racket team but I am working on a community survey. I'm
hoping the results of this will inform part of that.

No personal data collected, but SurveyMonkey logs IP addresses.

Only one multi-answer question, the same question was asked on racket.slack
s
how do you edit Racket code?

   - [image: :blue_heart:] DrRacket
   - [image: :green_heart:] Emacs Racket Mode
   - [image: :yellow_heart:] Visual Studio Code
   - [image: :orange_heart:] Vim
   - [image: :purple_heart:] text editor (notepad++, sublime text)
   - [image: :black_heart:] Visual Studio/Xcode/InteliJ/Eclipse
   - [image: :basketball:] Other ?

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


Re: [racket-users] how to adapt BC code for Racket CS?

2020-02-24 Thread Hendrik Boom
On Sun, Feb 23, 2020 at 05:58:30AM -0700, Matthew Flatt wrote:

> 
> Converting loops into closed form requires more sophisticated and
> general induction reasoning than is typical in a compiler. Or it needs
> ad hoc pattern patching to cover a few cases --- which I have seen gcc
> do, but I don't think that's very common.
> 

If interest here, though not really converting loops into closed form:

A language I saw proposed in the 70's has a loop construct where the 
request to start a new interaation was done by an 'again' statement.

loop i := 3 
...
...
if ...
then
   ...
   ...
   again i+1
endif
endloop

Of course the again could occur in positions where it was a genuine 
recursive call.  In most situation, though, it would be recognised as a 
tail-recursion and be treated like a normal iteration.

And yes, there could be more than one loop variable, which would 
tranlate into more than one function parameter.

In a syntactic situation like this, it would be easier to eliminate a 
loop variable that was not used, because all the calls to the loop body 
would be explicitly present within the syntax.

-- hendrik

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


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

2020-02-24 Thread Marc Kaufmann
Very nice, adding 

(: get-user-var (case-> ...))

indeed does the trick. So I can use `case->` to do overloading (if that's 
what it is called), by defining different functions for different type 
signatures, and then put them together into a single function via a cond. 
E.g.:

(: int-add (-> Integer Integer Integer))
(define (int-add x y)
  (+ x y))

(: string-add (-> String String String))
(define (string-add x y)
  (string-append x y))

(: int-string-add (case-> 
(-> Integer Integer Integer)
(-> String String String)))
(define (int-string-add x y)
  (cond [(integer? x) (int-add x y)]
[(string? x) (string-add x y)]
[else
  (error "Not a string or int" x)]))

I am wondering if there is a way to avoid the final definition of 
`int-string-add`, by simply defining the same function twice (or more) with 
different type signatures, and then when I call the function, which code 
gets called depends on the type signature? I would be surprised if this 
existed in Typed Racket right now, but it would be neat and good to know if 
there is a more idiomatic/built-in way than what I do above, ie just write:

(: special-add (-> Integer Integer Integer))
(define-special (special-add x y)
  (+ x y))

(: special-add (-> String String String))
(define-special (special-add x y)
  (string-append x y))

I guess it would be pretty hard, since the type signature has to be coupled 
more tightly to a specific function than TR requires right now, i.e. I'd 
have to write (define-special (special-add [x : String] [y : String]) to 
make the link explicit. Anyway, if it's not possible right now, totally 
fine.
   
Regarding refinement types for symbols, I have no idea how useful it would 
be, as the only example I came up with was the above one, which I think is 
better dealt with in a different way.

Cheers,
Marc

On Sunday, February 23, 2020 at 6:33:33 PM UTC+1, Ben Greenman wrote:
>
> Try this case-> type instead: 
>
>   (case-> 
> (-> Integer 'name Symbol) 
> (-> Integer 'age Integer) 
> (-> Integer Symbol (U Symbol Integer))) 
>
>
> I don't know what it would take to add refinements for symbols, but 
> that might be useful. Andrew Kent's dissertation may have some 
> pointers: 
>
> https://pnwamk.github.io/docs/dissertation.pdf 
>

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