Re: [racket-users] inspecting inferred types in typed racket

2018-08-09 Thread Ben Greenman
Typed Racket first runs the macro expander, and then type checks the
expanded program.

If your implementation can type check an expanded program too, then
you can probably get started by copy/pasting typed racket's
#%module-begin and inserting a new pass over the program just after
the optimizer. Here's one place to get started looking for what to
re-use:*
https://github.com/racket/typed-racket/blob/master/typed-racket-lib/typed-racket/core.rkt#L34

If your implementation wants to type check the surface syntax of a
program, then maybe you can hack something together using the above
strategy and the source-syntax library:
http://docs.racket-lang.org/source-syntax/index.html


* I think it'd be nice if typed racket provided an "expand +
type-check" function that other #langs could re-use, but AFAIK it
doesn't yet

-- 
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] inspecting inferred types in typed racket

2018-08-09 Thread Alvin Cheung
Edit: I'm not even sure how to do (1) without (2) given that it requires 
multiple evaluations of the same input. Any pointers would be appreciated.


On 8/9/18 7:02 PM, Alvin Cheung wrote:

Thanks. I am building a language with the same syntax as typed racket,
with the plan to (1) run the input as a typed racket program to type
check, and then (2) run it using my implementation, ideally with the
possibility of querying for the inferred types of the variables and
functions in the input program. Is there an easy way to do this?

Alvin

On 7/16/18 6:14 AM, Sam Tobin-Hochstadt wrote:

Typed Racket doesn't provide a public API for type information, but it
does retain lots of things and if you have something specific you
want, it may be easy to get it.

Sam

On Sat, Jul 14, 2018 at 2:46 PM, Alvin Cheung
 wrote:
Hi, does typed racket retain the inferred typed information? If so is 
there

a way to inspect them programmatically rather than using the REPL?

Thanks,
Alvin

--
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] inspecting inferred types in typed racket

2018-08-09 Thread Ben Greenman
I don't think so, but check `typed-racket/types/type-table`:

https://github.com/racket/typed-racket/blob/master/typed-racket-lib/typed-racket/types/type-table.rkt#L20

-- 
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] inspecting inferred types in typed racket

2018-08-09 Thread Alvin Cheung

Thanks. I am building a language with the same syntax as typed racket,
with the plan to (1) run the input as a typed racket program to type
check, and then (2) run it using my implementation, ideally with the
possibility of querying for the inferred types of the variables and
functions in the input program. Is there an easy way to do this?

Alvin

On 7/16/18 6:14 AM, Sam Tobin-Hochstadt wrote:

Typed Racket doesn't provide a public API for type information, but it
does retain lots of things and if you have something specific you
want, it may be easy to get it.

Sam

On Sat, Jul 14, 2018 at 2:46 PM, Alvin Cheung
 wrote:

Hi, does typed racket retain the inferred typed information? If so is there
a way to inspect them programmatically rather than using the REPL?

Thanks,
Alvin

--
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] bf "module: initial import is not a well-formed module path"

2018-08-09 Thread Shu-Hung You
On Thu, Aug 9, 2018 at 3:42 PM, Zeta Convex  wrote:
>
>
> On Thursday, 9 August 2018 21:34:16 UTC+1, Shu-Hung You wrote:
>>
>> Change the first few lines of lang/reader.rkt to:
>>
>> #lang s-exp syntax/module-reader
>> bf/language
>> #:read my-read
>> #:read-syntax my-read-syntax
>> ;; ...
>>
> Ah yes, that did it! Thanks!
>
>> And just install the entire directory as a package using raco pkg
>> install.
>
>
> I just installed it into my collects directory rather than using raco.
>
> I  typed my stuff in using his tutorial, rather than anything from planet.
>

Just a little clarification: installing the 'bf' directory locally
using the raco command does not involve interacting with the planet
system. All it does is recording the path in the local database and
compile every file in the directory. For example, I have a bunch of
local packages and downloaded packages installed:

