-
Notifications
You must be signed in to change notification settings - Fork 19
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
Questions #29
Comments
instance Universe Void where universe = []
Then we'll have a combinatorial problem instance (Infinite a, Universe a) => Infinite (a, b) where
-- or?
instance (Universe a, Infinite a) => Infinite (a, b) where
-- as it's enough that only other argument is infinite. Note: |
👍
Hmm, I haven't tried this yet, but I figured if you can produce a universe = [x0, x1, x2, ...]
-- Naturals: 0, 1, 2, ... And so you could write... indexUniverse :: Natural -> Maybe a
indexUniverse 0 = x0
indexUniverse 1 = x1
indexUniverse 2 = x2
... For products like (+*+) :: (Natural -> Maybe a) -> (Natural -> Maybe b) -> (Natural -> Maybe (a, b)) Maybe this is where the rub is. I'm not sure about
Ah, didn't realize this was an instance. :-)
I was just thinking: for the same reason it might make sense to have a more precise type for |
No big objection to Pairing functions are not enough: when one domain is finite, you no longer want a bijection between (N,N) and N, but between (X, N) and N where X is some finite set. It's not impossible to cook up, but it is hecking annoying, especially if you don't have a really solid compile-time test for the size of X (instances can't be conditional on whether a type is |
@dmwit @phadej thanks for the push to try it out myself. I have created a Gist here. I still need to test and compare to the results of this library, but when playing around in GHCi it seems... OK. I think the instances for |
This seems a bit buggy:
Relatedly, the implementations here seem significantly more complex/fragile. I would definitely want to see analogs of the helpers in http://hackage.haskell.org/package/universe-base-1.0.2.1/docs/Data-Universe-Helpers.html at least for people writing new instances. It seems like a fun idea, though. |
Dang, good catches. I'll keep playing with this and try to land some tests.
Yes, it certainly felt that way writing it... Agree about helpers. I haven't really worked through what supporting these APIs would mean when it comes to writing new instances. Could be tricky. Thanks for taking a look :-) |
I really like the idea of offering a I also wish for an |
Is there the go to |
Hi,
I've been playing around with some toy code that overlaps with some of the problems this library solves. In looking at it, I had a few questions:
cardinality
has typeproxy a -> Integer
. Should it beproxy a -> Natural
instead?universe
has type[a]
. Sometimes you may want the inhabitant at an indexi
. With the current API, I guess you would dogenericIndex universe i
. Would it make sense to have some functionfoo
with typeNatural -> Maybe a
orNatural -> a
, too?universe
could perhaps have a default implementation in terms of this function, e.g.My feeling is that a class-specific implementation of
Natural -> Maybe a
could be more performant thangenericIndex universe i
.Would it make sense to have a function
Maybe a -> Natural
onUniverse
or a related class? (For more context, my dissatisfaction with Enum'stoEnum
andfromEnum
usingInt
led me here...)Finite
saysThis seems very similar to
Bounded
. Would it make sense to be able to recover something like aminBound
andmaxBound
with this class? Such thatAlthough there is a law about
universeF
terminating, would such bounds with laws like the above give stronger guarantees aboutFinite
? I worry thatuniverseF
versusuniverse
don't tell me very much, since they have the same type[a]
.Would an
Infinite
class make sense, e.g.Reading this library, I see
Universe
could be finite or infinite, based on the[a]
API. I seeFinite
should be finite (although I must trustuniverseF
terminates). Something likeinfinite
with aStream a
-based API could make clear that theStream
returned byinfinite
does not terminate. There could also be a lawuniverse == toList infinite
Thanks for your consideration,
Mark
The text was updated successfully, but these errors were encountered: