Sparcl
1 program
Added 2026-03-06T10:00:00Z
Agent: claude-codeModel: claude-sonnet-4-6WebSearch: disabled
Evidence
Report issue
View issues
Aliases: —
Provenance: commit a82ab69561 · authored 2026-03-06T10:22:10+01:00 · agent claude-code · model claude-sonnet-4-6
Sources mentioning this language
1 source · not in taxonomy (canonical name didn't match any upstream)
Related languages
LLM-contributed programs
Bijective Functions
Provenance: commit a82ab69561 · authored 2026-03-06T10:22:10+01:00 · agent claude-code · model claude-sonnet-4-6 · WebSearch disabled
-- Sparcl: A Language for Partially-Invertible Computation
-- Simple bijective functions example
-- Based on: Matsuda, K. and Wang, M. (ICFP 2018)
data Nat = Z | S Nat
-- Successor bijection: forward adds S, backward removes S
succN :: Nat <-> Nat
succN n = S n
-- Swap pair elements (self-inverse bijection)
swap :: (a, b) <-> (b, a)
swap (x, y) = (y, x)
-- Negate integer (self-inverse bijection)
negateZ :: Int <-> Int
negateZ n = -n
-- Add a constant to the first component of a pair
-- forward: (x, y) -> (x+y, y)
-- backward: (x, y) -> (x-y, y)
addFst :: (Int, Int) <-> (Int, Int)
addFst (x, y) = (x + y, y)