Skip to content

Instantly share code, notes, and snippets.

@cartazio
Last active August 29, 2015 14:05
Show Gist options
  • Save cartazio/584aad55ef6dc6d21703 to your computer and use it in GitHub Desktop.
Save cartazio/584aad55ef6dc6d21703 to your computer and use it in GitHub Desktop.
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 )
sliceTable :: table -> (Address table, Address table) -> Maybe table
readTable :: table -> Address table -> Value table
@cartazio
Copy link
Author

cartazio commented Sep 4, 2014

alternatively, something like this might be better

class (Ord k) => OrderedKV table k v where 
   type Address table :: * 
   keyRange :: table k v -> (k,k)
   key2Address :: table k v  -> k -> (Address table)
...

@cartazio
Copy link
Author

cartazio commented Nov 1, 2014

should revisit this

@tranma
Copy link

tranma commented Nov 19, 2014

I can see how this abstracts the access pattern of [] and Vector, do you think it can be adapted to work with a streaming backend like pipes?

Btw, what is the difference between Key and Address?

@cartazio
Copy link
Author

@TranM i think my key2Address should have been key2Value. IN these apis, Key IS the notion of address

pipes makes sense as a way of streaming chunks that you work on locally, but i dont think its teh interface you want for addressing individual items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment