some project about typed racket - racket

I am doing some study in typed racket.To understand typed racket well, I need some typed racket projects . Can anyone please give me some links where I can find some typed racket source code.Thanks

Leif is probably right about this not being right for SO. But as a quick answer, there is a lot of typed racket code shipped with Racket itself. On Ubuntu, for example, you can search for the line #lang typed/racket in /usr/share/racket/pkgs. Or you can find them on GitHub. The math or images libraries might be a good place to start.

Related

Guidelines on structuring large racket project

Is there any general guidelines (equivalent to How to Write Go Code ) on how to structure large racket project ?
Your question is about structuring large Racket projects, however your example link How to Write Go Code seems mainly to be about how to create a package. These aren't necessarily the same thing (although you might divide a large Racket program into different source directories, which could be "collections" or "packages"). Anyway, to address both parts:
How to structure a large Racket project: Asumu's answer provides a good link: How to Program Racket. In particular see section 3, "Units of Code", which discusses modules. Also, one technique you will see in the source code of Racket itself, is that a module may exist solely to require functions from others and provide them -- to "re-provide". In other words you can use modules like this to chunk up other modules and selectively expose them as a "layer" in your structure. Furthermore, Racket has a class system if that fits your problem domain, and generics if you have some sort of "interface" or "protocol" strategy. And more. Really, there a many, many techniques available in Racket to structure a large project.
How to make Racket packages: This is an interesting time to ask. Historically Racket has used something called Planet as a package manager. More recently, it has a new package system. Although not yet officially out of beta, many people are already using it for real work. The current documentation for that, although in a different style than the Go doc, is Package Management in Racket Beta).
You asked for general guidelines, which is a bit open-ended. If you have any specific choices you're weighing for how to structure a large project, perhaps you could ask about those one by one to get crisper answers?
There is a Racket style guide called How to Program Racket that will ship in the documentation of a future version of Racket. You can read it at the link I posted or in the bundled docs if you build the git version of Racket.

DrRacket autocomplete does not see functions defined in my source code

I am using Racket and DrRacket for a small project (I am trying to learn both and using them to teach a friend of mine some functional programming).
I have just discovered the autocomplete function (C-/) and it works fine with library functions, but it won't see my own functions.
I have also added
(provide (all-defined-out))
at the beginning of my source file (I thought that the autocomplete function might not see the symbols because they are not exported) but this does not solve the problem.
All the symbols are accessible in the DrRacket REPL (I can evaluate my functions and they work fine).
Can you give me any indication on how to solve this problem? Do I need to configure something?
I can confirm that DrRacket currently works this way. The best advice I can give, is to submit a feature request (use "Submit Bugreport" in the Help menu) and then cross your fingers.

Examples on Literate Programming with Racket scribble/lp

In addition to learning Racket I'm trying to learn literate programming. Unfortunately the Racket documentation is sparse to say the least with regards to scribble/lp. Could someone point me to some better resources on this subject or examples of literate programs written in Racket?
Thank you kindly.
Here's a small puzzle game in Racket, using the scribble/lp library: https://github.com/racket/games/blob/master/chat-noir/chat-noir-literate.rkt
Here is another shorter and self - explanatory example:
Project Repository Github.
Project Page using woven output.
It was written to cover some of the gaps in the Racket documentation.

Struggling with common lisp libraries

