identicalsnowflake / cantor-pairing Goto Github PK
View Code? Open in Web Editor NEWConvert data to and from a natural number representation
License: MIT License
Convert data to and from a natural number representation
License: MIT License
Is it intentional that there is no instance for Word
? there are instances for the fixed width word varieties and Int so it surprises me that the instance is missing.
This tree completely breaks because the zero case is not in the expected corner:
data Tree a = Branch (Tree a) a (Tree a) | Node
Is it possible to promote cardinality to the type level? Like,
data Cardinality = Finite Nat | Countable
class Cantor a where
type Measure a :: Cardinality
...
instead of
data Cardinality = Finite Integer | Countable
class Cantor where
cardinality :: Cardinality
...
This would allow to distinguish between finite and countable on type level, eliminating the need in deriving an additional Finite
typeclass. Constraint Finite a
would be simply Measure a ~ Finite n
.
Current HEAD
fails to detect cardinality of mutually-recursive types as Countable
. Here is an example:
{-# LANGUAGE DeriveGeneric, TypeApplications #-}
import Cantor
import GHC.Generics
data Foo = FooNil | Foo Bool Bar deriving (Generic)
data Bar = BarNil | Bar Bool Foo deriving (Generic)
instance Cantor Foo
instance Cantor Bar
main = print $ cardinality @Foo
$ ghc MutualRec.hs && ./MutualRec
MutualRec: <<loop>>
I believe that this can be improved by keepind track of all encountered types (instead of only the last one) in the first argument of GCantor
class, as a type-level list. Does it look worse pursuing?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.