Comments (6)
I take it this is because of Nothing
appearing sometimes? It seems like we could tweak the laws to say pred a > succ a where pred a /= Nothing and succ a /= Nothing
, or something like that. Or is there more to it than that?
from purescript-enums.
Yes, any of those would do for writing the checks. Which one is preferable?
from purescript-enums.
The current Enum
class is pretty weird, since the Maybe
cases do only exist to allow for BoundedEnum
s to satisfy it the laws, but I think yeah, just modifying the laws to account for the presence of Maybe
would probably be better than adding a new class.
I can see some benefit in having an UnboundedEnum
, so that is is known succ
and pred
will never return Nothing
and unsafePartial $ fromJust
can be safely used... but yeah, the instances that exist for it a probably relatively rare... a smaller infinity than the types that can implement the other Enum
classes anyway 😄
from purescript-enums.
Would these be enough then?
-- | - succ a > pred a where succ a /= Nothing
-- | - pred a < succ a where succ a /= Nothing
Isn't the second one redundant?
from purescript-enums.
I think where succ a /= Nothing
need applying to all the laws for them to hold? Or do you mean the flipped versions of the laws generally are redundant? They probably are because of the Ord
requirement.
from purescript-enums.
I think this is resolved by #32; please reopen if not.
from purescript-enums.
Related Issues (15)
- No separation between Enumerable and FinitelyEnumerable HOT 1
- BoundedOrd HOT 1
- Inconsistent behavior of enumFromTo for bounded enums HOT 2
- BoundedEnum instance for Int has invalid cardinality HOT 2
- Incorrect assumptions from BoundedEnum laws. HOT 3
- Why isn't BoundedEnum constraint used in defaultSucc and defaultPred? HOT 2
- upFromIncluding :: ∀ a u. Enum a => Unfoldable u => a -> NonEmpty u a HOT 2
- move Cardinality to type level HOT 3
- Consider a SmallBounded type
- `toEnum` modulo `Cardinality a`
- `charToEnum` implementation is wrong HOT 1
- Why succ returns Maybe? HOT 6
- Define BoundedEnum-like class using type-level Ints
- Overlapping instances found HOT 24
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from purescript-enums.