I've learned scheme and quickly mastered a lot of it, then did a project in it just fine. Literally took me days to finish. I'm now trying to learn common lisp to get a feel for that and now I'm just really really struggling with trying to learn asdf. It seems to be common knowledge how to use it with libraries but I'm baffled. I guess it's because most lisp programs are made and run inside the repl because that all works fine. It's when I try to compile it to an executable where I'm loosing my place.
Is there anyone who can give me any advice on it or point me to a tutorial for it? I really want to be able to make an executable to give to people without having to explain how to install sbcl and (require) it then run it. I just want to learn to do something substantial in lisp that I haven't been able to do with scheme.
I guess I could use scheme and use ffi to get c libraries to work, but I have no experience with c. I'm just a web developer learning lisp for my own personal reasons. Of course learning some c and ffi may not take as long as this haha.
Thanks
I really want to be able to make an
executable to give to people without
having to explain how to install sbcl
and (require) it then run it.
You do not need ASDF in order to produce a 'stand-alone' executable. Most implementations provide means to save an executable image, but how to do this (and if it is to be provided at all) is not mentioned in the standard.
In general, you would load your code into your running image and then "dump" that image.
In SBCL for example, you would use sb-ext:save-lisp-and-die; CCL has ccl:save-application. You will have to look in your implementation's documentation in order to find out how to do it.
I don't have SBCL here at the moment, but this minimal example should work (untested):
(defun do-it () (format t "hello world~%"))
(sb-ext:save-lisp-and-die "hello" :toplevel #'do-it :executable t)
This is a working example using CCL:
Welcome to Clozure Common Lisp Version 1.6-dev-r14287M-trunk (LinuxX8632)!
? (defun do-it () (format t "hello world~%"))
DO-IT
? (ccl:save-application "hello" :toplevel-function #'do-it :prepend-kernel t)
[danlei#susi ~/build/ccl]% ./hello
hello world
These executable images may be of rather big size, unless your implementation provides something like a tree-shaker, but I do not think that this should be a problem nowadays.
You can find a detailed example for clisp in another SO question about this topic.
ASDF Documentation
This is not exactly what you asked for, but it might help.
I never could get ASDF to work very well, either. Somebody pointed me at clbuild instead, which is a slightly different approach to a similar problem. It's worked pretty well for me so far.

Writing Emacs extensions in languages other than Lisp

I'd like to take an existing application (written in OCaml) and create an Emacs "interface" for it (like, for example, the Emacs GDB mode). I would prefer to do this without writing a ton of Lisp code. In MVC terms, I'd like for the View to be Emacs, but for the Model and Controller to remain (primarily) OCaml.
Does anybody know of a way to write Emacs extensions in a language other than Lisp? This could either take the form of bindings to the Emacs extension API in some other language (e.g., making OCaml a first-class Emacs extension language) or an Emacs interaction mode where, for example, the extension has a pipe into which it can write Emacs Lisp expressions and read out result values.
http://www.emacswiki.org/cgi-bin/emacs-en?CategoryExtensionLanguage is a list of all non-Elisp extension languages you can use.
It does appear to be dynamic language centric.
http://common-lisp.net/project/slime/ is missing from that list, as it is not quite an extension language, but an Elisp-Common Lisp bridge. Its source code would show how to communicate back and forth over sockets.
A similar IDE for Erlang is Distel, at http://fresh.homeunix.net/~luke/distel/ (currently down) and https://github.com/massemanet/distel.
Good luck!
I don't know if this will work for your particular problem, but I have been doing something similar using the shell-command-to-string function:
(shell-command-to-string
"bash -c \"script-to-exec args\"")
So for example, we have existing scripts written in python which will mangle a file, so the above lets me invoke the script via emacs lisp.
A quick google search found this page describing a system to write extensions in Python, so it seems feasible to do what you want... you will just have to see if anyone has written a similar framework for OCaml.
Some Extension Api is now possible with the incoming emacs 25.1 and dynamic modules
A Library, emacs-ffi offer a foreign function interface based on libffi.
Check out complete documentation on the README.
Try PyMacs, which allows extending Emacs in Python.
edit: updated link.
From the statically typed languages side, there is something that looks quite performant and well featured for Haskell:
https://github.com/knupfer/haskell-emacs
there is also probably something useful for Scala to be reused from the Ensime project (has a bridge for both Emacs and Vim):
https://github.com/ensime/ensime-server
Furthermore, a quick google search revealed another potential candidate for extending Emacs with a classic FP language, OCaml; the project has a lot of .ml source files so there's got to be an Emacs-OCaml bridge somewhere:
https://github.com/the-lambda-church/merlin
There is no "Extension API". Emacs Lisp is way in there, and it ain't moving.
You can run Emacs commands from your other process. Have a look at Gnuserv.
There are plenty of applications where Emacs is the View for a Model/Controller in a separate process. The Emacs GDB interface is a good example. I'm not sure of a simpler example, maybe sql-postgresql?