Skip to content

Instantly share code, notes, and snippets.

@tranma
tranma / Snail.hs
Created September 15, 2012 19:27
Relations, Graphs and Trees
{-# LANGUAGE TupleSections, FlexibleInstances #-}
-- Manipulate graphs for metadata generation
-- WARNING: everything in here is REALLY REALLY REALLY SLOW
--
module Snail
( Rel(..)
, fromList, toList
, allR, differenceR, unionR, composeR, transitiveR
, transClosure
class (Ord (Key table)) => OrderedKV table where
type Key table :: *
type Value table ::*
type Address table :: *
keyRange :: table -> (Key table, Key table)
key2Address :: table -> (Key table) -> Maybe (Address table)
address2Key :: table -> (Address table) -> Key Table
nextAddress :: table -> Address table -> Maybe (Address table)
nextKey :: table -> Key table -> Maybe (Address table) ->Maybe (Key table, Address table )