-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Equivalence a
Type
#44
Comments
An An implementation using PR welcome. |
Hi, I had some time to implement the I had to add an Also, I typically prefer to use cardinality = Tagged (bell (genericLength (universeF :: [a])))
where bell :: Natural -> Natural
bell n = NE.head (nth n (\ns -> NE.scanl1 (+) (NE.last ns NE.:| NE.toList ns)) (1 NE.:| []))
where nth n = foldr (.) id . replicate (fromIntegral n) But I can of course just refactor |
Can we use I think 4.9 is recent enough (Jan 2017) that it would be desirable to do a tiny bit of CPP so that we can support both before and after smoothly. |
@phadej I apologize because I thought you meant for the Also, I made the changes noted in the previous comment, I had meant to substitute in the cardinality but I am admittedly a
Here is the progress: Unless you have other feedback, I'll move on to
|
Hi, I think this project is really great, thank you for all the work you do on it!
I had an idea which I think is worth mentioning. Going with the description of "... for types where we know all the values" I think their is a good case for
Finite a => Finite (Equivalence a)
(theEquivalence a
type being from http://hackage.haskell.org/package/contravariant-1.5/docs/Data-Functor-Contravariant.html#t:Equivalence). But I'm not sure if that is too specific for your library.For the
cardinality
I think if you wanted to avoid computinguniverseF
to get the length you could just compute the corresponding Bell number:https://en.wikipedia.org/wiki/Equivalence_relation#Counting_possible_partitions
To actually generate the list of partitions I've been using:
And then just in case you are interested here are the helper functions:
So then for the
Finite
instance, you would potentially be able to do something like:Fair warning, I haven't written any of this with performance in mind, but I still think the idea is worth mentioning. If you don't see a use for it please close the ticket I would not take offense!
Have a nice day!
The text was updated successfully, but these errors were encountered: