-
Notifications
You must be signed in to change notification settings - Fork 20
Description
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:
-
cardinalityhas typeproxy a -> Integer. Should it beproxy a -> Naturalinstead? -
universehas 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 functionfoowith typeNatural -> Maybe aorNatural -> a, too?universecould perhaps have a default implementation in terms of this function, e.g.universe = takeWhile isJust $ map foo [1..]
My feeling is that a class-specific implementation of
Natural -> Maybe acould be more performant thangenericIndex universe i. -
Would it make sense to have a function
Maybe a -> NaturalonUniverseor a related class? (For more context, my dissatisfaction with Enum'stoEnumandfromEnumusingIntled me here...) -
FinitesaysCreating an instance of this class is a declaration that your
universeeventually ends.This seems very similar to
Bounded. Would it make sense to be able to recover something like aminBoundandmaxBoundwith this class? Such thatminBound == universe `genericIndex` 0 maxBound == universe `genericIndex` (cardinality (Proxy :: Proxy a))
Although there is a law about
universeFterminating, would such bounds with laws like the above give stronger guarantees aboutFinite? I worry thatuniverseFversusuniversedon't tell me very much, since they have the same type[a]. -
Would an
Infiniteclass make sense, e.g.class Universe a => Infinite a where infinite :: Stream a
Reading this library, I see
Universecould be finite or infinite, based on the[a]API. I seeFiniteshould be finite (although I must trustuniverseFterminates). Something likeinfinitewith aStream a-based API could make clear that theStreamreturned byinfinitedoes not terminate. There could also be a lawuniverse == toList infinite
Thanks for your consideration,
Mark