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

shouldn't posn be non parametric? #1

Closed
AlexKnauth opened this Issue Jan 27, 2015 · 4 comments

Comments

Projects
None yet
2 participants
@AlexKnauth
Copy link
Contributor

commented Jan 27, 2015

since you can't define it properly as a parametric type, shouldn't you just use

(require/typed/provide
 lang/posn
 [#:opaque Posn posn?]
 [make-posn [Real Real -> Posn]]
 [posn-x [Posn -> Real]]
 [posn-y [Posn -> Real]])

By the way with the parametric type I get errors like this:

> (define p ((inst make-posn Byte) 1 2))
> p
- : htdp:posn
(posn #<A7> #<A7>) ; um, what?
> (posn-x p)
. . posn-x: broke its contract
  promised: A10
  produced: #<A7>
  in: the range of
      (parametric->/c
       (A10)
       (->* (g12) () (values A10)))
  contract from: (interface for posn-x)
  blaming: (interface for posn-x)
   (assuming the contract is correct)
  at: <pkgs>/2htdp-typed/typed/lang/posn.rkt:15.2

And anyway if you can figure out how to make it parametric properly, shouldn't it be parametric over 2 type variables instead of 1?

@AlexKnauth AlexKnauth changed the title shouldn't posn be not parametric? shouldn't posn be non parametric? Jan 27, 2015

@lexi-lambda

This comment has been minimized.

Copy link
Owner

commented Jan 27, 2015

Hmm, this is interesting, I didn't realize how broken this is. I'll take a look when I get around to it, but @samth, could you explain why this typechecks but doesn't work at all? Where are those strange contract errors coming from? Why #<A7>?

@AlexKnauth

This comment has been minimized.

Copy link
Contributor Author

commented Jan 29, 2015

In case it helps, here's a simpler program that fails in the same way:

#lang typed/racket
(require/typed racket/function [identity (All (X) X -> Number)])
(identity 1)

It gives this error message:

. . identity: broke its contract
  promised: Number
  produced: #<X3>
  in: the range of
      (parametric->/c
       (X3)
       (->* (X3) () (values g5)))
  contract from: (interface for identity)
  blaming: (interface for identity)
   (assuming the contract is correct)
  at: /Users/Alex/Documents/DrRacket/untitled-folder/typed.rkt:2.32
@lexi-lambda

This comment has been minimized.

Copy link
Owner

commented Feb 28, 2015

Removed. I may revisit this later if I can come up with a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.