Closed mfelleisen closed 9 years ago
--Apple-Mail-2--585267247
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed
Attached is a screen shot to clarify the high-lighting and error
reporting that I am complaining about.
--Apple-Mail-2--585267247
Content-Transfer-Encoding: base64
Content-Type: image/png;
x-unix-mode=0644;
name=Picture 1.png
Content-Disposition: inline;
filename="Picture 1.png"
I can't explain the highlighting behavior - I expect that's something
strange somewhere else.
However, the reason you're getting the other behavior you are seeing is this:
The function f has the type (case-lambda (Integer -> Integer) (Boolean
Integer -> Integer)). That type is a subtype of *both* (Integer ->
Integer) and (Boolean Integer -> Integer), so the definition
typechecks.
But when you try to apply the function, you have to satisfy *all* of
the elements of a union typed function in order to be able to apply
it. The first element typechecks fine, but the second one has two
errors - the first argument is the wrong type, and there aren't enough
arguments. So both of those errors are reported.
Does that make sense?
sam th
On Fri, Aug 8, 2008 at 7:56 PM, matthias@ccs.neu.edu wrote:
A new problem report is waiting at http://bugs.plt-scheme.org/query/?cmd=view&pr=9672 Reported by matthias for release: 4.0.2.6-svn4aug2008 * Description: put the program in a window don't save evaluate (f 10) at the prompt in the repl this high-lights "ng Pic" in the third line and reports three errors, none of them explainig what went wrong * How to repeat: (define-struct: lw ([e : (U (Listof lw) Symbol String Pict)] [line : Integer] [line-span : Integer] [column : Integer] [column-span : Integer] [unq? : Boolean] [metafunction-name :(U #f Symbol)])) ;; the U shold be a case-lambda (case-lambda: [((i : Integer)) i] [((b : Boolean) (i : Integer)) i])) *\ Environment: macosx "Darwin europe.local 8.11.1 Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28 PDT 2007; root:xnu-792.25.20~1/RELEASE_I386 i386 i386" (i386-macosx/3m) (get-display-depth) = 32 Human Language: english (current-memory-use) 158718820 Collections: (("/Users/matthias/Unison/collects/" ".DS_Store" "date" "finance" "info-domain" "info.ss" "short" "testing" "tll-collects" "utils" "web") ("/Users/matthias/Library/PLT Scheme/4.0.2.6/collects" non-existent-path) ("/Users/matthias/plt/collects" ".DS_Store" ".svn" "afm" "algol60" "big" "browser" "combinator-parser" "compiler" "config" "defaults" "doc" "drscheme" "dynext" "embedded-gui" "eopl" "errortrace" "ffi" "file" "framework" "frtime" "games" "graphics" "gui-debugger" "guibuilder" "handin-client" "handin-server" "help" "hierlist" "honu" "honu-module" "htdch" "htdp" "html" "icons" "info-domain" "lang" "launcher" "lazy" "little-helper" "macro-debugger" "make" "mred" "mrflow" "mrlib" "mysterx" "mzcom" "mzlib" "mzscheme" "mztake" "net" "openssl" "parser-tools" "planet" "plot" "preprocessor" "profj" "profjBoxes" "profjWizard" "r5rs" "r6rs" "readline" "redex" "repos-time-stamp" "rnrs" "s-exp" "scheme" "scribble" "scribblings" "setup" "sgl" "sirmail" "skipper" "slatex" "slibinit"! "slideshow" "srfi" "srpersist" "stepper" "string-constants" "swindle" "syntax" "syntax-color" "teachpack" "test-box-recovery" "test-engine" "test-suite" "tests" "tex2page" "texpict" "trace" "typed-scheme" "version" "waterworld" "web-server" "wxme" "xml")) Computer Language: (("Module") (#(#t write mixed-fraction-e #f #t debug) (default) #() "#lang scheme\n"))
That's not at all what
(case-lambda (-> int int) (-> int bool bool))
should mean. Case-lambdas dispatch based on the arity at the application site.
Philippe spent a long time looking into the various options for
case-lambda in the context of mrflow; you might want to look at his
stuff to see where he ended up.
On Fri, Aug 8, 2008 at 7:33 PM, Sam TH samth@plt-scheme.org wrote:
A new problem report is waiting at http://bugs.plt-scheme.org/query/?cmd=view&pr=9672 Reported by matthias for release: 4.0.2.6-svn4aug2008 * Description: put the program in a window don't save evaluate (f 10) at the prompt in the repl this high-lights "ng Pic" in the third line and reports three errors, none of them explainig what went wrong * How to repeat: (define-struct: lw ([e : (U (Listof lw) Symbol String Pict)] [line : Integer] [line-span : Integer] [column : Integer] [column-span : Integer] [unq? : Boolean] [metafunction-name :(U #f Symbol)])) ;; the U shold be a case-lambda (case-lambda: [((i : Integer)) i] [((b : Boolean) (i : Integer)) i])) *\ Environment: macosx "Darwin europe.local 8.11.1 Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28 PDT 2007; root:xnu-792.25.20~1/RELEASE_I386 i386 i386" (i386-macosx/3m) (get-display-depth) = 32 Human Language: english (current-memory-use) 158718820 Collections: (("/Users/matthias/Unison/collects/" ".DS_Store" "date" "finance" "info-domain" "info.ss" "short" "testing" "tll-collects" "utils" "web") ("/Users/matthias/Library/PLT Scheme/4.0.2.6/collects" non-existent-path) ("/Users/matthias/plt/collects" ".DS_Store" ".svn" "afm" "algol60" "big" "browser" "combinator-parser" "compiler" "config" "defaults" "doc" "drscheme" "dynext" "embedded-gui" "eopl" "errortrace" "ffi" "file" "framework" "frtime" "games" "graphics" "gui-debugger" "guibuilder" "handin-client" "handin-server" "help" "hierlist" "honu" "honu-module" "htdch" "htdp" "html" "icons" "info-domain" "lang" "launcher" "lazy" "little-helper" "macro-debugger" "make" "mred" "mrflow" "mrlib" "mysterx" "mzcom" "mzlib" "mzscheme" "mztake" "net" "openssl" "parser-tools" "planet" "plot" "preprocessor" "profj" "profjBoxes" "profjWizard" "r5rs" "r6rs" "readline" "redex" "repos-time-stamp" "rnrs" "s-exp" "scheme" "scribble" "scribblings" "setup" "sgl" "sirmail" "skipper" "slatex" "slibinit"! "slideshow" "srfi" "srpersist" "stepper" "string-constants" "swindle" "syntax" "syntax-color" "teachpack" "test-box-recovery" "test-engine" "test-suite" "tests" "tex2page" "texpict" "trace" "typed-scheme" "version" "waterworld" "web-server" "wxme" "xml"))
Computer Language: (("Module") (#(#t write mixed-fraction-e #f #t debug) (default) #() "#lang scheme\n"))
samth@ccs.neu.edu
I'm not sure what you're saying. The function `f' had that type, but
then Matthias assigned it a different (super) type, which led to
strange errors. There would be no errors in that program if Matthias
had written `case-lambda' instead of `U'.
sam th
On Fri, Aug 8, 2008 at 8:40 PM, Robby Findler robby@plt-scheme.org wrote:
(case-lambda (-> int int) (-> int bool bool))
A new problem report is waiting at http://bugs.plt-scheme.org/query/?cmd=view&pr=9672 Reported by matthias for release: 4.0.2.6-svn4aug2008 * Description: put the program in a window don't save evaluate (f 10) at the prompt in the repl this high-lights "ng Pic" in the third line and reports three errors, none of them explainig what went wrong * How to repeat: (define-struct: lw ([e : (U (Listof lw) Symbol String Pict)] [line : Integer] [line-span : Integer] [column : Integer] [column-span : Integer] [unq? : Boolean] [metafunction-name :(U #f Symbol)])) ;; the U shold be a case-lambda (case-lambda: [((i : Integer)) i] [((b : Boolean) (i : Integer)) i])) *\ Environment: macosx "Darwin europe.local 8.11.1 Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28 PDT 2007; root:xnu-792.25.20~1/RELEASE_I386 i386 i386" (i386-macosx/3m) (get-display-depth) = 32 Human Language: english (current-memory-use) 158718820 Collections: (("/Users/matthias/Unison/collects/" ".DS_Store" "date" "finance" "info-domain" "info.ss" "short" "testing" "tll-collects" "utils" "web") ("/Users/matthias/Library/PLT Scheme/4.0.2.6/collects" non-existent-path) ("/Users/matthias/plt/collects" ".DS_Store" ".svn" "afm" "algol60" "big" "browser" "combinator-parser" "compiler" "config" "defaults" "doc" "drscheme" "dynext" "embedded-gui" "eopl" "errortrace" "ffi" "file" "framework" "frtime" "games" "graphics" "gui-debugger" "guibuilder" "handin-client" "handin-server" "help" "hierlist" "honu" "honu-module" "htdch" "htdp" "html" "icons" "info-domain" "lang" "launcher" "lazy" "little-helper" "macro-debugger" "make" "mred" "mrflow" "mrlib" "mysterx" "mzcom" "mzlib" "mzscheme" "mztake" "net" "openssl" "parser-tools" "planet" "plot" "preprocessor" "profj" "profjBoxes" "profjWizard" "r5rs" "r6rs" "readline" "redex" "repos-time-stamp" "rnrs" "s-exp" "scheme" "scribble" "scribblings" "setup" "sgl" "sirmail" "skipper" "slatex" "slibinit"! "slideshow" "srfi" "srpersist" "stepper" "string-constants" "swindle" "syntax" "syntax-color" "teachpack" "test-box-recovery" "test-engine" "test-suite" "tests" "tex2page" "texpict" "trace" "typed-scheme" "version" "waterworld" "web-server" "wxme" "xml"))
Computer Language: (("Module") (#(#t write mixed-fraction-e #f #t debug) (default) #() "#lang scheme\n"))
samth@ccs.neu.edu
Oh! Sorry. I see.
On Fri, Aug 8, 2008 at 7:44 PM, Sam TH samth@plt-scheme.org wrote:
(case-lambda (-> int int) (-> int bool bool))
A new problem report is waiting at http://bugs.plt-scheme.org/query/?cmd=view&pr=9672 Reported by matthias for release: 4.0.2.6-svn4aug2008 * Description: put the program in a window don't save evaluate (f 10) at the prompt in the repl this high-lights "ng Pic" in the third line and reports three errors, none of them explainig what went wrong * How to repeat: (define-struct: lw ([e : (U (Listof lw) Symbol String Pict)] [line : Integer] [line-span : Integer] [column : Integer] [column-span : Integer] [unq? : Boolean] [metafunction-name :(U #f Symbol)])) ;; the U shold be a case-lambda (case-lambda: [((i : Integer)) i] [((b : Boolean) (i : Integer)) i])) *\ Environment: macosx "Darwin europe.local 8.11.1 Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28 PDT 2007; root:xnu-792.25.20~1/RELEASE_I386 i386 i386" (i386-macosx/3m) (get-display-depth) = 32 Human Language: english (current-memory-use) 158718820 Collections: (("/Users/matthias/Unison/collects/" ".DS_Store" "date" "finance" "info-domain" "info.ss" "short" "testing" "tll-collects" "utils" "web") ("/Users/matthias/Library/PLT Scheme/4.0.2.6/collects" non-existent-path) ("/Users/matthias/plt/collects" ".DS_Store" ".svn" "afm" "algol60" "big" "browser" "combinator-parser" "compiler" "config" "defaults" "doc" "drscheme" "dynext" "embedded-gui" "eopl" "errortrace" "ffi" "file" "framework" "frtime" "games" "graphics" "gui-debugger" "guibuilder" "handin-client" "handin-server" "help" "hierlist" "honu" "honu-module" "htdch" "htdp" "html" "icons" "info-domain" "lang" "launcher" "lazy" "little-helper" "macro-debugger" "make" "mred" "mrflow" "mrlib" "mysterx" "mzcom" "mzlib" "mzscheme" "mztake" "net" "openssl" "parser-tools" "planet" "plot" "preprocessor" "profj" "profjBoxes" "profjWizard" "r5rs" "r6rs" "readline" "redex" "repos-time-stamp" "rnrs" "s-exp" "scheme" "scribble" "scribblings" "setup" "sgl" "sirmail" "skipper" "slatex" "slibinit"! "slideshow" "srfi" "srpersist" "stepper" "string-constants" "swindle" "syntax" "syntax-color" "teachpack" "test-box-recovery" "test-engine" "test-suite" "tests" "tex2page" "texpict" "trace" "typed-scheme" "version" "waterworld" "web-server" "wxme" "xml"))
Computer Language: (("Module") (#(#t write mixed-fraction-e #f #t debug) (default) #() "#lang scheme\n"))
samth@ccs.neu.edu
samth@ccs.neu.edu
On Aug 8, 2008, at 8:33 PM, Sam TH wrote:
> However, the reason you're getting the other behavior you are
> seeing is this:
This far I follow: (case-lambda a b) <: (U a b).
> it.
Eh? When someone tells me x : (U a b) I'd say x in a OR x in b suffices.
So I am lost with this sentence.
> The first element typechecks fine, but the second one has two
This follows from a sentence I don't get.
>> A new problem report is waiting at
>> http://bugs.plt-scheme.org/query/?cmd=view&pr=9672
>> Reported by matthias for release: 4.0.2.6-svn4aug2008
>> *** Description:
>> put the program in a window
>> don't save
>> evaluate (f 10) at the prompt in the repl
>> this high-lights "ng Pic" in the third line
>> and reports three errors, none of them explainig what went wrong
>> *** How to repeat:
>> (define-struct: lw ([e : (U (Listof lw) Symbol String Pict)]
>> [line : Integer] [line-span : Integer]
>> [column : Integer] [column-span : Integer]
>> [unq? : Boolean]
>> [metafunction-name :(U #f Symbol)]))
>> ;; the U shold be a case-lambda
>> (case-lambda:
>> [((i : Integer)) i]
>> [((b : Boolean) (i : Integer)) i]))
>> *** Environment:
>> macosx "Darwin europe.local 8.11.1 Darwin Kernel Version 8.11.1:
>> Wed Oct 10 18:23:28 PDT 2007; root:xnu-792.25.20~1/RELEASE_I386
>> i386 i386" (i386-macosx/3m) (get-display-depth) = 32
>> Human Language: english
>> (current-memory-use) 158718820
>> Collections:
>> (("/Users/matthias/Unison/collects/" ".DS_Store" "date" "finance"
>> "info-domain" "info.ss" "short" "testing" "tll-collects" "utils"
>> "web") ("/Users/matthias/Library/PLT Scheme/4.0.2.6/collects" non-
>> existent-path) ("/Users/matthias/plt/collects" ".DS_Store" ".svn"
>> "afm" "algol60" "big" "browser" "combinator-parser" "compiler"
>> "config" "defaults" "doc" "drscheme" "dynext" "embedded-gui"
>> "eopl" "errortrace" "ffi" "file" "framework" "frtime" "games"
>> "graphics" "gui-debugger" "guibuilder" "handin-client" "handin-
>> server" "help" "hierlist" "honu" "honu-module" "htdch" "htdp"
>> "html" "icons" "info-domain" "lang" "launcher" "lazy" "little-
>> helper" "macro-debugger" "make" "mred" "mrflow" "mrlib" "mysterx"
>> "mzcom" "mzlib" "mzscheme" "mztake" "net" "openssl" "parser-tools"
>> "planet" "plot" "preprocessor" "profj" "profjBoxes" "profjWizard"
>> "r5rs" "r6rs" "readline" "redex" "repos-time-stamp" "rnrs" "s-exp"
>> "scheme" "scribble" "scribblings" "setup" "sgl" "sirmail"
>> "skipper" "slatex" "slibinit
> "!
>> "slideshow" "srfi" "srpersist" "stepper" "string-constants"
>> "swindle" "syntax" "syntax-color" "teachpack" "test-box-recovery"
>> "test-engine" "test-suite" "tests" "tex2page" "texpict" "trace"
>> "typed-scheme" "version" "waterworld" "web-server" "wxme" "xml"))
>> Computer Language: (("Module") (#(#t write mixed-fraction-e #f #t
>> debug) (default) #() "#lang scheme\n"))
> --
> samth@ccs.neu.edu
On Aug 9, 2008, at 10:50 AM, Matthias Felleisen wrote:
>> it.
> Eh? When someone tells me x : (U a b) I'd say x in a OR x in b
> suffices.
The problem is that it's one or the other, but you don't know which.
It's like if you have x : (U String Integer); you have to check first
to see if x is a String or an Integer before you can use it at one of
the specific types inside the union.
After all, this variable below also has type (U (Integer -> Integer)
(Boolean Integer -> Integer)):
#lang typed-scheme
(define bool-check? #f)
(: f (U (Integer -> Integer) (Boolean Integer -> Integer)))
(define f
(if bool-check?
(lambda: ([x : Integer]) x)
(lambda: ([b : Boolean] [x : Integer])
(if b x 0))))
but there's no way you'd be able to just say
(f 10)
after this definition, since f might not be (Integer -> Integer).
On Aug 9, 2008, at 11:42 AM, Stevie Strickland wrote:
>>> it.
>> Eh? When someone tells me x : (U a b) I'd say x in a OR x in b
>> suffices.
> The problem is that it's one or the other, but you don't know which.
That explanation I understand. It jives me with OR sense of U.
Question: Is it at all possible to apply an f with type (U (Boolean -
> Boolean) (Boolean Char -> Boolean)) say via arity? Even if this is
possible, what about (U (Boolean -> Char) (Integer -> Char))?
> It's like if you have x : (U String Integer); you have to check
> first to see if x is a String or an Integer before you can use it
> at one of the specific types inside the union.
> After all, this variable below also has type (U (Integer ->
> Integer) (Boolean Integer -> Integer)):
> (if bool-check?
> (lambda: ([x : Integer]) x)
> (lambda: ([b : Boolean] [x : Integer])
> (if b x 0))))
On Aug 9, 2008, at 11:51 AM, Matthias Felleisen wrote:
> > Boolean) (Boolean Char -> Boolean)) say via arity? Even if this is
In the first case, if Typed Scheme understood procedure-reduce-arity
with a constant arity argument as an attempt to do such discrimination
and the union only included one function at that arity, then perhaps
you could do it that way, but I'm not sure that's very useful (or used
often enough in PLT to be worth adding as a special case, but I
haven't checked).
In the latter, you're totally hosed once you've gotten a type like
that. The only way I could imagine using it is if it made sense to
lift the union into the function type to get (-> (U Boolean Integer)
Char), and then you could use it with a variable of that union type.
But since union can't be lifted across function types like that, so
yeah, no way I can think off of the top of my head.
Good! These are the answers I wanted.
On Aug 9, 2008, at 12:03 PM, Stevie Strickland wrote:
>> Question: Is it at all possible to apply an f with type (U
>> (Boolean -> Boolean) (Boolean Char -> Boolean)) say via arity?
>> Even if this is possible, what about (U (Boolean -> Char) (Integer
>> -> Char))?
> In the first case, if Typed Scheme understood procedure-reduce-
> arity with a constant arity argument as an attempt to do such
> discrimination and the union only included one function at that
> arity, then perhaps you could do it that way, but I'm not sure
> that's very useful (or used often enough in PLT to be worth adding
> as a special case, but I haven't checked).
> lift the union into the function type to get (-> (U Boolean
> Integer) Char), and then you could use it with a variable of that
> union type. But since union can't be lifted across function types
> like that, so yeah, no way I can think off of the top of my head.
On Fri, Aug 8, 2008 at 8:33 PM, Sam TH <samth@plt-scheme.org> wrote:
Just to make sure it doesn't get lost in the shuffle, there's a
DrScheme bug here with the highlighting. Robby, should I assign the
bug to you?
That's how things usually work.
On Aug 19, 2008, at 3:54 PM, Sam TH wrote:
> --
> samth@ccs.neu.edu
Maybe it would be better to open a new report, esp. if you can give me
a different, typeed-scheme-less program to reproduce it?
I only ask this because I'm keeping counts of contract violations,
etc, and so having a separate report helps me with that.
On Tue, Aug 19, 2008 at 2:54 PM, Sam TH <samth@plt-scheme.org> wrote:
> --
> samth@ccs.neu.edu
I've submitted a new bug with a small testcase. I'll close this bug.
sam th
On Tue, Aug 19, 2008 at 4:36 PM, Robby Findler <robby@plt-scheme.org> wrote:
>> --
>> samth@ccs.neu.edu
Thanks.
On Tue, Aug 19, 2008 at 3:58 PM, Sam TH <samth@plt-scheme.org> wrote:
>>> --
>>> samth@ccs.neu.edu
> --
> samth@ccs.neu.edu
Originally submitted on: Fri Aug 08 19:56:01 -0400 2008
Steps to Reproduce:
Release:
Environment:
This bug was converted from Gnats bug 9672.