$ raco pkg show
Installation-wide:
 Package Checksum  Source
 csv-reading 217c1ee293ee2...  catalog...eading
 custom-load 4e70205c29ab0...  catalog...m-load
 ...
 raco-find-collection00f0d3dbad025...  catalog...ection
 redex   3e069f3c6721e...  clone...th=redex
 rsvgc326fe1567908...  catalog...master
 scribble-abbrevsf207f11814f7e...  catalog...bbrevs
 scribble-math   063604d4a2b38...  catalog...th.git
 slideshow-repl  93246109d2dc4...  catalog...master
 soft-contract link...-contract


>>
>> I'm still getting application error after that, but I'm not sure what
>> went wrong.
>>
>
> Actually, everything is now working fine for me. Thanks for your help.
>
> --
> 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] bf "module: initial import is not a well-formed module path"

2018-08-09 Thread Zeta Convex


On Thursday, 9 August 2018 21:34:16 UTC+1, Shu-Hung You wrote:
>
> Change the first few lines of lang/reader.rkt to: 
>
> #lang s-exp syntax/module-reader 
> *bf/language *
> #:read my-read 
> #:read-syntax my-read-syntax 
> ;; ... 
>
> Ah yes, that did it! Thanks!

And just install the entire directory as a package using raco pkg 
> install. 


I just installed it into my collects directory rather than using raco. 

I  typed my stuff in using his tutorial, rather than anything from planet.


> I'm still getting application error after that, but I'm not sure what 
> went wrong. 
>
>
Actually, everything is now working fine for me. Thanks for your help.

-- 
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] bf "module: initial import is not a well-formed module path"

2018-08-09 Thread Shu-Hung You
Change the first few lines of lang/reader.rkt to:

#lang s-exp syntax/module-reader
bf/language
#:read my-read
#:read-syntax my-read-syntax
;; ...

