├── java ├── verification-roadmap.png ├── verification-roadmap.graffle ├── .gitignore ├── package.yaml ├── Makefile ├── Main.hs ├── support.el ├── default.nix └── denotational-design.org /java: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | exec /run/current-system/sw/bin/java -Djava.awt.headless=true "$@" -------------------------------------------------------------------------------- /verification-roadmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jwiegley/thinking-with-functions/HEAD/verification-roadmap.png -------------------------------------------------------------------------------- /verification-roadmap.graffle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jwiegley/thinking-with-functions/HEAD/verification-roadmap.graffle -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.cabal 2 | *.log 3 | *.nav 4 | *.out 5 | *.pdf 6 | *.snm 7 | *.svg 8 | *.tex 9 | *.toc 10 | *.upa 11 | *.vrb 12 | /.diagrams_cache/ 13 | /_minted-denotational-design/ 14 | /auto/ 15 | /dist/ 16 | /svg-inkscape/ 17 | /result 18 | -------------------------------------------------------------------------------- /package.yaml: -------------------------------------------------------------------------------- 1 | name: org-support-code 2 | version: 0.1.0 3 | synopsis: Helper code to be using with org-beamer 4 | github: jwiegley/denotational-design 5 | license: MIT 6 | author: John Wiegley 7 | maintainer: johnw@newartisans.com 8 | category: Development 9 | 10 | dependencies: 11 | - base >= 4.9.1.0 12 | - bytestring >= 0.10.8.1 13 | - containers >= 0.5.7.1 14 | - hspec >= 2.4.3 15 | - lens >= 4.15.1 16 | - lens-aeson >= 1.0.0.5 17 | - mtl >= 2.2.1 18 | - text >= 1.2.2.1 19 | - thyme >= 0.3.5.5 20 | - unordered-containers >= 0.2.8.0 21 | 22 | tests: 23 | org-support-code-tests: 24 | main: Main.hs 25 | ghc-options: -threaded -rtsopts -with-rtsopts=-N 26 | 27 | executables: 28 | org-support-code: 29 | main: Main.hs 30 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | NAME = denotational-design 2 | PYTHON = /usr/bin/python 3 | PRESENT = /Applications/Misc/Présentation.app/Contents/MacOS/presentation.py 4 | PDF = $(NAME).pdf 5 | EMACS = emacs 6 | 7 | all: $(PDF) 8 | 9 | open: $(PDF) 10 | open $< 11 | 12 | present: all 13 | $(PYTHON) $(PRESENT) $(PDF) 14 | 15 | # Ensure all examples work before building the slide deck 16 | %.tex: %.org Makefile 17 | $(EMACS) --debug-init -batch $(EMACS_ARGS) -L . -l support -f perform-extraction $< 18 | 19 | %.pdf: %.tex 20 | xelatex -8bit -shell-escape -interaction nonstopmode $< 21 | xelatex -8bit -shell-escape -interaction nonstopmode $< 22 | xelatex -8bit -shell-escape -interaction nonstopmode $< 23 | 24 | clean: 25 | rm -fr html 26 | rm -f *.tex *.pdf *.vrb *.aux *.log *.nav *.out *.snm *.toc *.upa 27 | rm -f src/*.d src/*.vo src/*.glob 28 | rm -fr _minted-* auto diagram*.svg svg-inkscape *.cabal dist 29 | 30 | watch: 31 | fswatch --batch-marker --latency 2 -m poll_monitor \ 32 | *.hs *.el *.org *.yaml Makefile \ 33 | | while read event; do \ 34 | [[ $$event == NoOp ]] && PATH=$(PWD):$(PATH) make; \ 35 | done 36 | -------------------------------------------------------------------------------- /Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MultiWayIf #-} 2 | 3 | {-# OPTIONS_GHC -Wno-type-defaults #-} 4 | {-# OPTIONS_GHC -Wno-unused-imports #-} 5 | {-# OPTIONS_GHC -Wno-unused-top-binds #-} 6 | 7 | module Main (main) where 8 | 9 | import Control.Exception 10 | import Control.Lens 11 | import Control.Monad.State 12 | import Data.Char 13 | import Data.Data 14 | import Data.Data.Lens 15 | import Data.Function 16 | import Data.List 17 | import Data.Maybe (isJust) 18 | import Data.Map (Map) 19 | import qualified Data.Map as M 20 | import Data.Monoid 21 | import Data.Set (Set) 22 | import qualified Data.Set as S 23 | import Numeric.Natural 24 | import Test.Hspec 25 | 26 | {------------------------------------------------------------------------} 27 | 28 | infixr 0 ==> 29 | (==>) :: (HasCallStack, Show a, Eq a) => a -> a -> Expectation 30 | (==>) = shouldBe 31 | 32 | infixr 0 /=> 33 | (/=>) :: (HasCallStack, Show a, Eq a) => a -> a -> Expectation 34 | (/=>) = shouldNotBe 35 | 36 | infixr 0 !!> 37 | (!!>) :: (HasCallStack, Exception e) => a -> Selector e -> Expectation 38 | v !!> s = pure v `shouldThrow` s 39 | 40 | main :: IO () 41 | main = hspec $ parallel $ 42 | describe "Part" $ 43 | describe "Chapter" $ 44 | describe "Section" $ 45 | it "Test" $ 46 | True 47 | ==> True 48 | 49 | -- Local Variables: 50 | -- haskell-indent-spaces: 2 51 | -- haskell-indentation-ifte-offset: 2 52 | -- haskell-indentation-layout-offset: 2 53 | -- haskell-indentation-left-offset: 2 54 | -- haskell-indentation-starter-offset: 2 55 | -- haskell-indentation-where-post-offset: 2 56 | -- haskell-indentation-where-pre-offset: 2 57 | -- End: 58 | -------------------------------------------------------------------------------- /support.el: -------------------------------------------------------------------------------- 1 | (setq org-latex-default-packages-alist 2 | '(;; ("T1" "fontenc" t) 3 | ("" "fontspec" nil) 4 | ("" "xunicode" nil) 5 | ("" "graphicx" t) 6 | ("" "longtable" nil) 7 | ("" "float" nil) 8 | ("" "wrapfig" nil) 9 | ("" "rotating" nil) 10 | ("normalem" "ulem" t) 11 | ("" "amsmath" t) 12 | ("" "textcomp" t) 13 | ("" "marvosym" t) 14 | ("" "wasysym" t) 15 | ("" "amssymb" t) 16 | ("" "hyperref" nil) 17 | "\\tolerance=1000")) 18 | 19 | (require 'rx) 20 | (require 'ox-latex) 21 | (require 'ox-beamer) 22 | (require 'haskell-mode) 23 | (require 'haskell-customize) 24 | 25 | (setq org-plantuml-jar-path "/run/current-system/sw/lib/plantuml.jar") 26 | (setq org-ditaa-jar-path "/run/current-system/sw/lib/ditaa.jar") 27 | 28 | (org-babel-do-load-languages 29 | 'org-babel-load-languages 30 | '((python . t) 31 | (emacs-lisp . t) 32 | (haskell . t) 33 | (calc . t) 34 | (coq . t) 35 | (ledger . t) 36 | (ditaa . t) 37 | (plantuml . t) 38 | (sh . t) 39 | (dot . t))) 40 | 41 | (setq org-beamer-frame-default-options "fragile") 42 | 43 | (setq org-confirm-babel-evaluate nil) 44 | (setq org-export-babel-evaluate t) 45 | 46 | (setq org-latex-listings 'minted) 47 | 48 | (setq org-latex-minted-options 49 | '(("fontsize" "\\footnotesize") 50 | ("linenos" "false") 51 | ("xleftmargin" "0em"))) 52 | 53 | (setq org-export-latex-minted-options 54 | '(("fontsize" "\\small") 55 | ("linenos" "true"))) 56 | 57 | (setq org-latex-pdf-process 58 | '("xelatex -shell-escape -interaction nonstopmode -output-directory %o %f" 59 | "xelatex -shell-escape -interaction nonstopmode -output-directory %o %f" 60 | "xelatex -shell-escape -interaction nonstopmode -output-directory %o %f")) 61 | 62 | (setq org-export-latex-classes 63 | '(("beamer" "\\documentclass{beamer}" org-beamer-sectioning))) 64 | 65 | (defun extract-code (name) 66 | "Where name has the form foo.bar.baz" 67 | (with-temp-buffer 68 | (insert-file-contents-literally "Main.hs") 69 | 70 | (let ((parts (split-string name "\\."))) 71 | (while parts 72 | (re-search-forward 73 | (rx-to-string `(: word-start ,(if (cdr parts) "describe" "it") 74 | space ?\" ,(car parts) ?\"))) 75 | (forward-line) 76 | (setq parts (cdr parts)))) 77 | 78 | (let ((beg (point))) 79 | (forward-paragraph) 80 | (let ((str (buffer-substring-no-properties beg (point)))) 81 | (with-temp-buffer 82 | (insert str) 83 | (goto-char (point-min)) 84 | (let ((width (skip-chars-forward " "))) 85 | (goto-char (point-min)) 86 | (while (not (eobp)) 87 | (delete-char width) 88 | (forward-line))) 89 | (buffer-string)))))) 90 | 91 | (defun extract-code-blocks () 92 | (goto-char (point-min)) 93 | (while (re-search-forward "^### \\(.+\\)$" nil t) 94 | (let ((name (match-string 1)) 95 | (line (line-number-at-pos (match-end 0)))) 96 | (delete-region (match-beginning 0) (match-end 0)) 97 | (insert "#+begin_src haskell" ?\n) 98 | (condition-case err 99 | (insert (extract-code name)) 100 | (error 101 | (error "Failed to locate test for %s: %s" name err))) 102 | (insert "#+end_src")))) 103 | 104 | (defun perform-extraction () 105 | (find-file (car command-line-args-left)) 106 | (extract-code-blocks) 107 | (org-beamer-export-to-latex)) 108 | 109 | (provide 'support) 110 | -------------------------------------------------------------------------------- /default.nix: -------------------------------------------------------------------------------- 1 | { rev ? "4477cf04b6779a537cdb5f0bd3dd30e75aeb4a3b" 2 | , sha256 ? "1i39wsfwkvj9yryj8di3jibpdg3b3j86ych7s9rb6z79k08yaaxc" 3 | , pkgs ? import (builtins.fetchTarball { 4 | url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz"; 5 | inherit sha256; }) { 6 | config.allowUnfree = true; 7 | config.allowBroken = false; 8 | } 9 | }: 10 | 11 | let 12 | org = pkgs.stdenv.mkDerivation rec { 13 | name = "emacs-org-${version}"; 14 | version = "20160421"; 15 | src = pkgs.fetchFromGitHub { 16 | owner = "jwiegley"; 17 | repo = "org-mode"; 18 | rev = "db5257389231bd49e92e2bc66713ac71b0435eec"; 19 | sha256 = "073cmwgxga14r4ykbgp8w0gjp1wqajmlk6qv9qfnrafgpxic366m"; 20 | }; 21 | preBuild = '' 22 | rm -f contrib/lisp/org-jira.el 23 | makeFlagsArray=( 24 | prefix="$out/share" 25 | ORG_ADD_CONTRIB="org* ox*" 26 | ); 27 | ''; 28 | preInstall = '' 29 | perl -i -pe "s%/usr/share%$out%;" local.mk 30 | ''; 31 | buildInputs = [ pkgs.emacs26 ] ++ (with pkgs; [ texinfo perl which ]); 32 | meta = { 33 | homepage = "https://elpa.gnu.org/packages/org.html"; 34 | license = pkgs.lib.licenses.free; 35 | }; 36 | }; 37 | 38 | texFull = pkgs.texlive.combine { 39 | inherit (pkgs.texlive) scheme-full texdoc latex2e-help-texinfo; 40 | pkgFilter = pkg: 41 | pkg.tlType == "run" 42 | || pkg.tlType == "bin" 43 | || pkg.pname == "latex2e-help-texinfo"; 44 | }; 45 | 46 | ignoredDirs = [ 47 | "html" "_minted-denotational-design" 48 | "auto" "dist" "svg-inkscape" 49 | ]; 50 | 51 | ignoredSuffixes = [ 52 | ".aux" ".cabal" ".log" ".nav" ".out" ".pdf" ".snm" ".svg" 53 | ".tex" ".toc" ".upa" ".vrb" 54 | ]; 55 | in rec { 56 | org-support-code = 57 | pkgs.haskellPackages.callCabal2nix "org-support-code" 58 | (with pkgs.lib; cleanSourceWith { 59 | src = ./.; 60 | filter = path: type: 61 | let baseName = baseNameOf path; in 62 | builtins.elem baseName [ 63 | "Main.hs" 64 | "package.yaml" 65 | ]; 66 | }) {}; 67 | 68 | denotational-design = pkgs.stdenv.mkDerivation rec { 69 | name = "denotational-design"; 70 | version = "1.0"; 71 | 72 | src = 73 | if pkgs.lib.inNixShell 74 | then null 75 | else filterSource ./.; 76 | 77 | buildInputs = [ 78 | org-support-code 79 | org 80 | texFull 81 | pkgs.fontconfig 82 | pkgs.liberation_ttf 83 | pkgs.bash 84 | pkgs.jdk8 85 | pkgs.plantuml 86 | pkgs.ditaa 87 | pkgs.emacs26 88 | pkgs.python27Packages.pygments 89 | pkgs.inkscape.out 90 | pkgs.which 91 | ]; 92 | 93 | patchPhase = '' 94 | substituteInPlace java \ 95 | --replace "/run/current-system/sw/bin/java" \ 96 | "${pkgs.jdk8}/bin/java" 97 | substituteInPlace java \ 98 | --replace "/bin/bash" \ 99 | "${pkgs.bash}/bin/bash" 100 | substituteInPlace support.el \ 101 | --replace "/run/current-system/sw/lib/plantuml.jar" \ 102 | "${pkgs.plantuml}/lib/plantuml.jar" 103 | substituteInPlace support.el \ 104 | --replace "/run/current-system/sw/lib/ditaa.jar" \ 105 | "${pkgs.ditaa}/lib/ditaa.jar" 106 | ''; 107 | 108 | preConfigure = '' 109 | export HOME=$NIX_BUILD_TOP 110 | 111 | mkdir chroot-fontconfig 112 | cat ${pkgs.fontconfig.out}/etc/fonts/fonts.conf > chroot-fontconfig/fonts.conf 113 | sed -e 's@@@' -i chroot-fontconfig/fonts.conf 114 | echo "