Re: [racket-users] (number->string -nan.0) == "+nan.0" ?
Looks like its for the same reason that (number->string -0) yields "0". +nan.0 is special, but -nan.0 is the same as (- +nan.0) http://docs.racket-lang.org/reference/numbers.html On Mon, Feb 5, 2018 at 6:41 PM, David Storrs wrote: > I noticed that (number->string -nan.0) yields "+nan.0" instead of "-nan.0" > as I would have expected. It's not an issue for me, but I was wondering why > this is? > > -- > 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. -- 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] Defining algebraic data types?
On Mon, Feb 5, 2018 at 6:36 PM, HiPhish wrote: > Why would that be a problem? The caller has to provide a function for > "adding" > and "multiplying" an N, and as long as I define what it means to multiply > and > add strings it shouldn't matter that I'm using a dual number where both > components are strings. The problem is that the definition of `(Dual-Number N)` includes `N`, and therefore (Dual-Number (Dual-Number String)) might either be a (D (D "x" "y") (D "x" "y")) or just (D "x" "y"). Therefore checking D? can't tell that you're in the `D` case because both cases could be a `D` case. Sam > > But I think this is a case of the rectangle-square problem: dual scalars and > a > dual vectors a both a subset of dual quaternions that contain less > information > than their supertype. I guess what I'm really looking for is a way to > "magically" promote objects. > > A quaternion is an object of > > H = {a + bi + cj + dk | a,b,c,d ∈ R}, > > a vector is an object of > > V = {ai + bj + ck | a,b,c ∈ R}, > > but we can also view H as > > H = R × V = {(a, v) | a ∈ R, v ∈ V}. > > The first definition of H is how it is usually defined and written out, but > the > second definition makes it easier to compute the product: > > (p_r, p_v) (q_r, q_v) = (p_r q_r - p_v ⋅ q_v, p_r q_v + q_r p_v + p_v × > q_v). > > So far this is a simple hierarchy. But the set of scalars and the set of > vectors can be embedded in the set of quaternions: > > R → H, a ↦ (a, 0) and V → H, v ↦ (0, v) > > We can also define things like the "quaternion cross product" and > "quaternion > dot product" for quaternions where the scalar part is zero: > > (0, p) × (0, q) := (p, p × q) > (0, p) ⋅ (0, q) := (p ⋅ q, 0) > > I'm starting to think this is becoming a pointless exercise. Maybe I should > just limit myself to "dual quaternions are a pair of quaternions" and > "quaternions are pairs of a scalar and a vector" and forget about the magic > subtyping. > > > On Tuesday, February 6, 2018 at 12:01:42 AM UTC+1, Sam Tobin-Hochstadt > wrote: >> >> I'm not sure how the "If" got there. >> >> But to say more, consider your function: >> >> (: dual-* (∀ (N) (→ (Dual-Number N) (Dual-Number N) (→ N N N) (→ N N >> N) (Dual-Number N >> (define (dual-* d1 d2 * +) >> (cond >> [(D? d1) >>(D >> (D-real d1) >> (D-dual d1))] >> [else (D d1 d1)])) >> >> Now you imagine instantiating `N` with things like `(Vector3 Real)`, >> but if we instantiated it instead with `(Dual-Number String)`, then >> you'd have a problem. >> >> Sam > > -- > 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. -- 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] (number->string -nan.0) == "+nan.0" ?
I noticed that (number->string -nan.0) yields "+nan.0" instead of "-nan.0" as I would have expected. It's not an issue for me, but I was wondering why this is? -- 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] Defining algebraic data types?
Why would that be a problem? The caller has to provide a function for "adding" and "multiplying" an N, and as long as I define what it means to multiply and add strings it shouldn't matter that I'm using a dual number where both components are strings. But I think this is a case of the rectangle-square problem: dual scalars and a dual vectors a both a subset of dual quaternions that contain less information than their supertype. I guess what I'm really looking for is a way to "magically" promote objects. A quaternion is an object of H = {a + bi + cj + dk | a,b,c,d ∈ R}, a vector is an object of V = {ai + bj + ck | a,b,c ∈ R}, but we can also view H as H = R × V = {(a, v) | a ∈ R, v ∈ V}. The first definition of H is how it is usually defined and written out, but the second definition makes it easier to compute the product: (p_r, p_v) (q_r, q_v) = (p_r q_r - p_v ⋅ q_v, p_r q_v + q_r p_v + p_v × q_v). So far this is a simple hierarchy. But the set of scalars and the set of vectors can be embedded in the set of quaternions: R → H, a ↦ (a, 0) and V → H, v ↦ (0, v) We can also define things like the "quaternion cross product" and "quaternion dot product" for quaternions where the scalar part is zero: (0, p) × (0, q) := (p, p × q) (0, p) ⋅ (0, q) := (p ⋅ q, 0) I'm starting to think this is becoming a pointless exercise. Maybe I should just limit myself to "dual quaternions are a pair of quaternions" and "quaternions are pairs of a scalar and a vector" and forget about the magic subtyping. On Tuesday, February 6, 2018 at 12:01:42 AM UTC+1, Sam Tobin-Hochstadt wrote: > > I'm not sure how the "If" got there. > > But to say more, consider your function: > > (: dual-* (∀ (N) (→ (Dual-Number N) (Dual-Number N) (→ N N N) (→ N N > N) (Dual-Number N > (define (dual-* d1 d2 * +) > (cond > [(D? d1) >(D > (D-real d1) > (D-dual d1))] > [else (D d1 d1)])) > > Now you imagine instantiating `N` with things like `(Vector3 Real)`, > but if we instantiated it instead with `(Dual-Number String)`, then > you'd have a problem. > > Sam > -- 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] Defining algebraic data types?
I'm not sure how the "If" got there. But to say more, consider your function: (: dual-* (∀ (N) (→ (Dual-Number N) (Dual-Number N) (→ N N N) (→ N N N) (Dual-Number N (define (dual-* d1 d2 * +) (cond [(D? d1) (D (D-real d1) (D-dual d1))] [else (D d1 d1)])) Now you imagine instantiating `N` with things like `(Vector3 Real)`, but if we instantiated it instead with `(Dual-Number String)`, then you'd have a problem. Sam On Mon, Feb 5, 2018 at 5:50 PM, HiPhish wrote: > Did your email get cut off? > > On Monday, February 5, 2018 at 6:00:05 PM UTC+1, Sam Tobin-Hochstadt wrote: >> >> This is an unfortunately common pitfall -- if you instantiated N with >> something that includes a dual number, then the type error would be pointing >> to a real bug. If >> >> Sam > > -- > 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. -- 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] Defining algebraic data types?
Did your email get cut off? On Monday, February 5, 2018 at 6:00:05 PM UTC+1, Sam Tobin-Hochstadt wrote: > > This is an unfortunately common pitfall -- if you instantiated N with > something that includes a dual number, then the type error would be > pointing to a real bug. If > > Sam > -- 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] Defining algebraic data types?
This is an unfortunately common pitfall -- if you instantiated N with something that includes a dual number, then the type error would be pointing to a real bug. If Sam On Feb 5, 2018 7:26 AM, "HiPhish" wrote: > Thank you for your answer, Sam. > > 1) does not really capture it, and 2) is a proof of concept that hasn't > been > updated in almost a year. But it did give me a good idea: use Typed Racket > and > have the type system work for me. > > (struct (N) D ([real : N] [dual : N])) > (define-type (Dual-Number N) (U N (D N))) > > Now a dual number is either an `N` (whatever an `N` is) or a pair of two > `N`s. > My next idea was to implement dual number multiplication like this: > > (: dual-* (∀ (N) (→ (Dual-Number N) (Dual-Number N) (→ N N N) (→ N N N) > (Dual-Number N > (define (dual-* d1 d2 * +) > (cond > [(and (D? d1) (D? d2)) >(D (* (D-real d1) > (D-real d2)) > (+ (* (D-real d1) > (D-dual d2)) > (* (D-dual d1) > (D-real d2] > [(D? d1) (D (* d2 (D-real d1)) (* d2 (D-dual d1)))] > [(D? d2) (D (* d1 (D-real d2)) (* d1 (D-dual d2)))] > [else (* d1 d2)])) > > This captures the rule of multiplication of dual numbers in a generic way. > For > a particular type of dual number one then has to provide the meaning of > `+` and > `*` for the underlying `N`. So in case of dual vectors one could define > > (define-type Dual-Vector (DualNumber (Vector3 Real))) > (: dual-vector-product (→ Dual-Vector Dual-Vector Dual-Vector)) > (define (dual-vector-product dv1 dv2) > (dual-* dv1 dv2 vector3-* vector3-+)) > > There is a problem with `dual-*` though: The predicate `D?` has type `(-> > Any > Boolean : (D Any))`, and thus `D-real` and `D-dual` will return an object > of > type `Any` rather than `N`, even though the type annotation for `dual-*` > makes > it clear that the type would have to be `N`. Here is a simpler form of the > function (obviously wrong math, I just want to get the types right): > > (: dual-* (∀ (N) (→ (Dual-Number N) (Dual-Number N) (→ N N N) (→ N N N) > (Dual-Number N > (define (dual-* d1 d2 * +) > (cond > [(D? d1) >(D > (D-real d1) > (D-dual d1))] > [else (D d1 d1)])) > > When I try to enter the module I get the following error: > > > ,enter "source/types/dual-number.rkt" > source/types/dual-number.rkt:30:5: Type Checker: Polymorphic function > `D1' could not be applied to arguments: > Argument 1: > Expected: N > Given:Any > Argument 2: > Expected: N > Given:Any > > Result type: (D N) > Expected result: (U (D N) N) > > in: (D (D-real d1) (D-dual d1)) > > > On Sunday, February 4, 2018 at 3:26:28 PM UTC+1, Sam Tobin-Hochstadt wrote: >> >> A few answers: >> >> 1. Use struct subtyping to give a type that includes both kinds: >> (struct dual ()) >> (struct quaternion dual (scalar vector)) >> (struct dual-quaternon dual (real dual)) >> >> 2. Use a library that supports algebraic data types, such as >> https://pkgs.racket-lang.org/package/datatype >> >> Sam >> > -- > 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. > -- 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] Defining algebraic data types?
Thank you for your answer, Sam. 1) does not really capture it, and 2) is a proof of concept that hasn't been updated in almost a year. But it did give me a good idea: use Typed Racket and have the type system work for me. (struct (N) D ([real : N] [dual : N])) (define-type (Dual-Number N) (U N (D N))) Now a dual number is either an `N` (whatever an `N` is) or a pair of two `N`s. My next idea was to implement dual number multiplication like this: (: dual-* (∀ (N) (→ (Dual-Number N) (Dual-Number N) (→ N N N) (→ N N N) (Dual-Number N (define (dual-* d1 d2 * +) (cond [(and (D? d1) (D? d2)) (D (* (D-real d1) (D-real d2)) (+ (* (D-real d1) (D-dual d2)) (* (D-dual d1) (D-real d2] [(D? d1) (D (* d2 (D-real d1)) (* d2 (D-dual d1)))] [(D? d2) (D (* d1 (D-real d2)) (* d1 (D-dual d2)))] [else (* d1 d2)])) This captures the rule of multiplication of dual numbers in a generic way. For a particular type of dual number one then has to provide the meaning of `+` and `*` for the underlying `N`. So in case of dual vectors one could define (define-type Dual-Vector (DualNumber (Vector3 Real))) (: dual-vector-product (→ Dual-Vector Dual-Vector Dual-Vector)) (define (dual-vector-product dv1 dv2) (dual-* dv1 dv2 vector3-* vector3-+)) There is a problem with `dual-*` though: The predicate `D?` has type `(-> Any Boolean : (D Any))`, and thus `D-real` and `D-dual` will return an object of type `Any` rather than `N`, even though the type annotation for `dual-*` makes it clear that the type would have to be `N`. Here is a simpler form of the function (obviously wrong math, I just want to get the types right): (: dual-* (∀ (N) (→ (Dual-Number N) (Dual-Number N) (→ N N N) (→ N N N) (Dual-Number N (define (dual-* d1 d2 * +) (cond [(D? d1) (D (D-real d1) (D-dual d1))] [else (D d1 d1)])) When I try to enter the module I get the following error: > ,enter "source/types/dual-number.rkt" source/types/dual-number.rkt:30:5: Type Checker: Polymorphic function `D1' could not be applied to arguments: Argument 1: Expected: N Given:Any Argument 2: Expected: N Given:Any Result type: (D N) Expected result: (U (D N) N) in: (D (D-real d1) (D-dual d1)) On Sunday, February 4, 2018 at 3:26:28 PM UTC+1, Sam Tobin-Hochstadt wrote: > > A few answers: > > 1. Use struct subtyping to give a type that includes both kinds: > (struct dual ()) > (struct quaternion dual (scalar vector)) > (struct dual-quaternon dual (real dual)) > > 2. Use a library that supports algebraic data types, such as > https://pkgs.racket-lang.org/package/datatype > > Sam > -- 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] raco distribute help
Deren, In addition to what Matthew has said, I guess you need to have a 'main' module in your language, and provide it to raco exe, too. It can be a dummy module or not. The requirement of such a module is unclear to me, but it exists. Here is my working script to pack a standalone interpreter of a language 'slon' on Windows: raco exe -o slon-racket ++lib slon/slon-language ++lib slon/lang/reader ++lib slon/main slon-interpreter.rkt raco distribute slon-racket slon-racket.exe Regards, Dmitry On February 1, 2018 8:53:50 PM EET, Deren Dohoda wrote: >Hi everyone, > >I'm having a hard time understanding the docs for raco exe and raco >distribute. > >tl;dr main.rkt has to (dynamic-require user-selected.rkt) and >user-selected.rkt is written in a different #lang and requires a file >from >this program. How do I glue these pieces together for raco exe / raco >distribute? > >My program has two things which seem to be hanging me up. The first is >that >a file is grabbed with (dynamic-require) based on a path obtained by >the >user with (get-file ...). This file is written in a different #lang and >uses (require ...) for some syntax transformers. > >The exe builds alright but chokes when used because it can't find the >#lang >and can't find the (require ...). > >Ideally the file which is given to (dynamic-require ...) could be in >any >folder the user chooses, but then the (require ...) statement would be >all >over the map and I don't understand what I'm supposed to do to resolve >this. If it helps, the file is already required by the program and >isn't >used only by the user-selected file. ++copy-collects doesn't seem to >grab >#lang folders correctly or I don't understand how to use it. > >Can someone give me some guidance here? > >Thanks, >Deren > >-- >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. -- 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] [CFP] ICOOOLPS 2018
Call for Papers: ICOOOLPS'18 13th Workshop on Implementation, Compilation, Optimization of Object- Oriented Languages, Programs and Systems Co-located with ECOOP 2018 held Mon 16 - Sun 22 July in Amsterdam, Netherlands Twitter: @ICOOOLPS URL: https://conf.researchr.org/track/ecoop-issta-2018/ICOOOLPS-2018-papers The ICOOOLPS workshop series brings together researchers and practitioners working in the field of language implementation and optimization. The goal of the workshop is to discuss emerging problems and research directions as well as new solutions to classic performance challenges. The topics of interest for the workshop include techniques for the implementation and optimization of a wide range of languages including but not limited to object-oriented ones. Furthermore, meta-compilation techniques or language-agnostic approaches are welcome, too. ### Topics of Interest A non-exclusive list of topics of interest for this workshop is: - Implementation and optimization of fundamental languages features (from automatic memory management to zero-overhead metaprogramming) - Runtime systems technology (libraries, virtual machines) - Static, adaptive, and speculative optimizations and compiler techniques - Meta-compilation techniques and language-agnostic approaches for the efficient implementation of languages - Compilers (intermediate representations, offline and online optimizations,…) - Empirical studies on language usage, benchmark design, and benchmarking methodology - Resource-sensitive systems (real-time, low power, mobile, cloud) - Studies on design choices and tradeoffs (dynamic vs. static compilation, heuristics vs. programmer input,…) - Tooling support, debuggability and observability of languages as well as their implementations ### Workshop Format and Submissions This workshop welcomes the presentation and discussion of new ideas and emerging problems that give a chance for interaction and exchange. More mature work is welcome as part of a mini-conference format, too. We aim to interleave interactive brainstorming and demonstration sessions between the formal presentations to foster an active exchange of ideas. The workshop papers will be published in ACM DL or an open archive (to be confirmed). Papers are to be submitted using the sigplanconf LaTeX template (http://www.sigplan.org/Resources/LaTeXClassFile/). Please submit contributions via EasyChair: https://easychair.org/conferences/submission_show_all.cgi?a=17114062 ### Important Dates Submissions: 18 May 2018 Author Notification: 8 June 2018 ### Program Committee The program committee consists of the organizers and the following reviewers: Nada Amin, University of Cambridge Clément Béra, RMOD - INRIA Lille Nord Europe Shigeru Chiba, University of Tokyo Benoit Daloze, JKU Linz Görel Hedin, Lund University Eric Jul, University of Oslo Stefan Marr, University of Kent Eliot Miranda, Cadence Design Systems Sarah Mount, King's College London Tobias Pape, Hasso Plattner Institute Jennifer Sartor, Vrije Universiteit Brussel + University Ghent ### Workshop Organizers Tim Felgentreff, Oracle Labs Potsdam Olivier Zendra, INRIA / LORIA -- 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.