-
Notifications
You must be signed in to change notification settings - Fork 15
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
Reintroduce Join/MeetSemiLattice #95
Comments
I'd recommend to use https://hackage.haskell.org/package/semilattices if you need that. I have to write down my reasoning though for an API change |
It'd be good to see the reasoning. Having to use a separate package is a bit annoying as I have code that works over some types that are lattices and some that are just semi lattices and I'd like to have them use the same operator rather than switching between differently qualified |
Also there is no I have a Would you consider also maintaining v1.*, if only for bumping upper bounds? |
@sgraf812 I did revision for 1.7.1.1 https://hackage.haskell.org/package/lattices-1.7.1.1/revisions/ (looks like GHC-8.10 is fine too). I'll do revision for 2.x versions when I do bigger larger scan of libraries I maintain (after GHC-8.10 is released). About In short Yet, I'm not sure how I even borrowed a book to wrap my head around these issues properly |
Yes, Also, being able to compute the join of two incomparable elements is quite useful at times. In terms of a monotone function TLDR; I like Edit: Reading https://en.wikipedia.org/wiki/Complete_partial_order it seems I had the definition of a chain-complete partial order in mind when writing this. I find that wikipedia page quite confusing everytime I hit it. Anyway, thanks for the version bump! |
Another solution for I tried, and needed to do just two changes in the library (examples define instances, so there is more work). |
Thanks for the suggestion! I'd probably define a Anyway, the current state of things works for me, so no need to change it just yet :) I'm a little worried about potential users (well, in case there will ever be any user of |
I can also use lattices-1.7.1 (thanks for providing that) and heyting-algebras-0.2.0.0 but it's not ideal as we'll definitely be missing future updates/additions. Using 2.0 introduces partial functions as I can't define I still don't understand the need or benefit to combining join/meet lattices while you keep a separation of bounded meet and join lattices. They're two perfectly lawful parts of the hierarchy. |
If you want separate type hierarchy, use https://hackage.haskell.org/package/semilattices. We ( I wont reintroduce Join/MeetSemiLattice class(es). |
@phadej Please help me understand why semi-lattices have been removed. Who benefits from having separate packages for lattices and semi-lattices, with separate class hierarchies and subtly distinct interfaces? Surely if a type is a lattice, it is automatically both a join and a meet semilattice. Can there ever be a technical reason for breaking things apart like this? |
Note that I accepted in #95 (comment) that I just have to define my own type class. I can't switch to https://hackage.haskell.org/package/semilattices, because it has no analog of |
I to would be interested in the reasoning for this change. I can't see the reason for this reordering of the type classes (and it breaks my usages of this package). Above you said you needed to write up the logic, I can't find it yet though. Would you mind explaining please? |
I don't like when there are laws assigned to
class Pointed f where
pure :: a - f a
class Ap f where
(<*>) :: f (a -> b) -> f a -> f b
type Applicative f = (Functor f, Pointed f, Ap f) That's however how hierarchy is modelled in Current (
I'm aware that new hierachy might not fit all the previous use-cases, |
You're of course free to refactor your library as you please, but
I understand the issue about synonyms, but not so much about type classes. What's wrong with a memberless sub class? If Haskell actually had theorem proving capabilities, the proof for the law would surely be part of the type class, so the type class wouldn't even be empty anymore. Declaring the instance in Haskell basically declares a "trust me" proof. I'm not a huge fan if the instance for a memberless sub class is directly implied, though, because that makes it effectively a synonym. Maybe I'm misunderstanding, but the example you gave is just one for the synonym issue, not for the memberless type class issue. |
However, Haskell does not have theorem proving capabilities. In And even if Haskell had: class (Functor f, Pointed f, Ap f) => Applicative f where
...four law members.. then what would be the inferred type of:
It won't be In theorem provers, types are rarely inferred. In Haskell they are, because it's not a theorem prover and laws are not used formally (so we won't overconstraint the type if we don't need to). |
Inference is a convincing example. Thanks! |
But One of the other knock-on effects this has is that, while the "more principled class is the superclass" approach may work in some cases like I'm not going to say "change it back", because obviously competition is great, but it's something to think about. |
That is the problem I'm running into, this arrangement seems to contradict the theory behind lattices. |
But in this case the join and meet instances can't be with respect to the same partial order? But I might be misunderstanding and you're making exactly this point! I think I'd expect
? Not arguing for a change just trying to understand what other interfaces could make sense. |
Not every (JoinSemiLattice a, MeetSemiLattice a) => a is Lattice a, correct. Lattice a comes with extra requirements. If you need those theorems you need to take Lattice. |
Yes - but that is only in the case when the induced partial orders are different? - which I'd argue makes for poor instances. I think that would be fixed by making |
|
Sorry @phadej - I'd seen this and it wasn't a request to make any changes. Just trying to clear up the discussion I'd been having above. I do feel that breaking the hierarchy apart to admit the
That said - thanks for creating/maintaining the library! I understand how much time it can take and underappreciated it can be. |
Yes, precisely. This problem comes from the fact that the purely algebraic take (lattices are composed of a pair of commutative, idempotent monoids that agree as a duoid) and the order-theoretic take (lattices are posets with all finite joins/meets) make slightly different assumptions at different points. In the former case, you need the typeclass due to the pair |
|
Ah yes - that is very nice and something I hadn't considered. You can - albeit with an extra couple of operators - recover that behaviour (and more?) with
but I guess that's just one of the trade-offs. |
The deprecated typeclasses are JoinSemiLattice and MeetSemiLattices. haskellari/lattices#95
Why were Join/MeetSemiLattice dropped from the API?
I have some algebras that can only implement meet (or join) but do not have the other, e.g. they form a partial ordering but can only define lub or glb.
It's a bit of a shame to have the missing step from partial ord to lattice.
The text was updated successfully, but these errors were encountered: