Skip to content

Instantly share code, notes, and snippets.

@jtpaasch
jtpaasch / coq-dockerfiles.md
Created July 24, 2018 15:48
Some old Coq Dockerfiles

Coq Dockerfiles

These are just experiments. Turns out the ocaml/opam docker containers only use a local copy of the opam repo, so opam update does nothing. Consequently, opam install coq.8.8.1 (for instance) would always say No such package. After I learned that I simply needed to add a remote opam repository to the docker container, regular opam install X started to work again, so my docker files got simpler.

I'm putting these here just to save them somewhere. There are little

@jtpaasch
jtpaasch / software-foundations-lf-Poly.v
Created July 22, 2018 23:15
Software Foundations, Logical Foundations, Poly.v
(** * Poly: Polymorphism and Higher-Order Functions *)
(* Final reminder: Please do not put solutions to the exercises in
publicly accessible places. Thank you!! *)
(* Suppress some annoying warnings from Coq: *)
Set Warnings "-notation-overridden,-parsing".
Require Export Lists.
(* ################################################################# *)
@jtpaasch
jtpaasch / software-foundations-lf-Induction.v
Last active July 22, 2018 23:16
Software Foundations, Logical Foundations, Induction.v
(** * Induction: Proof by Induction *)
(** Before getting started, we need to import all of our
definitions from the previous chapter: *)
Require Export Basics.
(** For the [Require Export] to work, you first need to use
[coqc] to compile [Basics.v] into [Basics.vo]. This is like
making a [.class] file from a [.java] file, or a [.o] file from a
@jtpaasch
jtpaasch / software-foundations-lf-Lists.v
Created July 22, 2018 01:10
Software Foundations, Logical Foundations, Lists.v
(** * Lists: Working with Structured Data *)
Require Export Induction.
Module NatList.
(* ################################################################# *)
(** * Pairs of Numbers *)
(** In an [Inductive] type definition, each constructor can take
any number of arguments -- none (as with [true] and [O]), one (as
@jtpaasch
jtpaasch / software-foundations-lf-Basics.v
Created July 21, 2018 03:19
Software Foundations, Logical Foundations, Basics
(** * Basics: Functional Programming in Coq *)
(* REMINDER:
#####################################################
### PLEASE DO NOT DISTRIBUTE SOLUTIONS PUBLICLY ###
#####################################################
(See the [Preface] for why.)
*)
@jtpaasch
jtpaasch / procstat.ml
Created July 9, 2018 21:08
A simple template for parsing /proc/[pid]/stat files (OCaml).
(* CLI =============================== *)
let pid_value = ref (-1)
let get_pid () = !pid_value
let check () =
match get_pid () with
| (-1) ->
Printf.printf "Error. Please provide a PID.\n%!";
exit 1
@jtpaasch
jtpaasch / OCaml-Project-Layout.md
Created July 5, 2018 14:29
Notes/tutorial on a simple OCaml project scaffold.

OCaml Projects

Simple project

Create a folder called myutility, with a Makefile, as well as a src subfolder:

mkdir ~/myutility
@jtpaasch
jtpaasch / Ocaml-Systems-Programming.md
Created July 5, 2018 14:28
Notes/tutorial on systems programming in OCaml.

OCaml Systems Programming

Including the unix module

To compile

Compile your modules first, e.g.:

@jtpaasch
jtpaasch / tty_table.ml
Created May 27, 2018 16:08
Construct a TTY-printable table string from a table, i.e., a list of string lists (OCaml).
(* A utility for building a table that can be printed on a TTY.
Use it by calling [create], and passing it a list of string lists.
The argument is a list of rows, where each row is a list of strings.
The [create] function returns a string you can print to a TTY. *)
let rec longest items res =
match items with
| [] -> res
| hd :: tl ->
match hd > res with
@jtpaasch
jtpaasch / tty_str.ml
Created May 18, 2018 20:29
Another colorizer/formatter for TTYs (OCaml)
module Tty_str = struct
type ttyfmt =
| Plain
| Red
| Green
| Yellow
| Bold
| Dim
| Italic