cantor-pairing alternatives and similar packages
Based on the "Data" category.
Alternatively, view cantor-pairing alternatives based on common mentions on social networks and blogs.
-
semantic-source
Parsing, analyzing, and comparing source code across many languages -
lens
Lenses, Folds, and Traversals - Join us on web.libera.chat #haskell-lens -
text
Haskell library for space- and time-efficient operations over Unicode text. -
code-builder
Packages for defining APIs, running them, generating client code and documentation. -
unordered-containers
Efficient hashing-based container types -
compendium-client
Mu (μ) is a purely functional framework for building micro services. -
cassava
A CSV parsing and encoding library optimized for ease of use and high performance -
holmes
A reference library for constraint-solving with propagators and CDCL. -
resource-pool
A high-performance striped resource pooling implementation for Haskell -
binary
Efficient, pure binary serialisation using ByteStrings in Haskell. -
primitive
This package provides various primitive memory-related operations. -
json-autotype
Automatic Haskell type inference from JSON input -
discrimination
Fast linear time sorting and discrimination for a large class of data types -
audiovisual
Extensible records, variants, structs, effects, tangles -
reflection
Reifies arbitrary Haskell terms into types that can be reflected back into terms -
IORefCAS
A collection of different packages for CAS based data structures. -
dependent-map
Dependently-typed finite maps (partial dependent products) -
dependent-sum
Dependent sums and supporting typeclasses for comparing and displaying them -
streaming
An optimized general monad transformer for streaming applications, with a simple prelude of functions -
orgmode-parse
Attoparsec parser combinators for parsing org-mode structured text! -
bifunctors
Haskell 98 bifunctors, bifoldables and bitraversables -
text-icu
This package provides the Haskell Data.Text.ICU library, for performing complex manipulation of Unicode text. -
protobuf
An implementation of Google's Protocol Buffers in Haskell. -
safecopy
An extension to Data.Serialize with built-in version control -
scientific
Arbitrary-precision floating-point numbers represented using scientific notation -
uuid-types
A Haskell library for creating, printing and parsing UUIDs
Access the most powerful time series database as a service
Do you think we are missing an alternative of cantor-pairing or a related project?
README
cantor-pairing
Cantor pairing gives us an isomorphism between a single natural number and pairs of natural numbers. This package provides a modern API to this functionality using GHC generics, allowing the encoding of arbitrary combinations of finite or countably infinite types in natural number form.
As a user, all you need to do is derive generic and get the instances for free.
Example
import GHC.Generics
import Cantor
data MyType = MyType {
value1 :: [ Maybe Bool ]
, value2 :: Integer
} deriving (Generic,Cantor)
This should work nicely even with simple inductive types:
Recursive example
data Tree a = Leaf | Branch (Tree a) a (Tree a) deriving (Generic,Cantor)
If your type is finite, you can specify this by deriving the Finite
typeclass, which is a subclass of Cantor
:
Finite example
data Color = Red | Green | Blue deriving (Generic,Cantor,Finite)
Mutually-recursive types
If you have mutually-recursive types, unfortunately you'll need to manually specify the cardinality for now, but you can still get the to/from encodings for free:
data Foo = FooNil | Foo Bool Bar deriving (Generic,Show)
data Bar = BarNil | Bar Bool Foo deriving (Generic,Show)
instance Cantor Foo where
cardinality = Countable
instance Cantor Bar