







Blog
I consult on all things Clojure: web, backend, Datomic, DataScript, performance, etc. Check out my Github and get in touch niki@tonsky.me
Integrating functional and imperative programming | Proceedings of the 1986 ACM conference on LISP and functional programming
We present a new model, based on monads, for performing input/output in a non-strict, purely functional language. It is composable, extensible, efficient, requires no extensions to the type system, and extends smoothly to incorporate mixed-language ...
Abstract syntax and variable binding
We develop a theory of abstract syntax with variable binding. To every binding signature we associate a category of models consisting of variable sets endowed with compatible algebra and substitution structures. The syntax generated by the signature is the initial model. This gives a notion of initial algebra semantics encompassing the traditional one; besides compositionality, it automatically verifies the semantic substitution lemma.
Home | Monadical Consulting
Monadical is a full-stack software development consultancy. We specialize in full-stack web development and custom software solutions.

Kan Extensions in Haskell
Previously: Tabulation Tribulations. If you think of functor composition as a form of multiplication, Kan extensions are an attempt to construct inverses of this multiplication. But unlike multipli…

Implementing a Hindley-Milner Type System (Part 1) | Blog
First part of a tutorial on implementing a Hindley-Milner type system for a simple, purely functional programming language in Haskell. We go over syntax representation, how the Hindley-Milner type system is defined, polymorphism vs. monomorphism, generalization, and instantiation.
Profunctor Optics, a Categorical Update
Optics are bidirectional data accessors that capture data transformation patterns such as accessing subfields or iterating over containers. Profunctor optics are a particular choice of representation supporting modularity, meaning that we can construct accessors for complex structures by combining simpler ones. Profunctor optics have previously been studied only in an unenriched and non-mixed setting, in which both directions of access are modelled in the same category. However, functional programming languages are arguably better described by enriched categories; and we have found that some structures in the literature are actually mixed optics, with access directions modelled in different categories. Our work generalizes a classic result by Pastro and Street on Tambara theory and uses it to describe mixed V-enriched profunctor optics and to endow them with V-category structure. We provide some original families of optics and derivations, including an elementary one for traversals. Finally, we discuss a Haskell implementation.

Bringing Clojure programming to Enterprise
How a dialect of LISP can help developping modern enterprise applications

Dynamic task delegation for hierarchical agents
This is the fourth installment in a series of papers offering models of hierarchical structure for dynamical systems, using the language of polynomial functors. The operad underlying the symmetric monoidal category $(\mathbf{Poly}, \otimes, \mathcal{y})$ can be viewed as defining the behavior of hierarchical delegation. In particular, a morphism $\mathbf{Poly}(p_1 \otimes \cdots \otimes p_m, q)$ turns the outputs of subordinates with interfaces $p_i$ into the output of an agent with interface $q$ and turns a task given to the agent into a task for each of the subordinates. In this article, we extend the framework so that subordinates may be invoked asynchronously depending on the outcomes of other subordinates. We prove that the free (co)monad (co)monad extends to a (co)monad on $\mathbf{Org}$. From the perspective of programs/pattern, this extension implies the existence of a $\mathbf{Cat}$-enriched operad $\mathbf{Org}_\mathfrak{m}$, and from the perspective of behavior/matter, it implies the existence of a $\mathbf{Cat}$-enriched operad $\mathbf{Org}^\mathfrak{c}$. Second, we crispen the relationship between the programmatic and behavioral perspectives via a functor $[-, t] \colon \mathbf{Org}_{\mathfrak{m}}^\textrm{op} \to \mathbf{Org}^\mathfrak{c}$ for any polynomial monad $t$.

The operad of wiring diagrams: formalizing a graphical language for databases, recursion, and plug-and-play circuits
Wiring diagrams, as seen in digital circuits, can be nested hierarchically and thus have an aspect of self-similarity. We show that wiring diagrams form the morphisms of an operad $\mcT$, capturing this self-similarity. We discuss the algebra $\Rel$ of mathematical relations on $\mcT$, and in so doing use wiring diagrams as a graphical language with which to structure queries on relational databases. We give the example of circuit diagrams as a special case. We move on to show how plug-and-play devices and also recursion can be formulated in the operadic framework as well. Throughout we include many examples and figures.


Functional Query Languages with Categorical Types
We study three category-theoretic types in the context of functional query languages (typed lambda-calculi extended with additional operations for bulk data processing). The types we study are:
Coeffects: a calculus of context-dependent computation
The notion of context in functional languages no longer refers just to variables in scope. Context can capture additional properties of variables (usage patterns in linear logics; caching requirements in dataflow languages) as well as additional resources or properties of the execution environment (rebindable resources; platform version in a cross-platform application). The recently introduced notion of coeffects captures the latter, whole-context properties, but it failed to capture fine-grained per-variable properties.We remedy this by developing a generalized coeffect system with annotations indexed by a coeffect shape. By instantiating a concrete shape, our system captures previously studied flat (whole-context) coeffects, but also structural (per-variable) coeffects, making coeffect analyses more useful. We show that the structural system enjoys desirable syntactic properties and we give a categorical semantics using extended notions of indexed comonad.The examples presented in this paper are based on analysis of established language features (liveness, linear logics, dataflow, dynamic scoping) and we argue that such context-aware properties will also be useful for future development of languages for increasingly heterogeneous and distributed platforms.

Algebraic data integration
In this paper, we develop an algebraic approach to data integration by combining techniques from functional programming, category theory, and database theory. In our formalism, database schemas and instances are algebraic (multi-sorted equational) theories of a certain form. Schemas denote categories, and instances denote their initial (term) algebras. The instances on a schema S form a category, S–Inst, and a morphism of schemas F : S → T induces three adjoint data migration functors: ΣF : S–Inst → T–Inst, defined by substitution along F, which has a right adjoint ΔF : T–Inst → S–Inst, which in turn has a right adjoint ΠF : S–Inst → T–Inst. We present a query language based on for/where/return syntax where each query denotes a sequence of data migration functors; a pushout-based design pattern for performing data integration using our formalism; and describe the implementation of our formalism in a tool we call AQL (Algebraic Query Language).

Categorical logic and type theory
Categorical logic and type theory by Bart Jacobs, 1999, Elsevier Science edition, in English - 1st ed.

See this post on Semble to find connections and similar articles.