Re: [racket-users] How to store a list (or struct...) in SQL and extract again as original Racket value
Thanks, I will give that a try in the future, once I have time to look at PG database (as I have some experience with Mysql, but none with PG). But that would be exactly the kind of thing I was looking for. Cheers, Marc On Tue, Mar 21, 2017 at 8:47 PM, George Neunerwrote: > > On 3/21/2017 8:36 PM, Marc Kaufmann wrote: > > Thanks. But I have to turn it into a string before storing it in the > database; when I tried to store a serialized list in it (in a VARCHAR > field), it complained that it expected a string. That's where all the > trouble came from. The trouble I had was parsing the string back into the > serialized form, which 'with-input-from-string does (because, I presume, it > treats the contents of the string as the input, rather than the string > itself). > > Of course, if there is a way to store serialized data directly in the > database, that would be great - but -- except for arrays in a Postgre > database -- that doesn't seem to be the case. > > > Serialize produce a list. You might try storing it as JSON. Postgresql > can parse and search JSON values. > > https://www.postgresql.org/docs/current/static/datatype-json.html > https://www.postgresql.org/docs/current/static/functions-json.html > > > George > -- 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] How to store a list (or struct...) in SQL and extract again as original Racket value
On 3/21/2017 8:36 PM, Marc Kaufmann wrote: Thanks. But I have to turn it into a string before storing it in the database; when I tried to store a serialized list in it (in a VARCHAR field), it complained that it expected a string. That's where all the trouble came from. The trouble I had was parsing the string back into the serialized form, which 'with-input-from-string does (because, I presume, it treats the contents of the string as the input, rather than the string itself). Of course, if there is a way to store serialized data directly in the database, that would be great - but -- except for arrays in a Postgre database -- that doesn't seem to be the case. Serialize produce a list. You might try storing it as JSON. Postgresql can parse and search JSON values. https://www.postgresql.org/docs/current/static/datatype-json.html https://www.postgresql.org/docs/current/static/functions-json.html George -- 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] How to store a list (or struct...) in SQL and extract again as original Racket value
Oh, never mind. I see what you mean. On Tue, Mar 21, 2017 at 8:42 PM, Jon Zeppieriwrote: > Did you try a using a bytea field? > > On Tue, Mar 21, 2017 at 8:36 PM, Marc Kaufmann > wrote: >> Thanks. But I have to turn it into a string before storing it in the >> database; when I tried to store a serialized list in it (in a VARCHAR >> field), it complained that it expected a string. That's where all the >> trouble came from. The trouble I had was parsing the string back into the >> serialized form, which 'with-input-from-string does (because, I presume, it >> treats the contents of the string as the input, rather than the string >> itself). >> >> Of course, if there is a way to store serialized data directly in the >> database, that would be great - but -- except for arrays in a Postgre >> database -- that doesn't seem to be the case. >> >> >> >> On Tue, Mar 21, 2017 at 8:04 PM, Philip McGrath >> wrote: >>> >>> When you use: >>> (write (~a (serialize '((0 1) (1 0 out) >>> you are first turning the result of deserialize into a string, then >>> writing the string, so read will produce a string. >>> >>> Your example will work correctly if you drop the ~a and just use: >>> (write (serialize '((0 1) (1 0))) out) >>> >>> If that's less than totally clear, for illustrative purposes, consider the >>> following: >>> > (serialize '((0 1) (1 0))) >>> '((3) 0 () 0 () () (q (0 1) (1 0))) >>> > (~a '((3) 0 () 0 () () (q (0 1) (1 0 >>> "((3) 0 () 0 () () (q (0 1) (1 0)))" >>> > (with-output-to-string >>>(λ () (write "((3) 0 () 0 () () (q (0 1) (1 0)))"))) >>> "\"((3) 0 () 0 () () (q (0 1) (1 0)))\"" >>> > (with-input-from-string "\"((3) 0 () 0 () () (q (0 1) (1 0)))\"" >>> read) >>> "((3) 0 () 0 () () (q (0 1) (1 0)))" >>> > (with-output-to-string >>>(λ () (write '((3) 0 () 0 () () (q (0 1) (1 0)) >>> "((3) 0 () 0 () () (q (0 1) (1 0)))" >>> > (with-input-from-string "((3) 0 () 0 () () (q (0 1) (1 0)))" >>> read) >>> '((3) 0 () 0 () () (q (0 1) (1 0))) >>> > (deserialize '((3) 0 () 0 () () (q (0 1) (1 0 >>> '((0 1) (1 0)) >>> >>> On Tue, Mar 21, 2017 at 6:53 PM Marc Kaufmann >>> wrote: Regarding not using deserialize directly: I may be using deserialize in the wrong way, but the following doesn't work (and I had tried that before posting): > (define-values (in out) (make-pipe)) > (write (~a (serialize '((0 1) (1 0) "((3) 0 () 0 () () (q (0 1) (1 0)))" > (write (~a (serialize '((0 1) (1 0 out) > (deserialize (read in)) ; car: contract violation ; expected: pair? ; given: "((3) 0 () 0 () () (q (0 1) (1 0)))" ; [,bt for context] 'read simply returns a string. On the other hand, using Philip's suggestion works (although I can't say I fully understand the subtleties involved): > (define serialized-string (~a (serialize '((0 1) (1 0) > (with-input-from-string serialized-string (lambda () (deserialize > (read '((0 1) (1 0)) Regarding pg-array, I thought (from the docs) that it allowed for multi-dimensional arrays, but since I might need a similar functionality for structs and the like, I thought that I should find another solution. Thanks everyone for the quick response. Cheers, Marc On Tue, Mar 21, 2017 at 5:58 PM, George Neuner wrote: > > On 3/21/2017 5:48 PM, Jon Zeppieri wrote: > > Ah, except apparently `pg-array` only supports arrays with dimension > 1. So... that won't help. > > > I *think* Ryan Culpepper fixed that a long time ago ... though the docs > may never have been updated. I had a workaround at the time and > unfortunately I never did go back to verify the fix in later releases. > > George > > > On 12/18/2014 09:03 PM, George Neuner wrote: > > Using 6.0.1. I just painfully discovered that > >(pg-array->list (list->pg-array (list))) >=> ERROR >pg-array->list: expected argument of type ; > given: (pg-array 0 '() '() '#()) > > The documentation for list->pg-array states that it produces an array > of dimension 1. However, if you pass an empty list, you get back an array > of dimension zero which you then can't transform back to a list [ except > by > going straight to the internal vector ]. > > My question is, "shouldn't these conversions be symmetric?" I > understand an array with no elements is meaningless as an array, but > Postgresql (ab)uses arrays as substitutes for lists and sets, so an empty > array does have meaning. > > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Racket Users" group. > To unsubscribe from this
Re: [racket-users] How to store a list (or struct...) in SQL and extract again as original Racket value
Thanks. But I have to turn it into a string before storing it in the database; when I tried to store a serialized list in it (in a VARCHAR field), it complained that it expected a string. That's where all the trouble came from. The trouble I had was parsing the string back into the serialized form, which 'with-input-from-string does (because, I presume, it treats the contents of the string as the input, rather than the string itself). Of course, if there is a way to store serialized data directly in the database, that would be great - but -- except for arrays in a Postgre database -- that doesn't seem to be the case. On Tue, Mar 21, 2017 at 8:04 PM, Philip McGrathwrote: > When you use: > (write (~a (serialize '((0 1) (1 0 out) > you are first turning the result of deserialize into a string, then > writing the string, so read will produce a string. > > Your example will work correctly if you drop the ~a and just use: > (write (serialize '((0 1) (1 0))) out) > > If that's less than totally clear, for illustrative purposes, consider the > following: > > (serialize '((0 1) (1 0))) > '((3) 0 () 0 () () (q (0 1) (1 0))) > > (~a '((3) 0 () 0 () () (q (0 1) (1 0 > "((3) 0 () 0 () () (q (0 1) (1 0)))" > > (with-output-to-string >(λ () (write "((3) 0 () 0 () () (q (0 1) (1 0)))"))) > "\"((3) 0 () 0 () () (q (0 1) (1 0)))\"" > > (with-input-from-string "\"((3) 0 () 0 () () (q (0 1) (1 0)))\"" > read) > "((3) 0 () 0 () () (q (0 1) (1 0)))" > > (with-output-to-string >(λ () (write '((3) 0 () 0 () () (q (0 1) (1 0)) > "((3) 0 () 0 () () (q (0 1) (1 0)))" > > (with-input-from-string "((3) 0 () 0 () () (q (0 1) (1 0)))" > read) > '((3) 0 () 0 () () (q (0 1) (1 0))) > > (deserialize '((3) 0 () 0 () () (q (0 1) (1 0 > '((0 1) (1 0)) > > On Tue, Mar 21, 2017 at 6:53 PM Marc Kaufmann > wrote: > >> Regarding not using deserialize directly: I may be using deserialize in >> the wrong way, but the following doesn't work (and I had tried that before >> posting): >> >> > (define-values (in out) (make-pipe)) >> > (write (~a (serialize '((0 1) (1 0) >> "((3) 0 () 0 () () (q (0 1) (1 0)))" >> > (write (~a (serialize '((0 1) (1 0 out) >> > (deserialize (read in)) >> ; car: contract violation >> ; expected: pair? >> ; given: "((3) 0 () 0 () () (q (0 1) (1 0)))" >> ; [,bt for context] >> >> 'read simply returns a string. On the other hand, using Philip's >> suggestion works (although I can't say I fully understand the subtleties >> involved): >> >> > (define serialized-string (~a (serialize '((0 1) (1 0) >> > (with-input-from-string serialized-string (lambda () (deserialize >> (read >> '((0 1) (1 0)) >> >> Regarding pg-array, I thought (from the docs) that it allowed for >> multi-dimensional arrays, but since I might need a similar functionality >> for structs and the like, I thought that I should find another solution. >> >> Thanks everyone for the quick response. >> >> Cheers, >> >> Marc >> >> >> On Tue, Mar 21, 2017 at 5:58 PM, George Neuner >> wrote: >> >> On 3/21/2017 5:48 PM, Jon Zeppieri wrote: >> >> Ah, except apparently `pg-array` only supports arrays with dimension >> 1. So... that won't help. >> >> >> I *think* Ryan Culpepper fixed that a long time ago ... though the docs >> may never have been updated. I had a workaround at the time and >> unfortunately I never did go back to verify the fix in later releases. >> >> George >> >> >> On 12/18/2014 09:03 PM, George Neuner wrote: >> >> Using 6.0.1. I just painfully discovered that >> >>(pg-array->list (list->pg-array (list))) >>=> ERROR >>pg-array->list: expected argument of type ; >> given: (pg-array 0 '() '() '#()) >> >> The documentation for list->pg-array states that it produces an array >> of dimension 1. However, if you pass an empty list, you get back an array >> of dimension zero which you then can't transform back to a list [ except by >> going straight to the internal vector ]. >> >> My question is, "shouldn't these conversions be symmetric?" I >> understand an array with no elements is meaningless as an array, but >> Postgresql (ab)uses arrays as substitutes for lists and sets, so an empty >> array does have meaning. >> >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "Racket Users" group. >> To unsubscribe from this topic, visit https://groups.google.com/d/ >> topic/racket-users/xAbm8mlPX-w/unsubscribe. >> To unsubscribe from this group and all its topics, 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
Re: [racket-users] How to store a list (or struct...) in SQL and extract again as original Racket value
Regarding not using deserialize directly: I may be using deserialize in the wrong way, but the following doesn't work (and I had tried that before posting): > (define-values (in out) (make-pipe)) > (write (~a (serialize '((0 1) (1 0) "((3) 0 () 0 () () (q (0 1) (1 0)))" > (write (~a (serialize '((0 1) (1 0 out) > (deserialize (read in)) ; car: contract violation ; expected: pair? ; given: "((3) 0 () 0 () () (q (0 1) (1 0)))" ; [,bt for context] 'read simply returns a string. On the other hand, using Philip's suggestion works (although I can't say I fully understand the subtleties involved): > (define serialized-string (~a (serialize '((0 1) (1 0) > (with-input-from-string serialized-string (lambda () (deserialize (read '((0 1) (1 0)) Regarding pg-array, I thought (from the docs) that it allowed for multi-dimensional arrays, but since I might need a similar functionality for structs and the like, I thought that I should find another solution. Thanks everyone for the quick response. Cheers, Marc On Tue, Mar 21, 2017 at 5:58 PM, George Neunerwrote: > On 3/21/2017 5:48 PM, Jon Zeppieri wrote: > > Ah, except apparently `pg-array` only supports arrays with dimension > 1. So... that won't help. > > > I *think* Ryan Culpepper fixed that a long time ago ... though the docs > may never have been updated. I had a workaround at the time and > unfortunately I never did go back to verify the fix in later releases. > > George > > > On 12/18/2014 09:03 PM, George Neuner wrote: > > Using 6.0.1. I just painfully discovered that > >(pg-array->list (list->pg-array (list))) >=> ERROR >pg-array->list: expected argument of type ; > given: (pg-array 0 '() '() '#()) > > The documentation for list->pg-array states that it produces an array of > dimension 1. However, if you pass an empty list, you get back an array of > dimension zero which you then can't transform back to a list [ except by > going straight to the internal vector ]. > > My question is, "shouldn't these conversions be symmetric?" I > understand an array with no elements is meaningless as an array, but > Postgresql (ab)uses arrays as substitutes for lists and sets, so an empty > array does have meaning. > > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Racket Users" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/racket-users/xAbm8mlPX-w/unsubscribe. > To unsubscribe from this group and all its topics, 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] syntax-parse: using expr/c with ~optional
Thanks! Is there an equivalent approach that works to replace ~optional as a repetition constraint? Given: (define-syntax (prefix stx) > (syntax-parse stx > [(_ (~or (~seq nat:exact-nonnegative-integer) > (~optional (~seq #:tail tail) > #:defaults ([tail #'null]))) > ...) > #:declare tail (expr/c #'(listof natural-number/c)) > #'(list* nat ... tail.c)])) > (define-syntax (prefix/parse stx) > (syntax-parse stx > [(_ (~or (~seq nat:exact-nonnegative-integer) > (~or (~seq #:tail tail) > (~and (~seq) (~parse tail #'null > ...) > #:declare tail (expr/c #'(listof natural-number/c)) > #'(list* nat ... tail.c)])) (prefix 6 5 4) raises the same error as before, and the definition of prefix/parse complains "syntax-parse: duplicate attribute in: tail". On Mon, Mar 20, 2017 at 1:18 PM Alex Knauthwrote: > > On Mar 20, 2017, at 11:04 AM, Philip McGrath > wrote: > > Using expr/c to attach a contract to a macro sub-pattern doesn't seem to > work with ~optional, even when the attribute is bound with #:defaults. > > For example, this program: > > #lang racket > > (require (for-syntax syntax/parse)) > (define-syntax (example stx) > (syntax-parse stx > [(_ (~optional (~seq #:return val) >#:defaults ([val #'42]))) > #:declare val (expr/c #'(or/c list? #f)) > #'val.c])) > (example) > > reports the following error: > > val.c: bad attribute value for syntax template > attribute value: #f > expected for attribute: syntax > sub-value: #f > expected for sub-value: syntax in: val.c > > > Is there a better way to do this? > > > This is because the `val` in the #:defaults is treated as just an > attribute name, not a variable pattern, and syntax-classes like `expr/c` > can only apply to variable patterns. One way to work around this is to use > ~or and ~parse to put it in a pattern position: > > #lang racket > (require (for-syntax syntax/parse)) > (define-syntax example > (syntax-parser > [(_ (~or (~seq #:return val) > (~and (~seq) (~parse val #'42 > #:declare val (expr/c #'(or/c list? #f)) > #'val.c])) > (example) > > This raises the contract violation you expected. > > Alex Knauth > -- 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] How to store a list (or struct...) in SQL and extract again as original Racket value
On 3/21/2017 5:48 PM, Jon Zeppieri wrote: Ah, except apparently `pg-array` only supports arrays with dimension 1. So... that won't help. I *think* Ryan Culpepper fixed that a long time ago ... though the docs may never have been updated. I had a workaround at the time and unfortunately I never did go back to verify the fix in later releases. George On 12/18/2014 09:03 PM, George Neuner wrote: Using 6.0.1. I just painfully discovered that (pg-array->list (list->pg-array (list))) => ERROR pg-array->list: expected argument of type 1>; given: (pg-array 0 '() '() '#()) The documentation for list->pg-array states that it produces an array of dimension 1. However, if you pass an empty list, you get back an array of dimension zero which you then can't transform back to a list [ except by going straight to the internal vector ]. My question is, "shouldn't these conversions be symmetric?" I understand an array with no elements is meaningless as an array, but Postgresql (ab)uses arrays as substitutes for lists and sets, so an empty array does have meaning. -- 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] How to store a list (or struct...) in SQL and extract again as original Racket value
I would do: (with-input-from-string from-db (λ () (deserialize (read On Tue, Mar 21, 2017 at 4:48 PM Jon Zeppieriwrote: > On Tue, Mar 21, 2017 at 5:44 PM, Jon Zeppieri wrote: > > However, postgres (if that's what you're using) > > has multidimensional arrays as a native type, so you could use those > > [https://www.postgresql.org/docs/current/static/arrays.html]. The > > Racket db package has a `pg-array` struct with conversion to/from > > lists to help you. > > > > Ah, except apparently `pg-array` only supports arrays with dimension > 1. So... that won't help. > > -- > 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] How to store a list (or struct...) in SQL and extract again as original Racket value
On Tue, Mar 21, 2017 at 5:44 PM, Jon Zeppieriwrote: > However, postgres (if that's what you're using) > has multidimensional arrays as a native type, so you could use those > [https://www.postgresql.org/docs/current/static/arrays.html]. The > Racket db package has a `pg-array` struct with conversion to/from > lists to help you. > Ah, except apparently `pg-array` only supports arrays with dimension 1. So... that won't help. -- 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] How to store a list (or struct...) in SQL and extract again as original Racket value
On Tue, Mar 21, 2017 at 5:34 PM, Marc Kaufmannwrote: > Hi, > > I want to store matrices of the following form (but larger) in a database: > > (define m '((0 1) (1 0))) > > Currently I manage to store them by turning them into strings first via: > > (~a (serialize m)); Or just drop the serialize, but I figured I might benefit > from it later. > > The problem is that I can only get a string out of the database. Obviously I > could write a parser for this, but it feels a little odd having to write one > for such a simple, and probably common, task. > > The question I have is whether there is a common best practice for storing > such things in a database, or whether I should write a parser? And if I > should write a parser, I presume I should use either Parsack or Megaparsack? Depends on your needs. However, postgres (if that's what you're using) has multidimensional arrays as a native type, so you could use those [https://www.postgresql.org/docs/current/static/arrays.html]. The Racket db package has a `pg-array` struct with conversion to/from lists to help you. If you're not using postgres and you don't actually need to query against the data, just store and retrieve it, then serialize/deserialize is fine. -- 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] How to store a list (or struct...) in SQL and extract again as original Racket value
Hi, I want to store matrices of the following form (but larger) in a database: (define m '((0 1) (1 0))) Currently I manage to store them by turning them into strings first via: (~a (serialize m)); Or just drop the serialize, but I figured I might benefit from it later. The problem is that I can only get a string out of the database. Obviously I could write a parser for this, but it feels a little odd having to write one for such a simple, and probably common, task. The question I have is whether there is a common best practice for storing such things in a database, or whether I should write a parser? And if I should write a parser, I presume I should use either Parsack or Megaparsack? Thanks, Marc -- 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] beautiful-racket, contract-violation: expected: module-path? given ('planet ....)
The unlib package is an old PLaneT package, so it won’t show up when you run `raco pkg show`. It’s a dependency of the snooze package (also from PLaneT), which you appear to have installed. Unfortunately, the unlib package appears to have bitrotted, so it won’t build on modern Racket (due to naming conflicts with new exports from #lang scheme that didn’t use to exist). I’ve actually been looking into bringing snooze and unlib up to date, just in the past few days, but unfortunately, it doesn’t seem to be trivial. Anyway, in the meantime, you should be able to uninstall snooze and unlib by using the `raco planet remove` command. That should get rid of the setup errors. > On Mar 21, 2017, at 12:33 PM, Daniel Bastos> wrote: > > On Tue, Mar 21, 2017 at 1:16 PM, John Clements > wrote: >> It looks to me as though this error may have nothing to do with >> beautiful racket, and that beautiful racket may have installed >> successfully. >> >> In particular, it looks like an error occurred while building the >> docs for ‘unlib’, and that the ‘unlib’ library is something that >> you had installed previously. Is this possible? > > It's possible, though I don't remember installing it. The system > seems to say it's not installed. > > %raco pkg show unlib > Installation-wide: > [none] > User-specific for installation "6.6": > [none] > % -- 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] beautiful-racket, contract-violation: expected: module-path? given ('planet ....)
On Tue, Mar 21, 2017 at 1:16 PM, John Clementswrote: > It looks to me as though this error may have nothing to do with beautiful > racket, and that beautiful racket may have installed successfully. > > In particular, it looks like an error occurred while building the docs for > ‘unlib’, and that the ‘unlib’ library is something that you had installed > previously. Is this possible? It's possible, though I don't remember installing it. The system seems to say it's not installed. %raco pkg show unlib Installation-wide: [none] User-specific for installation "6.6": [none] % > MAJOR CAVEAT: I haven’t investigated carefully, and it’s possible that I’m > misreading this. > > Regardless, I would suggest that the library is probably successfully > installed. See if it’s working. It is installed correctly. %racket -l br/test You installed beautiful-racket v1.0 correctly. -- 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] beautiful-racket, contract-violation: expected: module-path? given ('planet ....)
It looks to me as though this error may have nothing to do with beautiful racket, and that beautiful racket may have installed successfully. In particular, it looks like an error occurred while building the docs for ‘unlib’, and that the ‘unlib’ library is something that you had installed previously. Is this possible? MAJOR CAVEAT: I haven’t investigated carefully, and it’s possible that I’m misreading this. Regardless, I would suggest that the library is probably successfully installed. See if it’s working. John Clements > On Mar 21, 2017, at 3:23 AM, Daniel Bastoswrote: > > This was installed via DrRacket. The generated command line was: > > raco.exe pkg update --deps search-auto --scope user beautiful-racket > > See errors below. Thank you. > > Resolving "beautiful-racket" via > https://download.racket-lang.org/releases/6.6/catalog/ > Resolving "beautiful-racket" via https://pkgs.racket-lang.org > Downloading repository > git://github.com/mbutterick/beautiful-racket/?path=beautiful-racket > 00: Resolving "sugar" via > https://download.racket-lang.org/releases/6.6/catalog/ > 01: Resolving "beautiful-racket-lib" via > https://download.racket-lang.org/releases/6.6/catalog/ > 03: Resolving "brag" via > https://download.racket-lang.org/releases/6.6/catalog/ > 02: Resolving "beautiful-racket-demo" via > https://download.racket-lang.org/releases/6.6/catalog/ > 03: Resolving "brag" via https://pkgs.racket-lang.org > 01: Resolving "beautiful-racket-lib" via https://pkgs.racket-lang.org > 00: Resolving "sugar" via https://pkgs.racket-lang.org > 02: Resolving "beautiful-racket-demo" via https://pkgs.racket-lang.org > Resolving "br-parser-tools-lib" via > https://download.racket-lang.org/releases/6.6/catalog/ > Resolving "br-parser-tools-lib" via https://pkgs.racket-lang.org > Downloading repository git://github.com/mbutterick/sugar > Using cached14900911921490091192188 for > git://github.com/mbutterick/beautiful-racket/?path=beautiful-racket-lib > Using cached14900911921490091192188 for > git://github.com/mbutterick/beautiful-racket/?path=beautiful-racket-demo > Downloading repository git://github.com/mbutterick/brag/?path=brag > Using cached14900912081490091208344 for > git://github.com/mbutterick/brag/?path=br-parser-tools%2Fbr-parser-tools-lib > Resolving "br-parser-tools-doc" via > https://download.racket-lang.org/releases/6.6/catalog/ > Resolving "br-parser-tools-doc" via https://pkgs.racket-lang.org > Using cached14900912081490091208344 for > git://github.com/mbutterick/brag/?path=br-parser-tools%2Fbr-parser-tools-doc > The following uninstalled packages were listed as dependencies > and they were automatically installed: > dependencies of beautiful-racket: > sugar > beautiful-racket-lib > beautiful-racket-demo > brag > br-parser-tools-lib > dependencies of brag: > br-parser-tools-doc > raco setup: version: 6.6 > raco setup: platform: win32\x86_64 [3m] > raco setup: installation name: 6.6 > raco setup: variants: 3m > raco setup: main collects: C:\Users\Daniel\emacs\Racket\collects > raco setup: collects paths: > raco setup: C:\Users\Daniel\AppData\Roaming\Racket\6.6\collects > raco setup: C:\Users\Daniel\emacs\Racket\collects > raco setup: main pkgs: C:\Users\Daniel\emacs\Racket\share\pkgs > raco setup: pkgs paths: > raco setup: C:\Users\Daniel\emacs\Racket\share\pkgs > raco setup: C:\Users\Daniel\AppData\Roaming\Racket\6.6\pkgs > raco setup: links files: > raco setup: C:\Users\Daniel\emacs\Racket\share\links.rktd > raco setup: C:\Users\Daniel\AppData\Roaming\Racket\6.6\links.rktd > raco setup: main docs: C:\Users\Daniel\emacs\Racket\doc > raco setup: --- updating info-domain tables --- > raco setup: updating: > C:\Users\Daniel\AppData\Roaming\Racket\6.6\share\info-cache.rktd > raco setup: --- pre-installing collections --- > raco setup: --- installing foreign libraries --- > raco setup: --- installing shared files --- > raco setup: --- compiling collections --- > raco setup: --- parallel build using 4 jobs --- > raco setup: 3 making: /beautiful-racket-demo/basic-demo > raco setup: 3 making: /beautiful-racket-demo/basic-demo-2 > raco setup: 3 making: /beautiful-racket-demo/basic-demo-2a > raco setup: 3 making: /beautiful-racket-demo/basic-demo-3 > raco setup: 3 making: /beautiful-racket-demo/basic-demo-nth > raco setup: 3 making: /beautiful-racket-demo/bf-demo > raco setup: 3 making: /beautiful-racket-demo/funstacker-demo > raco setup: 2 making: /beautiful-racket-demo/hdl-demo > raco setup: 2 making: /beautiful-racket-demo/hdl-tst-demo > raco setup: 1 making: /beautiful-racket-demo/jsonic-demo > raco setup: 0 making: /beautiful-racket-demo/jsonic-demo-2 > raco setup: 3 making: /beautiful-racket-demo/jsonic-demo-3 > raco setup: 1 making: /beautiful-racket-demo/stacker-demo > raco setup: 2 making: /beautiful-racket-demo/stackerizer-demo > raco setup: 1 making: /beautiful-racket-demo/txtadv-demo > raco setup: 1 making:
Re: [racket-users] How to use the REPL with #lang s-exp "expander.rkt"
On Monday, March 20, 2017 at 7:25:35 PM UTC+1, Matthew Butterick wrote: > On Mar 20, 2017, at 2:59 AM, Jan Hondebrinkwrote: > > Testing top-interaction with expression: (#%top-interaction + 1 2) > . +: unbound identifier; > also, no #%app syntax transformer is bound in: + > > So when you pass an expression through to the racket/base #%module-begin, it > can use the racket/base bindings, but if you pass an expression through to > the racket/base #%top-interaction it cannot. How can you make > #%top-interaction use the racket/base bindings? > > > > > When you start a source file with this line: > > > #lang s-exp "ME-expander.rkt" > > > You are telling Racket to 1) parse the code into expressions using the > default `s-exp` (aka Racket-style) reader and 2) use "ME-expander.rkt" as the > expander module. > > > The expander module supplies the initial set of bindings for the code. > Conversely, if the expander doesn't provide a certain binding, the code can't > use it, and you get an unbound-identifier error. > > > Even though "ME-expander.rkt" is written with `#lang racket/base`, it does > not automatically export the bindings from `racket/base`. If that's the > behavior you want, you need to add this to "ME-expander.rkt": > > > (provide (all-from-out racket/base)) > > > Though you have to be a little careful if you plan to override bindings from > `racket/base` with your own (say, `#%top-interaction` and `#%module-begin`). > In that case, you can omit those bindings with `except-out`: > > > (provide (except-out (all-from-out racket/base) #%top-interaction > #%module-begin)) Thanks for the explanation! It turns out that I don't need "ME-expander.rkt" to export any bindings apart from #%module-begin and #%top-interaction. I overcomplicated Greg's suggestion to supply my own #%top-interaction by thinking it needed to pass its result "up the chain" to the racket/base #%top-interaction. Just as Beautiful Racket taught me to do with #%module-begin. But for #%top-interaction it is not necessary. In "ME-expander.rkt" the following works: #lang racket/base (require (for-syntax racket/base)) (define-syntax (ME-module-begin stx) (syntax-case stx () [(_ s-expressions ...) #'(#%module-begin (apply values (for/list ([expr (list 's-expressions ...)]) (m-eval expr global-environment))) )])) (define-syntax (#%top-interaction stx) #`(m-eval '#,(cdr (syntax-e stx)) global-environment)) (provide (rename-out (ME-module-begin #%module-begin)) #%top-interaction) (define (m-eval exp env) (... --- So let me try and formulate my understanding if this: when using #lang s-expr "ME-expander.rkt" in a source file: - The code in the file (DrRacket definition window) is caught by ME-expander's ME-module-begin which wraps the transformed code in (#%module-begin ...) which is then evaluated using the bindings from racket/base + the bindings in ME-expander (although I'm still a bit shady on how *exactly* that works) - Anything typed in the REPL window is caught by ME-expander's #%top-interaction which just transforms code without wrapping it in a special form, which is then evaluated using the bindings from racket/base + the bindings in ME-expander. -- 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] Typed Racket: Using (Sequenceof a) in place of (Listof a)
For input arguments, it's okay, (Sequenceof a) does accept (Listof a); but for the return value, (Listof a) does not accept (Sequenceof a). You can pass a list as the input, but you cannot narrow the type annotation in you example, say (list->vector) satisfies the annotation, both the input and output are sequences, but the output is not a list. Nonetheless, you can try the intersection type: (: step (All (a b) (-> (-> a (∩ (Sequenceof a) b) (∩ (Sequenceof a) b)) a (∩ (Sequenceof a) b) (∩ (Sequenceof a) b (define (step fn x seq) (fn x seq)) On Tue, Mar 21, 2017 at 12:46 PM, Sourav Dattawrote: > Hello all! > > I have a question regarding how sequence abstraction works in TR. In the > sequence part of the docs it says that a sequence can consist of lists or > vectors among other things. But does this make a function which ideally > accepts a (Listof a) to accept something that is declared as a (Sequenceof > a)? For example, in TR this works: > > (: x (Sequenceof Symbol)) > (define x '(a b c d)) > > However, this shows a type mismatch: > > #lang typed/racket > > (: step (All (a) > (-> (-> a (Sequenceof a) (Sequenceof a)) > a > (Sequenceof a) > (Sequenceof a > (define (step fn x seq) > (fn x seq)) > > > (step (ann cons (-> Symbol (Listof Symbol) (Listof Symbol))) > 'a > '(b c)) > > Results in: > > Type Checker: Polymorphic function `step' could not be applied to > arguments: > Argument 1: > Expected: (-> a (Sequenceof a) (Sequenceof a)) > Given:(-> Symbol (Listof Symbol) (Listof Symbol)) > Argument 2: > Expected: a > Given:'a > Argument 3: > Expected: (Sequenceof a) > Given:(List 'b 'c) > > I think, trying to instantiate the polymorphic step function might help > but I was not able to figure out how. > > Thanks in advance. > > -- > 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] beautiful-racket, contract-violation: expected: module-path? given ('planet ....)
This was installed via DrRacket. The generated command line was: raco.exe pkg update --deps search-auto --scope user beautiful-racket See errors below. Thank you. Resolving "beautiful-racket" via https://download.racket-lang.org/releases/6.6/catalog/ Resolving "beautiful-racket" via https://pkgs.racket-lang.org Downloading repository git://github.com/mbutterick/beautiful-racket/?path=beautiful-racket 00: Resolving "sugar" via https://download.racket-lang.org/releases/6.6/catalog/ 01: Resolving "beautiful-racket-lib" via https://download.racket-lang.org/releases/6.6/catalog/ 03: Resolving "brag" via https://download.racket-lang.org/releases/6.6/catalog/ 02: Resolving "beautiful-racket-demo" via https://download.racket-lang.org/releases/6.6/catalog/ 03: Resolving "brag" via https://pkgs.racket-lang.org 01: Resolving "beautiful-racket-lib" via https://pkgs.racket-lang.org 00: Resolving "sugar" via https://pkgs.racket-lang.org 02: Resolving "beautiful-racket-demo" via https://pkgs.racket-lang.org Resolving "br-parser-tools-lib" via https://download.racket-lang.org/releases/6.6/catalog/ Resolving "br-parser-tools-lib" via https://pkgs.racket-lang.org Downloading repository git://github.com/mbutterick/sugar Using cached14900911921490091192188 for git://github.com/mbutterick/beautiful-racket/?path=beautiful-racket-lib Using cached14900911921490091192188 for git://github.com/mbutterick/beautiful-racket/?path=beautiful-racket-demo Downloading repository git://github.com/mbutterick/brag/?path=brag Using cached14900912081490091208344 for git://github.com/mbutterick/brag/?path=br-parser-tools%2Fbr-parser-tools-lib Resolving "br-parser-tools-doc" via https://download.racket-lang.org/releases/6.6/catalog/ Resolving "br-parser-tools-doc" via https://pkgs.racket-lang.org Using cached14900912081490091208344 for git://github.com/mbutterick/brag/?path=br-parser-tools%2Fbr-parser-tools-doc The following uninstalled packages were listed as dependencies and they were automatically installed: dependencies of beautiful-racket: sugar beautiful-racket-lib beautiful-racket-demo brag br-parser-tools-lib dependencies of brag: br-parser-tools-doc raco setup: version: 6.6 raco setup: platform: win32\x86_64 [3m] raco setup: installation name: 6.6 raco setup: variants: 3m raco setup: main collects: C:\Users\Daniel\emacs\Racket\collects raco setup: collects paths: raco setup: C:\Users\Daniel\AppData\Roaming\Racket\6.6\collects raco setup: C:\Users\Daniel\emacs\Racket\collects raco setup: main pkgs: C:\Users\Daniel\emacs\Racket\share\pkgs raco setup: pkgs paths: raco setup: C:\Users\Daniel\emacs\Racket\share\pkgs raco setup: C:\Users\Daniel\AppData\Roaming\Racket\6.6\pkgs raco setup: links files: raco setup: C:\Users\Daniel\emacs\Racket\share\links.rktd raco setup: C:\Users\Daniel\AppData\Roaming\Racket\6.6\links.rktd raco setup: main docs: C:\Users\Daniel\emacs\Racket\doc raco setup: --- updating info-domain tables --- raco setup: updating: C:\Users\Daniel\AppData\Roaming\Racket\6.6\share\info-cache.rktd raco setup: --- pre-installing collections --- raco setup: --- installing foreign libraries --- raco setup: --- installing shared files --- raco setup: --- compiling collections --- raco setup: --- parallel build using 4 jobs --- raco setup: 3 making: /beautiful-racket-demo/basic-demo raco setup: 3 making: /beautiful-racket-demo/basic-demo-2 raco setup: 3 making: /beautiful-racket-demo/basic-demo-2a raco setup: 3 making: /beautiful-racket-demo/basic-demo-3 raco setup: 3 making: /beautiful-racket-demo/basic-demo-nth raco setup: 3 making: /beautiful-racket-demo/bf-demo raco setup: 3 making: /beautiful-racket-demo/funstacker-demo raco setup: 2 making: /beautiful-racket-demo/hdl-demo raco setup: 2 making: /beautiful-racket-demo/hdl-tst-demo raco setup: 1 making: /beautiful-racket-demo/jsonic-demo raco setup: 0 making: /beautiful-racket-demo/jsonic-demo-2 raco setup: 3 making: /beautiful-racket-demo/jsonic-demo-3 raco setup: 1 making: /beautiful-racket-demo/stacker-demo raco setup: 2 making: /beautiful-racket-demo/stackerizer-demo raco setup: 1 making: /beautiful-racket-demo/txtadv-demo raco setup: 1 making: /beautiful-racket-demo/wires-demo raco setup: 2 making: /beautiful-racket-lib/br raco setup: 0 making: /br-parser-tools-doc/br-parser-tools raco setup: 1 making: /br-parser-tools-lib/br-parser-tools raco setup: 3 making: /beautiful-racket-demo/jsonic-demo-3/scribblings raco setup: 2 making: /beautiful-racket-lib/br/private raco setup: 1 making: /br-parser-tools-lib/br-parser-tools/examples raco setup: 3 making: /brag/brag (brag) raco setup: 3 making: /brag/brag/cfg-parser raco setup: 0 making: /sugar/sugar raco setup: 1 making: /br-parser-tools-lib/br-parser-tools/private-lex raco setup: 1 making: /br-parser-tools-lib/br-parser-tools/private-yacc raco setup: 2 making: /beautiful-racket-lib/br/scribblings raco setup: 0 making: /sugar/sugar/coerce raco setup: 3 making: /brag/brag/codegen raco setup: 3
[racket-users] Call for Papers & Demos: International Workshop on Functional Art, Music, Modelling and Design (FARM)
5th ACM SIGPLAN International Workshop on Functional Art, Music, Modelling and Design Oxford, UK, September, 9th 2017 Key Dates: Submission deadline June 1, 2017 Author Notification July 1, 2017 Camera ReadyJuly 13, 2017 Call for Papers and Demos: The ACM SIGPLAN International Workshop on Functional Art, Music, Modelling and Design (FARM) gathers together people who are harnessing functional techniques in the pursuit of creativity and expression. It is co-located with ICFP 2017, the 22nd ACM SIGPLAN International Conference on Functional Programming. Functional Programming has emerged as a mainstream software development paradigm, and its artistic and creative use is booming. A growing number of software toolkits, frameworks and environments for art, music and design now employ functional programming languages and techniques. FARM is a forum for exploration and critical evaluation of these developments, for example to consider potential benefits of greater consistency, tersity, and closer mapping to a problem domain. FARM encourages submissions from across art, craft and design, including textiles, visual art, music, 3D sculpture, animation, GUIs, video games, 3D printing and architectural models, choreography, poetry, and even VLSI layouts, GPU configurations, or mechanical engineering designs. Theoretical foundations, language design, implementation issues, and applications in industry or the arts are all within the scope of the workshop. The language used need not be purely functional (“mostly functional” is fine), and may be manifested as a domain specific language or tool. Moreover, submissions focusing on questions or issues about the use of functional programming are within the scope. FARM 2017 website : http://functional-art.org/2017/ Submissions We welcome submissions from academic, professional, and independent programmers and artists. Submissions are invited in three categories: 1) Original papers We solicit original papers in the following categories: - Original research - Overview / state of the art - Technology tutorial All submissions must propose an original contribution to the FARM theme. FARM is an interdisciplinary conference, so a wide range of approaches are encouraged. An original paper should have 5 to 12 pages, be in portable document format (PDF), using the ACM SIGPLAN style guidelines and use the ACM SIGPLAN template. [ http://www.sigplan.org/Resources/Author/ ] Accepted papers will be published in the ACM Digital Library as part of the FARM 2017 proceedings. See http://authors.acm.org/main.cfm for information on the options available to authors. Authors are encouraged to submit auxiliary material for publication along with their paper (source code, data, videos, images, etc.); authors retain all rights to the auxiliary material. 2) Demo proposals Demo proposals should describe a demonstration to be given at the FARM workshop and its context, connecting it with the themes of FARM. A demo could be in the form of a short (10-20 minute) tutorial, presentation of work-in-progress, an exhibition of some work, or even a performance. Demo proposals should be in plain text, HTML or Markdown format, and not exceed 2000 words. A demo proposal should be clearly marked as such, by prepending Demo Proposal: to the title. Demo proposals will be published on the FARM website. A summary of the demo performances will also be published as part of the conference proceedings, to be prepared by the program chair. 3) Calls for collaboration Calls for collaboration should describe a need for technology or expertise related to the FARM theme. Examples may include but are not restricted to: - art projects in need of realization - existing software or hardware that may benefit from functional programming - unfinished projects in need of inspiration Calls for collaboration should be in plain text, HTML or Markdown format, and not exceed 5000 words. A call for collaboration should be clearly marked as such, by prepending Call for Collaboration: to the title. Calls for collaboration will be published on the FARM website. Submission is via EasyChair https://easychair.org/conferences/?conf=farm2017 Authors take note The official publication date is the date the proceedings are made available in the ACM Digital Library. This date may be up to two weeks prior to the first day of your conference. The official publication date affects the deadline for any patent filings related to published work. Questions If you have any questions about what type of contributions that might be suitable, or anything else regarding submission or the workshop itself, please contact the organisers at: farm-2...@functional-art.org All presentations at FARM 2017 will be recorded. Permission to publish the resulting video (in all probability on YouTube, along with the videos of ICFP itself and the other ICFP-colocated events) will be requested on-site. --