Added properties about DiffList in Data.DifferenceList.Properties #3043
Added properties about DiffList in Data.DifferenceList.Properties #3043mikedelorimier wants to merge 8 commits into
Conversation
|
Why isn't there a Obvious the same isn't true for
|
gallais
left a comment
There was a problem hiding this comment.
Looks good; my only comments are on the old code :D
jamesmckinna
left a comment
There was a problem hiding this comment.
Thanks very much for this @mikedelorimier .
I wholeheartedly agree with the overhaul of this ancient piece of legacy code.
Where I disagree is on the implementation details, but I think the suggestions I offer are intended to expose more of the 'real' structure of what is going on... but YMMV.
I haven't commented on the Properties of functions sections, until such time as the dust settles on this first round of reviewing...
|
Oh, and as a suggested coda to all of the above: ------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 3.0
lift : DiffList A → DiffList A → DiffList A
lift = _++_
{-# WARNING_ON_USAGE lift
"Warning: lift was deprecated in v3.0.
Please use _++_ instead."
#-} |
Co-authored-by: G. Allais <guillaume.allais@ens-lyon.org>
Co-authored-by: jamesmckinna <31931406+jamesmckinna@users.noreply.github.com>
|
You'll also need to add an entry to * `Data.DifferenceList` has been refactored to reexport the contents of two new modules:
- `Data.DifferenceList.Base`
- `Data.DifferenceList.Properties` |
jamesmckinna
left a comment
There was a problem hiding this comment.
Subject to fixing the CHANGELOG, I think this is all good as it is, but maybe could be made a tiny bit more slick when it comes to delegating proofs of xs ∼ ys steps to the corresponding ones in terms of _≗_?
I think we should consider dropping these functions that are not law-abiding. We may also want to name the pattern (Feel free to tell me to do it in a separate PR if you don't want to ;)) |
Makes sense, but can this and I updated the CHANGELOG's |
|
@gallais if you added a second approval, I'd be happy to merge. |
This adds
Data.DifferenceList.Propertiesand movesData.DifferenceListtoData.DifferenceList.Base.DiffListis likeListbut has efficient++.The new file is centered the new relation
xs ~ ysbetweenxs : List Aand its equivalentys : DiffList A.~is kind of like a simulation relation betweenListandDiffList. Each property shows preservation of aListop and its equivalentDiffListop. For examplemap⁺relatesList.mapandDifferenceList.map:It was easier for me to define and use properties on the relation
xs ~ ysthan properties on a transport function betweenListandDiffList(i.e.toListorfromList). The transport approach seemed complicated because there are manyDiffLists that aren't equivalent toLists.This change is motivated by the characterization of
Data.Tree.AVL.Indexed.toList, which was implemented usingDiffListfor efficiency. A followup PR for the AVL'stoListwill use this PR's[]⁺and++-∷⁺(pre-PR code is here).Propertiesalso adds similar properties that seemed natural but are not currently used:∼-fromListtoList∘fromListtoList⁺fromList⁺[_]⁺∷ʳ⁺map⁺. So let me know if you'd like to review this one as a self-contained change or wait for followup PRs and review them all at once.