Re: [racket-users] How to find source file loaded by/relevant for (require )?
Awesome, that looks like the right thing. Thanks, Marc On Fri, Mar 27, 2020 at 10:08 AM Alexis King wrote: > I recommend Ryan Culpepper’s whereis package: > https://docs.racket-lang.org/whereis/index.html It provides both a > programmatic interface and a raco command. > > Alexis > > On Mar 27, 2020, at 03:56, Marc Kaufmann > wrote: > > Hi, > > I am trying to set up vim such that it jumps to the correct source file > when I see a `(require some-module)`. With packages that I have installed > myself, I have managed to do so (80% solution), since they get installed in > $HOME/.racket//pkgs. However, I can't quite figure out where all > the things are. Some are in > /usr/share/racket/pkgs/-lib/, but > others like racket/match seem to be in /usr/share/racket/collects/... . Are > there any other places for the core modules? > > Rather than me trying to do something error-prone, is there a Racket > function that I can call on that returns the right path on my > machine? That way I don't write stupid error-prone regexes. > > Cheers, > 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. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAD7_NO6QwV0N_jqsxHrnS5E0%2BXdcyBvFTy%3DPVLWxyz74T2EJXA%40mail.gmail.com.
Re: [racket-users] Embedding Racket CS
At Sun, 29 Mar 2020 13:13:08 -0700 (PDT), zeRusski wrote: > First, CS snapshots in Utah and NW mirrors offer no libracketcs.a so I went > ahead and attempted to build CS from the github master. Sadly its `raco` > tool is unaware of the `ctool` subcommand, so I'm guessing snapshots are > built from your own private fork or something. Snapshot builds use the public GitHub repo's master. `raco ctool` is provided by the "cext-lib" package. That package is part of "main-distribution", but maybe you installed a subset of packages when building? > I then started mixing and > matching stuff from snapshot and freshly built github: > - raco, boot files and headers from the snapshot, > - libracketcs.a from github That could work. > Linking against `libracketcs.a` however failed with a bunch of > unresolved symbols like e.g. `CFLocaleCopyCurrent` most of them referenced > from `rktio_convert.o`. You will need to link to some standard libraries and frameworks on Mac OS: `-framework CoreFoundation`, `-liconv`, and `-lncurses`. I didn't try to write this down because it varies so much across platforms, and I expect C programmers to just know. :) But it should be written down or made more automatic. > It wouldn't work anyway since `declare_modules` > also failed to resolve and I'm guessing I really need the `libracketcs.a` > from the snapshot for that. `declare_modules` should be defined in the file generated by `raco ctool --c-mods`. > Another, probably unrelated issue where I'm likely not using the right > incantation is linking in Racket.framework. Even with -F path supplied as > needed `-framework racket` wasn't found. `man ld` for my platform shows it > expects to find (in our case) Racket under Racket.framework so > Racket.framework/Racket but all the frameworks you ship have intermediate > dirs Version/blabla/Racket. I just copied Racket and boot/ under > Racket.framework there to shut the linker up. Am I doing it wrong? A better strategy may be to use `install_name_tool` to update the framework reference to be relative to the executable: install_name_tool -change \ "Racket.framework/Versions/7.6.0.18_CS/Racket" \ "@excutable_path/rel/to/Racket.framework/Versions/7.6.0.18_CS/Racket" \ path_to_your_executable I don't know of a flag to the linker that will do this in the first place. > https://www.cs.utah.edu/plt/snapshots/current/doc/inside/cs.html is atm > quite about calling C. Is it possible or at least in the cards? I'd like to > use the API defined in C from Racket. Calling C from Racket is mostly left to the FFI documentation: https://docs.racket-lang.org/foreign/index.html So, if you link your executable in such a way that `(get-ffi-obj name #f )` can find the functions, then that's all you need. There's also a way to publish C functions to make them visible at the Chez Scheme level: https://cisco.github.io/ChezScheme/csug9.5/foreign.html#./foreign:s272 Then you'd have to propagate that to the Racket level somehow --- maybe by using `vm-eval` from `ffi/unsafe/vm` to access Chez Scheme directly on the Racket side. I haven't given that much thought, so far. -- 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/5e810807.1c69fb81.2cea0.0769SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
Re: [racket-users] Embedding Racket CS
> > It wouldn't work anyway since `declare_modules` also failed to resolve > and I'm guessing I really need the `libracketcs.a` from the snapshot for > that. > Oh ... I see `declare_modules` is produced by `raco ctool`. Why static though? This means I have to #include "hello.c" like in the example in the docs, but hm. At least I know why I was missing this particular symbol. The C codebase in question uses opinionated build tools e.g. `makeheaders` which analyses .c sources and produces corresponding header files, so anything static never makes into that hello.h which I tried to include. > > On Friday, 27 March 2020 22:53:42 UTC, Matthew Flatt wrote: >> >> At Fri, 27 Mar 2020 15:48:13 -0700 (PDT), zeRusski wrote: >> > How I might go about embedding Racket CS >> >> The current development version (as reflected by snapshot builds) now >> has support and documentation for that: >> >> >> https://www.cs.utah.edu/plt/snapshots/current/doc/inside/cs-embedding.html >> >> Of course, let me know if you run into any problems. >> >> >> Matthew >> >> -- 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/8b500094-3aeb-47f8-93f1-b88be1168147%40googlegroups.com.
Re: [racket-users] Embedding Racket CS
Failed so far, sigh. First, CS snapshots in Utah and NW mirrors offer no libracketcs.a so I went ahead and attempted to build CS from the github master. Sadly its `raco` tool is unaware of the `ctool` subcommand, so I'm guessing snapshots are built from your own private fork or something. I then started mixing and matching stuff from snapshot and freshly built github: - raco, boot files and headers from the snapshot, - libracketcs.a from github Am I doing this C thing wrong? :) Compiling modules with `raco ctool` worked fine. Linking against `libracketcs.a` however failed with a bunch of unresolved symbols like e.g. `CFLocaleCopyCurrent` most of them referenced from `rktio_convert.o`. It wouldn't work anyway since `declare_modules` also failed to resolve and I'm guessing I really need the `libracketcs.a` from the snapshot for that. Another, probably unrelated issue where I'm likely not using the right incantation is linking in Racket.framework. Even with -F path supplied as needed `-framework racket` wasn't found. `man ld` for my platform shows it expects to find (in our case) Racket under Racket.framework so Racket.framework/Racket but all the frameworks you ship have intermediate dirs Version/blabla/Racket. I just copied Racket and boot/ under Racket.framework there to shut the linker up. Am I doing it wrong? https://www.cs.utah.edu/plt/snapshots/current/doc/inside/cs.html is atm quite about calling C. Is it possible or at least in the cards? I'd like to use the API defined in C from Racket. Thank you Matthew! On Friday, 27 March 2020 22:53:42 UTC, Matthew Flatt wrote: > > At Fri, 27 Mar 2020 15:48:13 -0700 (PDT), zeRusski wrote: > > How I might go about embedding Racket CS > > The current development version (as reflected by snapshot builds) now > has support and documentation for that: > > > https://www.cs.utah.edu/plt/snapshots/current/doc/inside/cs-embedding.html > > Of course, let me know if you run into any problems. > > > Matthew > > -- 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/2ae01377-c89e-42ca-8ef9-dd1087da97d4%40googlegroups.com.
[racket-users] Working with JSON using Typed Racket
Hi everyone, Recently I've been experimenting with Typed Racket and trying to gradually type my code base. One of the functions that I need to write is to extract a list of strings from a JSON object, if it has following form: { "Type": "DTHidden", "Data": { "Type": "CDUsers", "Data": ["datum1", "datum2"] } } The way I used to structure it in Racket is to have a function `is-cdusers?` with the contract `jsexpr? -> boolean?`, which would check that the JSON object has the right shape; and a separate function `get-cdusers-data` with the contract `is-cdusers? -> listof string?`. However, after playing a bit with Typed Racket I decided that it was necessary, according to my understanding of occurrence typing, to have a single function `get-cdusers-data` with the type `JSExpr -> (U False (Listof String))`. In order to get it to work I ended up writing a long chain of conditionals: (: get-cdusers-data (-> JSExpr (U False (Listof Any (define (get-cdusers-data js) (if (and (hash? js) (equal? DTHidden (hash-ref js 'Type #f))) (let ([js (hash-ref-def js 'Data [ann #hasheq() JSExpr])]) (if (and (hash? js) (equal? CdUsers (hash-ref js 'Type #f))) (let ([data (hash-ref js 'Data)]) (if (hash? data) (let ([x (hash-ref js 'Data #f)]) (and (list? x) x)) #f)) #f)) #f)) Needless to say, this is a bit impractical and error-prone to write. Does anyone know if there is a better approach to this? >From my experience with typed languages I would get that the most principle >approach is to have an algebraic data type that represents all the underlying >data structures, something like type reply = ... | CDUsers of string list | ... and then have a single function to converts a JSExpr into that data type. I was hoping to avoid that, because I do enjoy working with the JSExpr type directly in Racket. Does anyone have advice/experience with problems like this? Best wishes, -Ed -- 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/bc4f73636c65f68b7dae4959ea18dc19%40disroot.org.