Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force, rentrent promise promise/e (or, pam/e is too strict) #4

Open
LeifAndersen opened this issue Mar 2, 2016 · 7 comments
Open

Comments

@LeifAndersen
Copy link
Member

I have the following program:

#lang racket

(require data/enumerate
         data/enumerate/lib)

(pam/e (λ (x) x)
       (letrec ([expr/e (delay/e
                         (or/e
                          natural/e
                          (pam/e (λ (x) x)
                                 expr/e
                                 #:contract any/c)))])
         expr/e)
       #:contract any/c)

And when I run it, I get:

. . racket/racket/collects/racket/private/promise.rkt:104:10: force: reentrant promise `promise/e'

I suspect the problem is related to the inner pam/e, because when I turn the inner expression:

(pam/e (λ (x) x)
    expr/e
    #:contract any/c)))])

Into: expr/e the program runs normally.

@LeifAndersen
Copy link
Member Author

For now I found data/enumerate/unsafe, and my program seems to work fine in it.

@jeapostrophe
Copy link
Contributor

A smaller program breaks too:

#lang racket/base
(require pict/tree-layout
         data/enumerate
         data/enumerate/lib)

(define bt/e
  (delay/e
   (or/e (single/e #f)
         (pam/e (λ (x) (tree-layout (car x) (cdr x)))
                (cons/e bt/e bt/e)
                #:contract tree-layout?))))

(from-nat bt/e 0)

On Wed, Mar 2, 2016 at 2:00 PM, Leif Andersen [email protected]
wrote:

For now I found data/enumerate/unsafe, and my program seems to work fine
in it.


Reply to this email directly or view it on GitHub
#4 (comment).

Jay McCarthy
Associate Professor
PLT @ CS @ UMass Lowell
http://jeapostrophe.github.io

       "Wherefore, be not weary in well-doing,
  for ye are laying the foundation of a great work.

And out of small things proceedeth that which is great."
- D&C 64:33

@rfindler
Copy link
Member

rfindler commented Mar 9, 2016

I just got back to looking into this and I'm not seeing the error anymore, although I think I did see if when Leif first posted this.

Maybe one of the compiler optimization fixes fixed it?

@jeapostrophe
Copy link
Contributor

I'm on commit 509da64135f412acd8522747daa3568524ac59ae and I have the error.

On Wed, Mar 9, 2016 at 6:06 PM, Robby Findler [email protected]
wrote:

I just got back to looking into this and I'm not seeing the error anymore,
although I think I did see if when Leif first posted this.

Maybe one of the compiler optimization fixes fixed it?


Reply to this email directly or view it on GitHub
#4 (comment).

Jay McCarthy
Associate Professor
PLT @ CS @ UMass Lowell
http://jeapostrophe.github.io

       "Wherefore, be not weary in well-doing,
  for ye are laying the foundation of a great work.

And out of small things proceedeth that which is great."
- D&C 64:33

@rfindler
Copy link
Member

I'm two days ahead of you, but I don't really see any obvious commits that
would fix it. Nevertheless, I get the expected error for both of these
programs, namely:

delay/e-expression: broke its own contract

promised: two-way-enum?

produced: #<infinite-one-way-enum...>

in: an and/c case of

  (and/c

   infinite-enum?

   two-way-enum?

   flat-enum?)

contract from: /Users/robby/tmp.rkt

blaming: /Users/robby/tmp.rkt

(assuming the contract is correct)

at: /Users/robby/tmp.rkt:7.0

context...:

/Users/robby/git/exp/plt/racket/collects/racket/contract/private/blame.rkt:156:0:
raise-blame-error16

/Users/robby/git/exp/plt/racket/collects/racket/private/promise.rkt:104:10

/Users/robby/git/exp/plt/racket/collects/racket/private/more-scheme.rkt:265:2:
call-with-exception-handler

/Users/robby/git/exp/plt/racket/collects/racket/private/promise.rkt:96:0:
force/generic

/Users/robby/git/exp/plt/extra-pkgs/data/data-enumerate-lib/data/enumerate/private/core.rkt:1076:9

/Users/robby/tmp.rkt: [running body]

@jeapostrophe
Copy link
Contributor

I get

force: reentrant promise `promise/e'
  context...:
   /Users/jay/Dev/scm/plt/racket/collects/racket/private/promise.rkt:96:0:
force/generic
   ...private/base.rkt:107:23

 /Users/jay/Dev/scm/plt/racket/collects/racket/contract/private/base.rkt:159:5

 /Users/jay/Dev/scm/plt/racket/collects/racket/contract/private/list.rkt:339:2

 /Users/jay/Dev/scm/plt/racket/collects/racket/contract/private/arrow-higher-order.rkt:454:2

 /Users/jay/Dev/scm/plt/racket/collects/racket/contract/private/arr-i.rkt:1094:2:
un-dep/maybe-chaperone
   ...rivate/arr-i.rkt:914:19
   /Users/jay/Dev/scm/plt/racket/collects/racket/private/kw.rkt:1585:36
   ...private/more.rkt:576:56

 /Users/jay/Dev/scm/plt/extra-pkgs/data-enumerate-lib/data-enumerate-lib/data/enumerate/private/more.rkt:601:13:
temp203
   /Users/jay/Dev/scm/plt/racket/collects/racket/private/promise.rkt:96:0:
force/generic

 /Users/jay/Dev/scm/plt/extra-pkgs/data-enumerate-lib/data-enumerate-lib/data/enumerate/private/core.rkt:1074:9
   /tmp/t.rkt: [running body]

 /Users/jay/Dev/scm/plt/extra-pkgs/compiler-lib/compiler-lib/compiler/commands/test.rkt:176:16
t.rkt: raco test: test raised an exception

Compilation exited abnormally with code 1 at Wed Mar  9 19:04:46

If you expect these programs to both error, how do you think we should
write down recursive one-way enumerations?

Jay

On Wed, Mar 9, 2016 at 7:01 PM, Robby Findler [email protected]
wrote:

I'm two days ahead of you, but I don't really see any obvious commits that
would fix it. Nevertheless, I get the expected error for both of these
programs, namely:

delay/e-expression: broke its own contract

promised: two-way-enum?

produced: #<infinite-one-way-enum...>

in: an and/c case of

(and/c

infinite-enum?

two-way-enum?

flat-enum?)

contract from: /Users/robby/tmp.rkt

blaming: /Users/robby/tmp.rkt

(assuming the contract is correct)

at: /Users/robby/tmp.rkt:7.0

context...:

/Users/robby/git/exp/plt/racket/collects/racket/contract/private/blame.rkt:156:0:
raise-blame-error16

/Users/robby/git/exp/plt/racket/collects/racket/private/promise.rkt:104:10

/Users/robby/git/exp/plt/racket/collects/racket/private/more-scheme.rkt:265:2:
call-with-exception-handler

/Users/robby/git/exp/plt/racket/collects/racket/private/promise.rkt:96:0:
force/generic

/Users/robby/git/exp/plt/extra-pkgs/data/data-enumerate-lib/data/enumerate/private/core.rkt:1076:9

/Users/robby/tmp.rkt: [running body]


Reply to this email directly or view it on GitHub
#4 (comment).

Jay McCarthy
Associate Professor
PLT @ CS @ UMass Lowell
http://jeapostrophe.github.io

       "Wherefore, be not weary in well-doing,
  for ye are laying the foundation of a great work.

And out of small things proceedeth that which is great."
- D&C 64:33

@rfindler
Copy link
Member

I still don't see why the error went away for me, but the obvious thing to guess is that something happened in the two days of git commits. And yes, I did indeed see that error before.

Meanwhile, here's the program I think that you wanted?

#lang racket/base
(require pict/tree-layout
data/enumerate
data/enumerate/lib)

(define bt/e
(delay/e
 (or/e (single/e #f)
       (pam/e (λ (x) (tree-layout (car x) (cdr x)))
              (cons/e bt/e bt/e)
              #:contract tree-layout?))
 #:two-way-enum? #f))

(for/list ([i (in-range 1 10)])
  (binary-tidier (from-nat bt/e i)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants