Skip to content

Conversation

@sirlensalot
Copy link
Contributor

@sirlensalot sirlensalot commented Apr 1, 2019

Fixes #442

Caveats:

  • Types must be specified somewhere in order to typecheck. I briefly investigated being able to specialize object literals on the fly a la { 'foo: 1 }:object{bar} (which would be ugly anyway) but Compile didn't like it. The example in the test shows the upshot:

    (defpact tc-yield-resume-1 (foo bar x:integer)

  • Return types on defpacts are weird/pathological. They associate to the return value of the last step, which itself is associated to the step app (ie, ignoring the rollback). Thus in the example we have steps returning different types.

  • Resume/yield in rollback is currently permitted, as the environment simply gathers yield/resume invocations within a step and associates them (respectively).

NB: Defun{} Funs now indicates def type, which was ignored before; resume/yield nodes are stored in Step{} ASTs.

Copy link
Contributor

@joelburget joelburget left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks pretty good. I just had the one question about whether something should be an error. I also have an additional note / question: It should be possible to reject a step like:

(step
  (if flag
    (yield { 'a : 1 })
    "no yield"))

Based on my reading of the code, we don't currently reject this. Should we?

debug $ "assocYRSchemas: " ++ show (a,a',b,b')
assocParams (_aId a) a' b'

assocStepYieldReturns _ _ = return ()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, as this is applied to any top level -- we only want this for matching on defpact

let specialBind = do
args'' <- notEmpty _appInfo "Expected >1 arg" (init args')
mkApp (set fSpecial (Just (sf,SBinding (last args'))) fun') args''
initArgs <- init <$> notEmpty _appInfo "Invalid binding invocation" args'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is my understanding correct that previously all bindings required at least one argument (plus the binding), but now we have resume, which takes no arguments (plus a binding)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Seems to do no harm as the other binding funs have differing arity anyways (e.g., with-default-read)

@sirlensalot
Copy link
Contributor Author

Sigh ... flaky web test in gitlab

@sirlensalot
Copy link
Contributor Author

@joelburget not sure how the typechecker will reject your example or other pathologies like noted in the PR description. The solution so far simply gathers yields and resumes, enforces they respectively associate within a step, and then performs rules across steps. This is already considerably more introspective than other typechecking tasks -- the step rules are tractable mainly because they can all be inspected at a single level (ie the defpact body).

One thing I can say about your example is if would at least fail to typecheck ...

Copy link
Contributor

@joelburget joelburget left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm -- thanks for figuring this out

@sirlensalot sirlensalot merged commit 9724459 into master Apr 2, 2019
@sirlensalot sirlensalot deleted the feat/tc-yield-resume branch April 2, 2019 14:42
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

Successfully merging this pull request may close these issues.

None yet

3 participants