Skip to content

guaraqe/wirecat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WireCat

wirecat

wirecat is a GHC plugin and small library for writing typed categorical wiring diagrams with a restricted fragment of Haskell proc notation. A single pipeline can be interpreted as executable code or rendered as a graph. Read the motivation for this project here.

The notation currently covers the cartesian part of the language: composition, projection, product-like combination, field relabeling, and primitive operations. Case analysis is the next missing piece for the bicartesian side.

Example

{-# LANGUAGE Arrows #-}
{-# OPTIONS_GHC -fplugin=WireCat #-}

import WireCat

wordCount :: WordCount :> cat => cat Empty Empty
wordCount = proc R {} -> do
  R {path} <- interpret ReadPath -< R {}
  R {text} <- interpret LoadText -< R {path}
  R {words} <- interpret CountWords -< R {text}
  R {lines} <- interpret CountLines -< R {text}
  R {chars} <- interpret CountChars -< R {text}
  interpret WriteReport -< R {path, words, lines, chars}

That same definition can be run with a concrete interpreter, captured as a free categorical term, or exported as DOT, SVG, and JSON for the React viewer:

WireCat

Commands

cabal build all
cabal test all
cabal run examples -- word-count graph
just viewer-dev

Generated example graphs are written to tmp/.

About

WireCat: visual programming with cartesian categories

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors