[racket-users] map in typed/racket
I have a little bit of a problem in understanding the function map with typed/racket. My problem starts with an application of map which in normal racket is very straight forward: > (map car '(("Eins" "One" "Un") ("Zwei" "Dos" "Two" "Deux") ("Drei" "Tres" "Trois"))) '("Eins" "Zwei" "Drei") If map is applied this way in typed/racket it yields an error: Type Checker: Polymorphic function `map' could not be applied to arguments: Domains: (-> a b ... b c) (Listof a) (Listof b) ... b (-> a c) (Pairof a (Listof a)) Arguments: (All (a b) (case-> (-> (Pairof a b) a) (-> (Listof a) a))) (List (List String String String) (List String String String String) (List String String String)) There is an easy way to get around this by using for/list with some type annotations. > (let ([ml '(("Eins" "One" "Un") ("Zwei" "Dos" "Two" "Deux") ("Drei" "Tres" "Trois"))]) (for/list : (Listof String) ([l : (Listof String) ml]) (car l))) - : (Listof String) '("Eins" "Zwei" "Drei") But this leaves me a little bit irritated. The function map has the following type in typed/racket: > map - : (All (c a b ...) (case-> (-> (-> a c) (Pairof a (Listof a)) (Pairof c (Listof c))) (-> (-> a b ... b c) (Listof a) (Listof b) ... b (Listof c # So in my code here I believed the type system would pick the first case where map is a function that takes two arguments a function with the domain of a and the range of c and as second argument a not emtpy list of type a. I thought the type placeholder a could in this case be (Listof String) so (Pairof a (Listof a)) translates to (Pairof String (Listof String)) which is the same as a nonempty (Listof String). But apparantly the type system has a different view and is unable to apply map to the supplied arguments. So I do need some help to get a better understanding of the type system. Thanks to everyone who reads this. -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/e3e829f5-39c3-4e24-bd08-0b037645fbcan%40googlegroups.com.
[racket-users] racket 7.0 typed racket, a small problem with the type of the method set-pixel from Bitmap-DC%
I just encountered a problem while I was experimenting with typed racket and the drawing toolkit. I called (send my-bitmap-dc some-x-value some-y-value my-color) and the interpreter complained that set-pixel broke it's own contract. I decided to look at the type of this method (or should I better call it function?). The type is defined in a file named "gui-types.rkt". In the section of the type-definition of Bitmap-DC% is the line [set-pixel (Real Real (Instance Color%) -> Boolean)] I changed that into [set-pixel (Real Real (Instance Color%) -> Void)] Now my code worked perfectly and I'm happy for the time being. But as I am not really a developer I don't feel too comfortable changing program code which should be private to the racket-lang system. So my questions are now was it alright to make this change or is there something which has to be considered first before making such changes deep in the racket-lang system? Thanks in advance for any suggestions. -- 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] problems with scribble while trying to document classes
Am Donnerstag, 10. März 2016 17:20:24 UTC+1 schrieb Matthew Flatt: > You need > > @(require (for-label racket/class)) > > to connect `object%` as used in your documentation to the `object%` > binding that is defined in documentation. > That works! Thanks for the immediate answer! -- 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] problems with scribble while trying to document classes
I was writing some documentation about my experiments with classes and types while I encountered some problems. The first question came up when I read the scribble documentation because I could not find any information concerning the case when the class I like to document does not implement any interface? In a first attempt I simply tried not to specify any interfaces. This worked but only as long as I did not use @defmodule. To demonstrate the problem I post the code: #lang scribble/manual @(require racket (file "class-1.rkt")) blah blah... @defclass[c1% object% ()]{this is class-1 documentation...} This works but you get these annoying warnings "No declared exporting libraries...". So I added @defmodule and the code looked like this: #lang scribble/manual @(require racket (file "class-1.rkt")) @defmodule[(file "class-1.rkt")]{This is the documentation of module @racket[class-1].} blah blah... @defclass[c1% object% ()]{this is class-1 documentation} Now the result was the following error message: ../../../../racket-6.4/share/racket/pkgs/scribble-lib/scribble/private/manual-class.rkt:127:11: scribble: no class/interface/mixin information for identifier: # When I now get rid of the @defclass thing (it seems to be a macro but as I am still learning racket I'm not so sure...) then scribble works again: #lang scribble/manual @(require racket (file "class-1.rkt")) @defmodule[(file "class-1.rkt")]{This is the documentation of module @racket[class-1].} blah blah... Is scribble not applicable to document such small modules? Does scribble need some more preparation to document classes? I ask this because in other circumstances scribble worked fine. Only as I tried to document the classes I created the problems. I also looked at some of the sources of the racket documentation to see how the 'professionals' did it. But that did not help me. Thanks in advance for any response! -- 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] Typed Classes and this%
I'm just experimenting with typed classes in the typed/racket language.In my first experiments I created a class called polynome% with a method derive. The result of this method is new instance of this class via (new this% ...). Unfortunately the drracket environment complained that it does not know this%. Is 'this%' missing by design or is it just not yet implemented? -- 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.