Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-11 Thread Robby Findler
On Sat, Nov 11, 2017 at 12:14 PM, Alexis King  wrote:
>> On Nov 11, 2017, at 08:17, Robby Findler 
>> wrote:
>>
>> One example that lives on (in a zombie-like state) is the "search in
>> files" functionality
>
> Sort of off-topic, but I use the Search in Files option all the time,
> so don’t think nobody’s finding it useful!

Yay! :)


Robby

-- 
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] unexpected behavior of parametric polymorphism in Typed Racket

2017-11-11 Thread Matthias Felleisen

Couldn’t Richard solve his second problem with the supply of a single type 
parameter to both new and alloc: 

#lang typed/racket

(define-type Addr Natural)
(define-type (Store α) (Listof α))

(: make-store (All (α) (-> (Values [-> (Store α)] [(Store α) α -> (Values 
(Store α) Addr)]
(define (make-store)
  (values (lambda () '())
  (lambda ({σ : (Store α)} {val : α})
(define addr (length σ))
(values (cons val σ) addr

(define-values (new alloc) [(inst make-store String)])

;; -

(let*-values ([(s) (new)]
  [(s a1) (alloc s "hello")]
  [(s a2) (alloc s 42)] ;; comment this out and it type checks 
  )
  s)

> (Context: I only actually intend to use `store' with a single type, but I
> want to define that type in a separate module.  Since the type's definition
> refers to `addr', I made `store' polymorphic to break the cyclical
> dependency.)

This of course calls for Typed Units, which are now available in Typed Racket 
thanks to Daniel Feltey. 

It might be worth trying it out — Matthias







> On Nov 10, 2017, at 12:10 PM, Sam Tobin-Hochstadt  
> wrote:
> 
> Your intuitions about both questions are right here.
> 
> First, type variables are only introduced into scope automatically in
> the function body for function definitions. You can use `#:forall`
> with `define` to use polymorphic types inline, but that does not allow
> you to define a polymorphic store value.
> 
> Second, you're right that subtyping allows `store` to be covariant,
> meaning that anyone can put additional kinds of things in a store. You
> can change this so that store is invariant by making the allowed
> hashtables possible mutable, changing that field to `(HashTable addr
> \alpha)`. Then your last example won't type check. However, that will
> mean you need to pick an initial store type, instead of having it
> inferred, and it will mean that a `(store Integer)` is not usable when
> you need a `(store Number)`.
> 
> Sam
> 
> On Fri, Nov 10, 2017 at 11:10 AM, Richard Cobbe  wrote:
>> I'm getting surprising results trying to define an abstract polymorphic
>> type in Typed Racket.  Could someone shed some light on this?
>> 
>> Consider the following definitions:
>> 
>>(struct addr ([ptr : Natural]))
>>(struct (α) store ([next-addr : addr]
>>   [table : (Immutable-HashTable addr α)]))
>> 
>>(: empty-store (All (α) (-> (store α
>>(define (empty-store)
>>  (store (addr 0) (make-immutable-hash null)))
>> 
>>(: alloc (All (α) (store α) α -> (Values (store α) addr)))
>>(define (alloc st v)
>>  (let ([a (store-next-addr st)])
>>(values (store (inc-addr a) (hash-set (store-table st) a v))
>>a)))
>> 
>>;; definitions of inc-addr & other store operations elided for brevity
>> 
>> I have two questions at this point, a big one and a small one.
>> 
>> Small question: it'd be nice to define empty-store to have type
>> (All (α) (store α)) -- i.e., without the eta expansion -- but I can't
>> figure out how to do this.  In particular, the following doesn't work:
>> 
>>(: empty-store (All (α) (store α)))
>>(define empty-store
>>  (store (addr 0) ((inst make-immutable-hash addr α) null)))
>> 
>> I get an error that "type name `α' is unbound", referring to the use of α
>> in the use of `inst'.  This surprises me, because section 4.8.3 (Lexically
>> Scoped Type Variables) of the Typed Racket Guide seems to say that α should
>> be in scope here.  Does that only work for function definitions?
>> 
>> Is there another way to do this without the thunk?
>> 
>> * * * * *
>> 
>> Big question: with the original version of empty-store, I get some very
>> surprising behavior.  Consider the following uses:
>> 
>>(: s (store String))
>>(define s ((inst empty-store String)))
>> 
>>(define-values (s1 addr) (alloc s 3))
>> 
>> This type-checks -- even the application of `alloc' in the last line.
>> What's going on here?  In my understanding of parametric polymorphism, this
>> can't be well-typed: α cannot be both String and Positive-Byte in the same
>> type application.  Did I overlook something in the Typed Racket manuals
>> that explains this?
>> 
>> After the final definition, `s1' has type (store (U Positive-Byte String)).
>> This does look sound to me, in that the values in the store are indeed
>> either Positive-Bytes or Strings.  But this makes it difficult to use the
>> type system to prevent clients from adding non-strings to the store.  Is it
>> possible to express that restriction in Typed Racket?
>> 
>> (Context: I only actually intend to use `store' with a single type, but I
>> want to define that type in a separate module.  Since the type's definition
>> refers to `addr', I made `store' polymorphic to break the cyclical
>> 

Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-11 Thread Alexis King
> On Nov 11, 2017, at 08:17, Robby Findler 
> wrote:
> 
> One example that lives on (in a zombie-like state) is the "search in
> files" functionality

Sort of off-topic, but I use the Search in Files option all the time,
so don’t think nobody’s finding it useful!

(Also, I virtually always launch DrRacket using the drracket launcher
executable that `raco setup` produces, but I don’t know that I have an
especially good reason for doing that. I imagine I started doing it at
one point for a reason, but I have since forgotten about what that
reason was.)

-- 
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] where does DrRacket get its environment variables on OS X?

2017-11-11 Thread Matthew Butterick
On Nov 11, 2017, at 10:07 AM, Matthew Butterick  wrote:
> 
>> On Nov 11, 2017, at 8:17 AM, Robby Findler > > wrote:
>> 
>> There is definitely a tension here, but my experience
>> suggests that it would  not be a good use of my time to do something
>> like that. At least, not without a clear pain point in my own mind.
>> Since you see to have one of those, however, maybe you should give
>> something a try?
> 
> Sure. I wasn't intending to frame this as "here's something new for Robby to 
> do" ;)

(PS But I don't use environment variables enough to impose my dumb-person's 
solution on the world, so I am content with the status quo)

-- 
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] where does DrRacket get its environment variables on OS X?

2017-11-11 Thread Matthew Butterick

> On Nov 11, 2017, at 8:17 AM, Robby Findler  
> wrote:
> 
> There is definitely a tension here, but my experience
> suggests that it would  not be a good use of my time to do something
> like that. At least, not without a clear pain point in my own mind.
> Since you see to have one of those, however, maybe you should give
> something a try?

Sure. I wasn't intending to frame this as "here's something new for Robby to 
do" ;)

-- 
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] where does DrRacket get its environment variables on OS X?

2017-11-11 Thread Robby Findler
FWIW, I have spent (far too much) time trying to replicate
functionality in DrRacket that is best just used in the underlying OS
or its tools somehow. One example that lives on (in a zombie-like
state) is the "search in files" functionality and there are others
that just died. There is definitely a tension here, but my experience
suggests that it would  not be a good use of my time to do something
like that. At least, not without a clear pain point in my own mind.
Since you see to have one of those, however, maybe you should give
something a try? As Matthew pointed out, there is already command-line
support (that I think doesn't get used much because it isn't very
convenient to use) that you could use a starting point for wiring
things in.

Robby


On Thu, Nov 9, 2017 at 11:29 AM, Matthew Butterick  wrote:
> I see your point. But this technique forfeits any broader compatibility with
> desktop-oriented tools (e.g., file launchers and whatnot)
>
> I did try making an Automator application containing a shell script that
> simply launches DrRacket, and also tried `bash -c ···` (to try to force it
> to launch from inside a login session). But these didn't change the result.
>
> Anyhow, add it to the giant pile of things in the world that are more
> complex than I thought.
>
>
> On Nov 8, 2017, at 8:07 PM, John Clements  wrote:
>
> On Nov 8, 2017, at 12:42, Robby Findler  wrote:
>
> How about "env X=Y racket -l- drracket file-to-open-in-drracket.rkt” ?
>
>
> +1
>
>
> --
> 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.