And just install the entire directory as a package using raco pkg
install. This could take a while. If you want to make it faster, just
skip building the examples by adding (define compile-omit-paths
'("examples")) line to info.rkt before installing it:

$ pwd
/bf

$ git diff info.rkt
diff --git a/info.rkt b/info.rkt
index 5b4c3c1..4d681b9 100644
--- a/info.rkt
+++ b/info.rkt
@@ -10,4 +10,5 @@
 (define blurb
   '("bf: a brainf*ck compiler for Racket.  Includes a tutorial for
building a language in Racket."))
 (define release-notes
-  '((p "Final? release.")))
\ No newline at end of file
+  '((p "Final? release.")))
+(define compile-omit-paths '("examples"))

$ raco pkg install
Linking current directory as a package
raco setup: version: 7.0.0.8
...
raco setup: 2 rendering: /racket-index/scribblings/main/search.scrbl
raco setup: --- installing collections ---
raco setup: --- post-installing collections ---
$

I'm still getting application error after that, but I'm not sure what
went wrong.


On Thu, Aug 9, 2018 at 3:08 PM, Zeta Convex  wrote:
> I'm following the example from "F*dging up a Racket" at
>
> https://www.hashcollision.org/brainfudge/index.html
>
> I set up a project within ~/.racket/6.12/collects:
>
> .
> ├── bf
> │   ├── hello2.rkt
> │   ├── hello.rkt
> │   ├── lang
> │   │   └── reader.rkt
> │   ├── language.rkt
> │   ├── parser.rkt
> │   └── semantics.rkt
>
>
> I don't have a planet account, so I'm jiggling with the code.
>
> Should I be setting up new collections directly under
> ~/.racket/6.12/collects (because that's what I've done)?
>
> I've got the file reader.rkt as follows:
>
> #lang s-exp syntax/module-reader
> (require "../language.rkt")
> #:read my-read
> #:read-syntax my-read-syntax
>
> (require "../parser.rkt")
>
>
> (define (my-read in)
>   (syntax->datum (my-read-syntax #f in)))
>
> (define (my-read-syntax src in)
>   (parse-expr src in))
>
>
> The file hello2.rkt contains:
>
> #lang bf
> ++[><-]>.
>>++[>++<-]>+.
> +++..+++.>[>+++<-]>.
> <+++[><-]>.<+++[>+<-]>.
>>>.+++.--..>>+.
>
> When I try to run this file, I get the error message:
>
> module: initial import is not a well-formed module path in: (require
> "../language.rkt")
> Module Language: invalid language specification in: (require
> "../language.rkt")
>
> If I comment out reader.rkt:(require "../language.rkt") I get the message:
>
> syntax/module-reader: must specify either a module language, or #:language
>
> So I guess I need to specify a module language, but I don't know how to do
> that.
>
>
>
> --
> 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] Re: bf "module: initial import is not a well-formed module path"

2018-08-09 Thread Zeta Convex
OK. I had a partial success. reader.rkt needs to start with something like:

#lang s-exp syntax/module-reader
"language.rkt"
#:read my-read
#:read-syntax my-read-syntax
...

except that I can't run my BF program (hello2.rkt) from an arbitrary 
directory, because it doesn't know where to locate language.rkt.

-- 
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] bf "module: initial import is not a well-formed module path"

2018-08-09 Thread Zeta Convex
 I'm following the example from "F*dging up a Racket" at 

https://www.hashcollision.org/brainfudge/index.html 

I set up a project within ~/.racket/6.12/collects: 

. 
├── bf 
│   ├── hello2.rkt 
│   ├── hello.rkt 
│   ├── lang 
│   │   └── reader.rkt 
│   ├── language.rkt 
│   ├── parser.rkt 
│   └── semantics.rkt 


I don't have a planet account, so I'm jiggling with the code. 

Should I be setting up new collections directly under 
~/.racket/6.12/collects (because that's what I've done)? 

I've got the file reader.rkt as follows: 

#lang s-exp syntax/module-reader 
(require "../language.rkt") 
#:read my-read 
#:read-syntax my-read-syntax 

(require "../parser.rkt") 


(define (my-read in) 
  (syntax->datum (my-read-syntax #f in))) 

(define (my-read-syntax src in) 
  (parse-expr src in)) 


The file hello2.rkt contains: 

#lang bf 
++[><-]>. 
>++[>++<-]>+. 
+++..+++.>[>+++<-]>. 
<+++[><-]>.<+++[>+<-]>. 
>>.+++.--..>>+. 

When I try to run this file, I get the error message: 

module: initial import is not a well-formed module path in: (require 
"../language.rkt") 
Module Language: invalid language specification in: (require 
"../language.rkt") 

If I comment out reader.rkt:(require "../language.rkt") I get the message: 

syntax/module-reader: must specify either a module language, or #:language 

So I guess I need to specify a module language, but I don't know how to do 
that. 



-- 
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] Notifier/subscriber pattern, preventing event cycles: What's the best practice?

2018-08-09 Thread Erich Rast
On Wed, 8 Aug 2018 19:36:10 -0400
David Vanderson  wrote:

> > Is there a better solution to this problem? How do mature
> > notifier/subscriber frameworks deal with these kind of problems?
> >  
> The most straightforward solution I've seen puts the responsibility
> on the view.  When the view gets a 'model-change, set a flag, change
> the GUI, unset the flag.  While the flag is set, the view will not
> send 'view-change events.
> 
> It's worked well for me, but maybe not at the level you're looking
> for.

That's how I did it in the past, too. The disadvantage of this solution
is that it puts the burden of cycle detection on the client of an event
library rather than the library itself. It also seems to be principally
error-prone, because in theory external events (e.g. user interaction)
can occur during the handling of the received event. The problem does
not just occur with model/view patterns, it may occur with any
asynchronous event handling that at some time later may trigger a new
event in response.

I suppose this is a general misfeature of event-based programming and
was wondering whether there is something better available in general.

-- 
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.