[racket] users Digest, Vol 109, Issue 69

From: Moshe Deutsch (moshedeutsch115 at gmail.com)
Date: Mon Sep 29 16:42:09 EDT 2014

Please take me off the list

Thanks

On Sun, Sep 28, 2014 at 2:08 PM,  <users-request at racket-lang.org> wrote:
> Send users mailing list submissions to
>         users at racket-lang.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://lists.racket-lang.org/users/listinfo
> or, via email, send a message with subject or body 'help' to
>         users-request at racket-lang.org
>
> You can reach the person managing the list at
>         users-owner at racket-lang.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of users digest..."
>
>
> [Racket Users list:
>  http://lists.racket-lang.org/users ]
>
>
> Today's Topics:
>
>    1. Re: typed racket, filters, and polymorphism (Alexander D. Knauth)
>    2. Help debugging a ffi crash (Eric Dobson)
>    3. Re: [GENERAL] Off Topic: Anybody reading this via
>       news.gmane.org? (Adrian Klaver)
>    4. Re: Help debugging a ffi crash (Matthew Flatt)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 28 Sep 2014 13:37:30 -0400
> From: "Alexander D. Knauth" <alexander at knauth.org>
> To: Spencer florence <spencerflorence at gmail.com>
> Cc: racket users list <users at racket-lang.org>, Sam Tobin-Hochstadt
>         <samth at cs.indiana.edu>
> Subject: Re: [racket] typed racket, filters, and polymorphism
> Message-ID: <B849BCC0-7F5C-402E-B98C-01F97E1762D8 at knauth.org>
> Content-Type: text/plain; charset="utf-8"
>
> No because I want the unit to be a struct that has a dimension field, not a symbol with various dimensions defined as unions of units.
> I want the unit to be based on the dimension, not the other way around, so that new units can be made that have the same dimension.
>
> I have something like the number+unit struct (I called it measure), but I?ll work on more that after I have the unit struct figured out.
>
> On Sep 28, 2014, at 12:13 PM, Spencer florence <spencerflorence at gmail.com> wrote:
>
>> would something like this work?
>>
>> #lang typed/racket
>>
>> (struct (U) number+unit ([amount : Real] [unit : U]))
>>
>> (define-type Weight-Unit (U 'kg 'g 'mg '?g))
>> (define-type Weight (number+unit Weight-Unit))
>> (define-predicate weight? Weight)
>>
>> (: make-weight : Real Weight-Unit -> Weight)
>> (define (make-weight n u)
>>   (number+unit n u))
>>
>> (: +/weight : Weight Weight -> Weight)
>> ;; something something needs unit conversion
>> (define (+/weight w1 w2)
>>   (number+unit (+ (number+unit-amount w1)
>>                   (number+unit-amount w1))
>>                (number+unit-unit w1)))
>>
>> (+/weight (make-weight 1 'kg) (make-weight 1 'kg))
>>
>>
>>
>> On Sun, Sep 28, 2014 at 11:03 AM, Alexander D. Knauth <alexander at knauth.org> wrote:
>>
>> Because the struct is representing a unit (kilograms, meters, seconds, etc.), and a unit has a dimension (mass, length, time, etc.) and I want the type-checker to be able to know what the dimension of a unit is so that the types of functions can specify the dimension that something should have.
>> The real solution to this would probably be bounded polymorphism, but I was wondering if there was some other way to do it with occurrence typing in the guard or something like that.
>>
>> On Sep 28, 2014, at 11:48 AM, Sam Tobin-Hochstadt <samth at cs.indiana.edu> wrote:
>>
>> > Why not do this with the type, instead of making this polymorphic?
>> >
>> > Sam
>> >
>> > On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth
>> > <alexander at knauth.org> wrote:
>> >> Is it possible to have a struct that does certain things according to the
>> >> guard?
>> >> #lang typed/racket
>> >>
>> >> (struct (a) foo ([a : a]) #:transparent
>> >> #:guard (lambda (a _)
>> >> (unless (exact-integer? a)
>> >> (error 'foo "expected Integer, given ~v" a))
>> >> a))
>> >>
>> >> (ann (foo (ann 1 Any)) (foo Integer))
>> >>
>> >> (: x : (foo Any))
>> >> (define x (foo 1))
>> >>
>> >> (ann (foo-a x) Integer)
>> >>
>> >> ;. Type Checker: Polymorphic function `foo1' could not be applied to
>> >> arguments:
>> >> ;Argument 1:
>> >> ; Expected: a
>> >> ; Given: Any
>> >> ;
>> >> ;Result type: (foo a)
>> >> ;Expected result: (foo Integer)
>> >> ; in: (foo (ann 1 Any))
>> >> ;. Type Checker: Polymorphic function `foo-a' could not be applied to
>> >> arguments:
>> >> ;Argument 1:
>> >> ; Expected: (foo a)
>> >> ; Given: (foo Any)
>> >> ;
>> >> ;Result type: (a : ....)
>> >> ;Expected result: Integer
>> >> ; in: (foo-a x)
>> >>
>> >> On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth <alexander at knauth.org>
>> >> wrote:
>> >>
>> >> What I?m trying to accomplish is something more like this:
>> >> #lang typed/racket
>> >>
>> >> (require "dimensions.rkt")
>> >>
>> >> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d])
>> >> #:transparent
>> >> #:guard (lambda (name scalar dimension _)
>> >> (unless (dimension? dimension)
>> >> (error 'unit "expected Dimension, given ~v" dimension))
>> >> (values name scalar dimension)))
>> >>
>> >> (define-type (Unitof d) (unit d))
>> >>
>> >> (define-type Unit (Unitof Dimension))
>> >>
>> >> (define Unit? (make-predicate Unit))
>> >>
>> >> (define-type Unitish
>> >> (U (Unitof Any)
>> >> Dimension
>> >> Positive-Real))
>> >>
>> >> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)]
>> >> [Unitish -> Unit])))
>> >> (define (->unit u)
>> >> (cond [(unit? u)
>> >> (unless (Unit? u) ; this should never happen anyway because of the
>> >> guard
>> >> (error '->unit "expected (Unitof Dimension), given ~v" u))
>> >> u]
>> >> [(dimension? u) (unit u 1 u)]
>> >> [(positive-real? u) (unit u u dimensionless-dimension)]))
>> >>
>> >>
>> >> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt <samth at cs.indiana.edu>
>> >> wrote:
>> >>
>> >> No, I don't think you can do this. Can you say more about what you're
>> >> trying to accomplish?
>> >>
>> >> Sam
>> >>
>> >> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth
>> >> <alexander at knauth.org> wrote:
>> >>
>> >> Do any of you have any advice for getting a function like this to
>> >> type-check?
>> >> #lang typed/racket
>> >>
>> >> (: check-int : (All (a) (case-> [a -> a]
>> >> [Any -> Integer])))
>> >> (define (check-int int)
>> >> (unless (exact-integer? int)
>> >> (error 'check-int "expected Integer, given ~v" int))
>> >> int)
>> >>
>> >> ;. Type Checker: type mismatch
>> >> ; expected: a
>> >> ; given: Integer in: int
>> >>
>> >>
>> >>
>> >> ____________________
>> >> Racket Users list:
>> >> http://lists.racket-lang.org/users
>> >>
>> >>
>> >> ____________________
>> >> Racket Users list:
>> >> http://lists.racket-lang.org/users
>> >>
>> >>
>>
>>
>> ____________________
>> Racket Users list:
>> http://lists.racket-lang.org/users
>>
>>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://lists.racket-lang.org/users/archive/attachments/20140928/56742b6b/attachment-0001.html>
>
> ------------------------------
>
> Message: 2
> Date: Sun, 28 Sep 2014 10:48:06 -0700
> From: Eric Dobson <eric.n.dobson at gmail.com>
> To: "users at racket-lang.org" <users at racket-lang.org>
> Subject: [racket] Help debugging a ffi crash
> Message-ID:
>         <CAAEHQ5uRU5V4i1rvNf6sdfcbQsD087ntCwftjRVhKroNErmUXg at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> I'm trying to debug an FFI crash that I'm seeing, and because it is
> dealing with C code the error just presents as a segfault. I believe I
> have tracked down what is causing the problem, but don't understand
> how it could be doing so.
>
> I have two racket functions which take a "cursor" (the foreign
> libraries object) and return a string representation of it, which I'm
> trying to use for debugging.
>
> (define raw-clang-get-cstring
>   (get-ffi-obj "clang_getCString" lib-clang
>     (_fun _pointer -> _string)))
>
> (define raw-cursor-spelling
>  (get-ffi-obj "clang_getCursorSpelling" lib-clang
>    (_fun _CXCursor -> _pointer)))
>
> (define (cursor-spelling c)
>   (raw-clang-get-cstring (raw-cursor-spelling c)))
>
> (define cursor-spelling2
>  (get-ffi-obj "clang_getCursorSpelling" lib-clang
>    (_fun _CXCursor -> (make-ctype _pointer values (? (v)
> (raw-clang-get-cstring v))))))
>
> If I use cursor-spelling, I have not been able to trigger a crash. But
> if I use cursor-spelling2 I can reliably trigger a crash.
>
> Is there anything obvious on how these functions are different?
> Because they look to me like they should be doing the same thing. If
> it would be helpful I can try to get my code in a portable enough
> shape so that it will work/crash on another machine.
>
>
>
> ------------------------------
>
> Message: 3
> Date: Thu, 25 Sep 2014 17:25:15 -0700
> From: Adrian Klaver <adrian.klaver at aklaver.com>
> To: George Neuner <gneuner2 at comcast.net>, neil at neilvandyke.org
> Cc: "users at racket-lang.org >> users" <users at racket-lang.org>
> Subject: Re: [racket] [GENERAL] Off Topic: Anybody reading this via
>         news.gmane.org?
> Message-ID: <5424B26B.9080504 at aklaver.com>
> Content-Type: text/plain; charset=windows-1252; format=flowed
>
> On 09/25/2014 05:13 PM, George Neuner wrote:
>>
>> On 9/25/2014 5:26 PM, Neil Van Dyke wrote:
>>> You can check your IP addr against the list at
>>> "http://gmane.org/denied.php".
>>>
>>> Neil V.
>>
>> On 9/25/2014 7:08 PM, Adrian Klaver wrote:
>>>
>>> Take a look here:
>>>
>>> http://gmane.org/denied.php
>>>
>>> My guess is you are the fourth one from the bottom.
>>>
>>>
>>> Might want to take a look at this thread to see what your options are
>>> and what the turn around time is on your request:
>>>
>>> http://thread.gmane.org/gmane.discuss/16309
>>
>> Thanks to both of you - I missed seeing the entry about the denied list
>> in the FAQ.
>>
>> Adrian you were right - it seems that I have been blocked for some
>> reason.  Based on the description of infractions I really don't think I
>> did anything to warrant it ... but there it is.  I'll have to follow my
>> lists by email until I can unblocked.
>
> I think the relevant part at gmane.org/denied.php is:
>
> "Since there is no way to identify users, news readers are denied on a
> domain/IP basis. So if somebody on a machine close to you downloaded the
> news spool yesterday, you're likely to be denied today"
>
>>
>> Thanks again,
>> George
>
>
> --
> Adrian Klaver
> adrian.klaver at aklaver.com
>
>
> ------------------------------
>
> Message: 4
> Date: Sun, 28 Sep 2014 12:08:23 -0600
> From: Matthew Flatt <mflatt at cs.utah.edu>
> To: Eric Dobson <eric.n.dobson at gmail.com>
> Cc: "users at racket-lang.org" <users at racket-lang.org>
> Subject: Re: [racket] Help debugging a ffi crash
> Message-ID: <20140928180825.80D74650196 at mail-svr1.cs.utah.edu>
> Content-Type: text/plain; charset=UTF-8
>
> Looking at
>
>   http://clang.llvm.org/doxygen/CXString_8h_source.html
>
> it seems that CXString as returned by clang_getCursorSpelling() is not
> a pointer:
>
>  typedef struct {
>    const void *data;
>    unsigned private_flags;
>  } CXString;
>
> If that's right, I'm a little surprised that `cursor-spelling` works
> --- but when you get representation wrong, strange things can happen,
> including something working when it shouldn't.
>
> Am I looking at the right library/definitions?
>
> At Sun, 28 Sep 2014 10:48:06 -0700, Eric Dobson wrote:
>> I'm trying to debug an FFI crash that I'm seeing, and because it is
>> dealing with C code the error just presents as a segfault. I believe I
>> have tracked down what is causing the problem, but don't understand
>> how it could be doing so.
>>
>> I have two racket functions which take a "cursor" (the foreign
>> libraries object) and return a string representation of it, which I'm
>> trying to use for debugging.
>>
>> (define raw-clang-get-cstring
>>   (get-ffi-obj "clang_getCString" lib-clang
>>     (_fun _pointer -> _string)))
>>
>> (define raw-cursor-spelling
>>  (get-ffi-obj "clang_getCursorSpelling" lib-clang
>>    (_fun _CXCursor -> _pointer)))
>>
>> (define (cursor-spelling c)
>>   (raw-clang-get-cstring (raw-cursor-spelling c)))
>>
>> (define cursor-spelling2
>>  (get-ffi-obj "clang_getCursorSpelling" lib-clang
>>    (_fun _CXCursor -> (make-ctype _pointer values (? (v)
>> (raw-clang-get-cstring v))))))
>>
>> If I use cursor-spelling, I have not been able to trigger a crash. But
>> if I use cursor-spelling2 I can reliably trigger a crash.
>>
>> Is there anything obvious on how these functions are different?
>> Because they look to me like they should be doing the same thing. If
>> it would be helpful I can try to get my code in a portable enough
>> shape so that it will work/crash on another machine.
>>
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>
>
>
> End of users Digest, Vol 109, Issue 69
> **************************************


Posted on the users mailing list.