|
|
||
|---|---|---|
| .. | ||
| Advent_of_Code_2017_December_3rd_files | ||
| jupyter_kernel | ||
| with_sympy_files | ||
| 0._This_Implementation_of_Joy_in_Python.html | ||
| 0._This_Implementation_of_Joy_in_Python.ipynb | ||
| 0._This_Implementation_of_Joy_in_Python.md | ||
| 0._This_Implementation_of_Joy_in_Python.rst | ||
| 1._Basic_Use_of_Joy_in_a_Notebook.html | ||
| 1._Basic_Use_of_Joy_in_a_Notebook.ipynb | ||
| 1._Basic_Use_of_Joy_in_a_Notebook.md | ||
| 1._Basic_Use_of_Joy_in_a_Notebook.rst | ||
| 2._Library_Examples.html | ||
| 2._Library_Examples.ipynb | ||
| 2._Library_Examples.md | ||
| 2._Library_Examples.rst | ||
| 3._Developing_a_Program.html | ||
| 3._Developing_a_Program.ipynb | ||
| 3._Developing_a_Program.md | ||
| 3._Developing_a_Program.rst | ||
| Advent_of_Code_2017_December_1st.html | ||
| Advent_of_Code_2017_December_1st.ipynb | ||
| Advent_of_Code_2017_December_1st.md | ||
| Advent_of_Code_2017_December_1st.rst | ||
| Advent_of_Code_2017_December_2nd.html | ||
| Advent_of_Code_2017_December_2nd.ipynb | ||
| Advent_of_Code_2017_December_2nd.md | ||
| Advent_of_Code_2017_December_2nd.rst | ||
| Advent_of_Code_2017_December_3rd.html | ||
| Advent_of_Code_2017_December_3rd.ipynb | ||
| Advent_of_Code_2017_December_3rd.md | ||
| Advent_of_Code_2017_December_3rd.rst | ||
| Advent_of_Code_2017_December_4th.html | ||
| Advent_of_Code_2017_December_4th.ipynb | ||
| Advent_of_Code_2017_December_4th.md | ||
| Advent_of_Code_2017_December_4th.rst | ||
| Advent_of_Code_2017_December_5th.html | ||
| Advent_of_Code_2017_December_5th.ipynb | ||
| Advent_of_Code_2017_December_5th.md | ||
| Advent_of_Code_2017_December_5th.rst | ||
| Advent_of_Code_2017_December_6th.html | ||
| Advent_of_Code_2017_December_6th.ipynb | ||
| Advent_of_Code_2017_December_6th.md | ||
| Advent_of_Code_2017_December_6th.rst | ||
| Compiling_Joy.html | ||
| Compiling_Joy.ipynb | ||
| Compiling_Joy.md | ||
| Compiling_Joy.rst | ||
| Correcet_Programming.html | ||
| Correcet_Programming.ipynb | ||
| Correcet_Programming.md | ||
| Correcet_Programming.rst | ||
| Derivatives_of_Regular_Expressions.html | ||
| Derivatives_of_Regular_Expressions.ipynb | ||
| Derivatives_of_Regular_Expressions.md | ||
| Derivatives_of_Regular_Expressions.rst | ||
| Generator_Programs.html | ||
| Generator_Programs.ipynb | ||
| Generator_Programs.md | ||
| Generator_Programs.rst | ||
| Hylo-,_Ana-,_Cata-,_and_Para-morphisms_-_Recursion_Combinators.html | ||
| Hylo-,_Ana-,_Cata-,_and_Para-morphisms_-_Recursion_Combinators.ipynb | ||
| Hylo-,_Ana-,_Cata-,_and_Para-morphisms_-_Recursion_Combinators.md | ||
| Hylo-,_Ana-,_Cata-,_and_Para-morphisms_-_Recursion_Combinators.rst | ||
| Joy-in-Jupyter.ipynb | ||
| Library_Examples.pdf | ||
| Makefile | ||
| Multiples-of-3-and-5.ipynb | ||
| Newton-Raphson.html | ||
| Newton-Raphson.ipynb | ||
| Newton-Raphson.md | ||
| Newton-Raphson.rst | ||
| Ordered_Binary_Trees.html | ||
| Ordered_Binary_Trees.ipynb | ||
| Ordered_Binary_Trees.md | ||
| Ordered_Binary_Trees.rst | ||
| Quadratic.html | ||
| Quadratic.ipynb | ||
| Quadratic.md | ||
| Quadratic.rst | ||
| README.md | ||
| Recursion_Combinators.html | ||
| Recursion_Combinators.ipynb | ||
| Recursion_Combinators.md | ||
| Recursion_Combinators.rst | ||
| Remove-Function.ipynb | ||
| Replacing.html | ||
| Replacing.ipynb | ||
| Replacing.md | ||
| Replacing.rst | ||
| Square_Spiral.html | ||
| Square_Spiral.ipynb | ||
| Square_Spiral.md | ||
| Square_Spiral.rst | ||
| The_Four_Operations.html | ||
| The_Four_Operations.ipynb | ||
| The_Four_Operations.md | ||
| The_Four_Operations.rst | ||
| Trees.html | ||
| Trees.ipynb | ||
| Trees.md | ||
| Trees.rst | ||
| Treestep.html | ||
| Treestep.ipynb | ||
| Treestep.md | ||
| Treestep.rst | ||
| TypeChecking.html | ||
| TypeChecking.ipynb | ||
| TypeChecking.md | ||
| TypeChecking.rst | ||
| Types.html | ||
| Types.ipynb | ||
| Types.md | ||
| Types.rst | ||
| Zipper.html | ||
| Zipper.ipynb | ||
| Zipper.md | ||
| Zipper.rst | ||
| fun_with_scan.html | ||
| fun_with_scan.ipynb | ||
| fun_with_scan.md | ||
| fun_with_scan.rst | ||
| notebook_preamble.py | ||
| with_sympy.html | ||
| with_sympy.ipynb | ||
| with_sympy.md | ||
| with_sympy.rst | ||
README.md
Thun Documentation Documentation
Most of the docs take the form of some Jupyter notebooks.
The notebooks are converted (using nbconvert) to HTML, Markdown, and ReST files so you can view them without running Jupyter.
Running the Notebooks with Jupyter
In order to run the Jupyter notebooks you need Jupyter (obviously):
Installing the classic Jupyter Notebook interface
And, of course, you should install Thun (see the main project README or the
online docs).
Once that's done you should be able to start Jupyter Notebook server
in the joypy/docs directory and run the notebooks.
notebook_preamble.py
...something about the notebook_preamble.py file.
Installing the Joy Jupyter Kernel
Tracking down the deets:
- Installing Kernels
- Kernels
- Jupyter kernels
- Jupyter kernels
- Creating new Jupyter kernels
- "Making kernels for Jupyter in the documentation."
From Making simple Python wrapper kernels:
Now create a JSON kernel spec file and install it using
jupyter kernelspec install </path/to/kernel>. Place your kernel module anywhere Python can import it (try current directory for testing).
The current list of kernels:
% jupyter kernelspec list
Available kernels:
python3 /usr/home/sforman/.local/share/jupyter/kernels/python3
Place your kernel module anywhere Python can import it
Yah, okay.
sforman@bock:~/src/Joypy/docs/jupyter_kernel % setenv PYTHONPATH `pwd`
Let's go!
sforman@bock:~/src/Joypy/docs/jupyter_kernel % jupyter kernelspec install .
[Errno 13] Permission denied: '/usr/local/share/jupyter'
Perhaps you want to install with `sudo` or `--user`?
Okay
sforman@bock:~/src/Joypy/docs/jupyter_kernel % jupyter kernelspec install --user .
[InstallKernelSpec] Removing existing kernelspec in /usr/home/sforman/.local/share/jupyter/kernels/.
Traceback (most recent call last):
File "/home/sforman/.local/bin/jupyter-kernelspec", line 8, in <module>
sys.exit(KernelSpecApp.launch_instance())
File "/home/sforman/.local/lib/python3.7/site-packages/traitlets/config/application.py", line 846, in launch_instance
app.start()
File "/home/sforman/.local/lib/python3.7/site-packages/jupyter_client/kernelspecapp.py", line 323, in start
return self.subapp.start()
File "/home/sforman/.local/lib/python3.7/site-packages/jupyter_client/kernelspecapp.py", line 151, in start
replace=self.replace,
File "/home/sforman/.local/lib/python3.7/site-packages/jupyter_client/kernelspec.py", line 404, in install_kernel_spec
shutil.rmtree(destination)
File "/usr/local/lib/python3.7/shutil.py", line 498, in rmtree
onerror(os.rmdir, path, sys.exc_info())
File "/usr/local/lib/python3.7/shutil.py", line 496, in rmtree
os.rmdir(path)
OSError: [Errno 22] Invalid argument: '/usr/home/sforman/.local/share/jupyter/kernels/.'
Looks at code Oh FFS
cp -Rv /usr/home/sforman/src/Joypy/docs/jupyter_kernel /usr/home/sforman/.local/share/jupyter/kernels/thun
/usr/home/sforman/src/Joypy/docs/jupyter_kernel -> /usr/home/sforman/.local/share/jupyter/kernels/thun
/usr/home/sforman/src/Joypy/docs/jupyter_kernel/Try out the Joypy Jupyter Kernel.ipynb -> /usr/home/sforman/.local/share/jupyter/kernels/thun/Try out the Joypy Jupyter Kernel.ipynb
/usr/home/sforman/src/Joypy/docs/jupyter_kernel/joy_kernel.py -> /usr/home/sforman/.local/share/jupyter/kernels/thun/joy_kernel.py
/usr/home/sforman/src/Joypy/docs/jupyter_kernel/kernel.json -> /usr/home/sforman/.local/share/jupyter/kernels/thun/kernel.json
Done. Can start joy kernal notebooks.
But really you want to use the --name switch:
In Joypy/docs/notebooks/jupyter_kernel:
% jupyter kernelspec install --user --name=thun .
[InstallKernelSpec] Installed kernelspec thun in /usr/home/sforman/.local/share/jupyter/kernels/thun
Building and Uploading
This section is mostly for my own reference.
backup-and-remove-htdocs script
On the OSDN server I have a little script I call backup-and-remove-htdocs
which does exactly what it says. Here are the current contents:
#!/usr/bin/env bash
tar cvz --remove-files \
-f $HOME/site-backup-$(date -u +'%F-%T').tgz \
/home/groups/j/jo/joypy/htdocs/*
As you can see, all it does is move the existing site into a tarball (in case I want to refer to it later for some reason.) Every once in a while they should be cleared out.
The main Makefile uses this script via ssh then uses rsync to upload the new version of the site.
Table of Contents
-
- Basic Use of Joy in a Notebook
-
- Library Examples - Short examples of each word in the dictionary. Various formats.
-
- Developing a Program - Working with the first problem from Project Euler, "Find the sum of all the multiples of 3 or 5 below 1000", several forms of the program are derived.
-
- Replacing Functions in the Dictionary - Shows the basics of defining new "primitive" functions in Python or as definitions and adding them to the dictionary.
- Factorial Function and Paramorphisms - A basic pattern of recursive control-flow.
- Generator Programs - Using the x combinator to make generator programs which can be used to create unbounded streams of values.
- Hylo-, Ana-, Cata-morphisms - Some basic patterns of recursive control-flow structures.
- Quadratic - Not-so-annoying Quadratic Formula.
- Trees - Ordered Binary Trees in Joy and more recursion.
- Zipper - A preliminary examination of the idea of data-structure "zippers" for traversing datastructures.
- notebook_preamble.py - Imported into notebooks to simplify the preamble code.
- pe1.py pe1.txt - Set up and execute a Joy program for the first problem from Project Euler. The pe1.txt file is the trace. It's 2.8M uncompressed. Compressed with gzip it becomes just 0.12M.
- repl.py - Run this script to start a REPL. Useful for e.g. running Joy code in a debugger.
Notes
One of the things that interests me about Joy is how programming becomes less about writing code and more about sound reasoning about simple (almost geometric) programs. Many of the notebooks in this collection consist of several pages of discussion to arrive at a few lines of Joy definitions. I think this is a good thing. This is "literate programming". The "programs" resemble mathematical proofs. You aren't implementing so much as deriving. The structure of Joy seems to force you to think clearly about the task in a way that is reliable but extremely flexible. It feels like a puzzle game, and the puzzles are often simple, and the solutions build on each other.